]> git.saurik.com Git - cycript.git/blobdiff - ObjectiveC/Replace.mm
OMG, the last fix didn't even work, because Apple's compiler doesn't even consider...
[cycript.git] / ObjectiveC / Replace.mm
index e25ff8625ac4eb9090c5d439ae51dafb4027b41d..494c6dd1641e78c12b9442b3d5aae05a267a95ac 100644 (file)
@@ -40,7 +40,7 @@
 #include "Replace.hpp"
 #include "ObjectiveC/Syntax.hpp"
 
-#include <objc/runtime.h>
+#include <Foundation/Foundation.h>
 #include <sstream>
 
 CYStatement *CYCategory::Replace(CYContext &context) {
@@ -135,13 +135,17 @@ CYString *CYSelectorPart::Replace(CYContext &context) {
 CYExpression *CYSendDirect::Replace(CYContext &context) {
     std::ostringstream name;
     CYArgument **argument(&arguments_);
+    CYSelectorPart *selector(NULL), *current(NULL);
 
     while (*argument != NULL) {
         if ((*argument)->name_ != NULL) {
-            name << *(*argument)->name_;
+            CYSelectorPart *part($ CYSelectorPart((*argument)->name_, (*argument)->value_ != NULL));
+            if (selector == NULL)
+                selector = part;
+            if (current != NULL)
+                current->SetNext(part);
+            current = part;
             (*argument)->name_ = NULL;
-            if ((*argument)->value_ != NULL)
-                name << ':';
         }
 
         if ((*argument)->value_ == NULL)
@@ -150,10 +154,7 @@ CYExpression *CYSendDirect::Replace(CYContext &context) {
             argument = &(*argument)->next_;
     }
 
-    SEL sel(sel_registerName(name.str().c_str()));
-    double address(static_cast<double>(reinterpret_cast<uintptr_t>(sel)));
-
-    return $C2($V("objc_msgSend"), self_, $D(address), arguments_);
+    return $C2($V("objc_msgSend"), self_, ($ CYSelector(selector))->Replace(context), arguments_);
 }
 
 CYExpression *CYSendSuper::Replace(CYContext &context) {