From: Jay Freeman (saurik) Date: Fri, 30 Oct 2009 23:31:25 +0000 (+0000) Subject: Setup iPhone cross-compilation and runtime abstracted JSObjectMakeArray support. X-Git-Tag: v0.9.432~228 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/e0625f37947994a0b96c15cc3b56c5a6b13642e2?ds=sidebyside Setup iPhone cross-compilation and runtime abstracted JSObjectMakeArray support. --- diff --git a/Library.cpp b/Library.cpp index cbeeb2a..d80978e 100644 --- a/Library.cpp +++ b/Library.cpp @@ -1302,19 +1302,24 @@ static JSStaticFunction Type_staticFunctions[4] = { {NULL, NULL, 0} }; +static JSObjectRef (*$JSObjectMakeArray)(JSContextRef, size_t, const JSValueRef[], JSValueRef *); + void CYSetArgs(int argc, const char *argv[]) { JSContextRef context(CYGetJSContext()); JSValueRef args[argc]; for (int i(0); i != argc; ++i) args[i] = CYCastJSValue(context, argv[i]); -#ifdef __APPLE__ - JSValueRef exception(NULL); - JSObjectRef array(JSObjectMakeArray(context, argc, args, &exception)); - CYThrow(context, exception); -#else - JSValueRef value(CYCallAsFunction(context, Array_, NULL, argc, args)); - JSObjectRef array(CYCastJSObject(context, value)); -#endif + + JSObjectRef array; + if ($JSObjectMakeArray != NULL) { + JSValueRef exception(NULL); + array = (*$JSObjectMakeArray)(context, argc, args, &exception); + CYThrow(context, exception); + } else { + JSValueRef value(CYCallAsFunction(context, Array_, NULL, argc, args)); + array = CYCastJSObject(context, value); + } + CYSetProperty(context, System_, CYJSString("args"), array); } @@ -1376,6 +1381,8 @@ void CYInitialize() { _aprcall(apr_initialize()); _aprcall(apr_pool_create(&Pool_, NULL)); _sqlcall(sqlite3_open("/usr/lib/libcycript.db", &Bridge_)); + + $JSObjectMakeArray = reinterpret_cast(dlsym(RTLD_DEFAULT, "JSObjectMakeArray")); } apr_pool_t *CYGetGlobalPool() { diff --git a/iPhone.mk b/iPhone.mk new file mode 100644 index 0000000..ac6ab20 --- /dev/null +++ b/iPhone.mk @@ -0,0 +1,4 @@ +uname_s := Darwin +uname_p := arm +paths := ~/menes/mobilesubstrate +include makefile diff --git a/iPhone.sh b/iPhone.sh new file mode 100755 index 0000000..7422689 --- /dev/null +++ b/iPhone.sh @@ -0,0 +1 @@ +PKG_ARCH=iphoneos-arm /apl/tel/exec.sh :apr-lib:libffi:readline:sqlite3 make -f iPhone.mk diff --git a/makefile b/makefile index fb9a6c8..c608315 100644 --- a/makefile +++ b/makefile @@ -6,7 +6,8 @@ else target := $(PKG_TARG)- endif -flags := +paths := $(foreach path,$(paths),$(wildcard $(path))) +flags := $(foreach path,$(paths),-I$(path) -L$(path)) objc := svn := $(shell svnversion) @@ -34,8 +35,14 @@ library := $(apr) -lffi -lsqlite3 console := $(apr) -lreadline depends := +ifndef uname_s uname_s := $(shell uname -s) +endif + +ifndef uname_p uname_p := $(shell uname -p) +endif + -include $(uname_s).mk -include $(uname_s)-$(uname_p).mk