]> git.saurik.com Git - cycript.git/blobdiff - Execute.cpp
Allow usage of .type on objects of type Message.
[cycript.git] / Execute.cpp
index c4a1fbb937cca1856f4545ffe3ee09d1365f57b6..8cd0c908698650666fc8d4acaf78b4a44cb5bb57 100644 (file)
@@ -1419,6 +1419,10 @@ static JSStaticValue Functor_staticValues[2] = {
     {NULL, NULL, NULL, 0}
 };
 
+namespace cy {
+    JSStaticValue const * const Functor::StaticValues = Functor_staticValues;
+}
+
 static JSStaticValue Type_staticValues[4] = {
     {"alignment", &Type_getProperty_alignment, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
     {"name", &Type_getProperty_name, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
@@ -1666,49 +1670,6 @@ void *CYMapFile(const char *path, size_t *psize) {
     return base;
 }
 
-static void CYRunSetups(JSContextRef context) {
-    std::string folder("/etc/cycript/setup.d");
-    DIR *setups(opendir(folder.c_str()));
-    if (setups == NULL)
-        return;
-
-    for (;;) {
-        dirent setup;
-        dirent *result;
-        _syscall(readdir_r(setups, &setup, &result));
-
-        if (result == NULL)
-            break;
-        _assert(result == &setup);
-
-        const char *name(setup.d_name);
-        size_t length(strlen(name));
-        if (length < 4)
-            continue;
-
-        if (name[0] == '.')
-            continue;
-        if (memcmp(name + length - 3, ".cy", 3) != 0)
-            continue;
-
-        std::string script(folder + "/" + name);
-        CYUTF8String utf8;
-        utf8.data = reinterpret_cast<char *>(CYMapFile(script.c_str(), &utf8.size));
-
-        CYPool pool;
-        CYUTF16String utf16(CYPoolUTF16String(pool, utf8));
-        munmap(const_cast<char *>(utf8.data), utf8.size);
-
-        // XXX: this should not be used
-        CydgetMemoryParse(&utf16.data, &utf16.size);
-
-        CYExecute(context, pool, CYPoolUTF8String(pool, utf16));
-        free(const_cast<uint16_t *>(utf16.data));
-    }
-
-    _syscall(closedir(setups));
-}
-
 static JSValueRef require(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
     _assert(count == 1);
     CYPool pool;
@@ -1769,6 +1730,12 @@ extern "C" void CYSetupContext(JSGlobalContextRef context) {
     JSObjectRef Array_prototype(CYCastJSObject(context, CYGetProperty(context, Array, prototype_s)));
     CYSetProperty(context, cy, CYJSString("Array_prototype"), Array_prototype);
 
+    JSObjectRef Boolean(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Boolean"))));
+    CYSetProperty(context, cy, CYJSString("Boolean"), Boolean);
+
+    JSObjectRef Boolean_prototype(CYCastJSObject(context, CYGetProperty(context, Boolean, prototype_s)));
+    CYSetProperty(context, cy, CYJSString("Boolean_prototype"), Boolean_prototype);
+
     JSObjectRef Error(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Error"))));
     CYSetProperty(context, cy, CYJSString("Error"), Error);
 
@@ -1778,6 +1745,12 @@ extern "C" void CYSetupContext(JSGlobalContextRef context) {
     JSObjectRef Function_prototype(CYCastJSObject(context, CYGetProperty(context, Function, prototype_s)));
     CYSetProperty(context, cy, CYJSString("Function_prototype"), Function_prototype);
 
+    JSObjectRef Number(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Number"))));
+    CYSetProperty(context, cy, CYJSString("Number"), Number);
+
+    JSObjectRef Number_prototype(CYCastJSObject(context, CYGetProperty(context, Number, prototype_s)));
+    CYSetProperty(context, cy, CYJSString("Number_prototype"), Number_prototype);
+
     JSObjectRef Object(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Object"))));
     CYSetProperty(context, cy, CYJSString("Object"), Object);
 
@@ -1848,8 +1821,6 @@ extern "C" void CYSetupContext(JSGlobalContextRef context) {
         (*hooks_->SetupContext)(context);
 
     CYArrayPush(context, alls, cycript);
-
-    CYRunSetups(context);
 }
 
 static JSGlobalContextRef context_;