From: Jay Freeman (saurik) Date: Fri, 16 Oct 2009 16:17:39 +0000 (+0000) Subject: Got the makefile to not rebuild the .deb constantly, and decided to attempt property... X-Git-Tag: v0.9.432~340 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/8953777c43f12e351c33843855be46ca71c3edcb Got the makefile to not rebuild the .deb constantly, and decided to attempt property autodetection. --- diff --git a/Library.mm b/Library.mm index 350c659..7a1872c 100644 --- a/Library.mm +++ b/Library.mm @@ -1714,13 +1714,19 @@ static JSValueRef Instance_getProperty(JSContextRef context, JSObjectRef object, } CYPoolCatch(NULL) const char *string(CYPoolCString(pool, name)); + Class _class(object_getClass(self)); - if (objc_property_t property = class_getProperty(object_getClass(self), string)) { + if (objc_property_t property = class_getProperty(_class, string)) { PropertyAttributes attributes(property); SEL sel(sel_registerName(attributes.Getter())); return CYSendMessage(pool, context, self, sel, 0, NULL, false, exception); } + if (SEL sel = sel_getUid(string)) + // XXX: possibly use a more "awesome" check? + if (class_getInstanceMethod(_class, sel) != NULL) + return CYSendMessage(pool, context, self, sel, 0, NULL, false, exception); + return NULL; } CYCatch } @@ -1744,8 +1750,9 @@ static bool Instance_setProperty(JSContextRef context, JSObjectRef object, JSStr } CYPoolCatch(NULL) const char *string(CYPoolCString(pool, name)); + Class _class(object_getClass(self)); - if (objc_property_t property = class_getProperty(object_getClass(self), string)) { + if (objc_property_t property = class_getProperty(_class, string)) { PropertyAttributes attributes(property); if (const char *setter = attributes.Setter()) { SEL sel(sel_registerName(setter)); @@ -1755,6 +1762,29 @@ static bool Instance_setProperty(JSContextRef context, JSObjectRef object, JSStr } } + size_t length(strlen(string)); + + char set[length + 5]; + + set[0] = 's'; + set[1] = 'e'; + set[2] = 't'; + + if (string[0] != '\0') { + set[3] = toupper(string[0]); + memcpy(set + 4, string + 1, length - 1); + } + + set[length + 3] = ':'; + set[length + 4] = '\0'; + + if (SEL sel = sel_getUid(set)) + // XXX: possibly use a more "awesome" check? + if (class_getInstanceMethod(_class, sel) != NULL) { + JSValueRef arguments[1] = {value}; + CYSendMessage(pool, context, self, sel, 1, arguments, false, exception); + } + if (CYInternal *internal = CYInternal::Set(self)) { internal->SetProperty(context, property, value); return true; diff --git a/makefile b/makefile index 4fbd67d..a1739a5 100644 --- a/makefile +++ b/makefile @@ -9,12 +9,13 @@ flags += -F${PKG_ROOT}/System/Library/PrivateFrameworks svn := $(shell svnversion) deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_iphoneos-arm.deb +all := cycript libcycript.dylib libcycript.plist header := Cycript.tab.hh Parser.hpp Pooling.hpp Struct.hpp cycript.hpp $(deb): -all: cycript libcycript.dylib libcycript.plist +all: $(all) clean: rm -f *.o libcycript.dylib cycript libcycript.plist Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh @@ -74,7 +75,7 @@ cycript: Application.o libcycript.dylib -framework JavaScriptCore -framework UIKit ldid -S cycript -$(deb): all +$(deb): $(all) rm -rf package mkdir -p package/DEBIAN sed -e 's/#/$(svn)/' control >package/DEBIAN/control