]> git.saurik.com Git - cycript.git/blobdiff - ObjectiveC/Library.mm
As FunctionInstance is different, it must be last.
[cycript.git] / ObjectiveC / Library.mm
index 46c7f98970fb3b1a7e056feeb22f2232e038d4e9..33ccaf0dade7df56081a8be618f57617c62fa3b5 100644 (file)
@@ -2315,8 +2315,9 @@ static void choose_(task_t task, void *baton, unsigned type, vm_range_t *ranges,
         if (result == choice->query_.end())
             continue;
 
-        // XXX: if (size < class_getInstanceSize(*result))
-        if ((class_getInstanceSize(*result) + 15) / 16 * 16 != size)
+        size_t needed(class_getInstanceSize(*result));
+        // XXX: if (size < needed)
+        if (needed <= 496 && (needed + 15) / 16 * 16 != size || needed > 496 && (needed + 511) / 512 * 512 != size)
             continue;
         CYArrayPush(context, choice->results_, CYCastJSValue(context, reinterpret_cast<id>(data)));
     }
@@ -2858,11 +2859,6 @@ void CYObjectiveC_Initialize() { /*XXX*/ JSContextRef context(NULL); CYPoolTry {
     definition.className = "BooleanInstance";
     BooleanInstance_ = JSClassCreate(&definition);
 
-    definition.className = "FunctionInstance";
-    definition.staticValues = FunctionInstance_staticValues;
-    definition.callAsFunction = &FunctionInstance_callAsFunction;
-    FunctionInstance_ = JSClassCreate(&definition);
-
     definition.className = "NumberInstance";
     NumberInstance_ = JSClassCreate(&definition);
 
@@ -2872,6 +2868,11 @@ void CYObjectiveC_Initialize() { /*XXX*/ JSContextRef context(NULL); CYPoolTry {
     definition.className = "StringInstance";
     StringInstance_ = JSClassCreate(&definition);
 
+    definition.className = "FunctionInstance";
+    definition.staticValues = FunctionInstance_staticValues;
+    definition.callAsFunction = &FunctionInstance_callAsFunction;
+    FunctionInstance_ = JSClassCreate(&definition);
+
     definition = kJSClassDefinitionEmpty;
     definition.className = "Class";
     definition.staticFunctions = Class_staticFunctions;