From: Jay Freeman (saurik) Date: Sun, 1 Nov 2009 01:30:13 +0000 (+0000) Subject: Implemented dpkg dependency generation for Leopard and fixed null symbol dereferences. X-Git-Tag: v0.9.432~209 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/65cf734f56bb94c76facc4b74aa16245e209d1f2 Implemented dpkg dependency generation for Leopard and fixed null symbol dereferences. --- diff --git a/Library.cpp b/Library.cpp index a981b2b..a6e9e4e 100644 --- a/Library.cpp +++ b/Library.cpp @@ -1118,17 +1118,21 @@ static JSValueRef Runtime_getProperty(JSContextRef context, JSObjectRef object, case 0: return JSEvaluateScript(CYGetJSContext(), CYJSString(value), NULL, NULL, 0, NULL); - case 1: - return CYMakeFunctor(context, reinterpret_cast(CYCastSymbol(name.data)), value); - case 2: { - // XXX: this is horrendously inefficient - sig::Signature signature; - sig::Parse(pool, &signature, value, &Structor_); - ffi_cif cif; - sig::sig_ffi_cif(pool, &sig::ObjectiveC, &signature, &cif); - return CYFromFFI(context, signature.elements[0].type, cif.rtype, CYCastSymbol(name.data)); - } + case 1: + if (void (*symbol)() = reinterpret_cast(CYCastSymbol(name.data))) + return CYMakeFunctor(context, symbol, value); + else return NULL; + + case 2: + if (void *symbol = CYCastSymbol(name.data)) { + // XXX: this is horrendously inefficient + sig::Signature signature; + sig::Parse(pool, &signature, value, &Structor_); + ffi_cif cif; + sig::sig_ffi_cif(pool, &sig::ObjectiveC, &signature, &cif); + return CYFromFFI(context, signature.elements[0].type, cif.rtype, symbol); + } else return NULL; // XXX: implement case 3 case 4: diff --git a/makefile b/makefile index 2b8d45c..69ec15e 100644 --- a/makefile +++ b/makefile @@ -66,13 +66,18 @@ all: $(deb) extra: -ifeq ($(depends)$(dll),.so) +ifeq ($(depends)$(dll),dylib) +control: control.in cycript libcycript.dylib + sed -e 's/&/'"$$(dpkg-query -S $$(otool -lah cycript *.dylib | grep dylib | grep -v ':$$' | sed -e 's/^ *name //;s/ (offset [0-9]*)$$//' | sort -u) 2>/dev/null | sed -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ +else +ifeq ($(depends)$(dll),so) control: control.in cycript libcycript.so sed -e 's/&/'"$$(dpkg-query -S $$(ldd cycript libcycript.so | sed -e '/:$$/ d; s/^[ \t]*\([^ ]* => \)\?\([^ ]*\) .*/\2/' | sort -u) 2>/dev/null | sed -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ else control: control.in sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ endif +endif $(deb): $(all) control rm -rf package