From: Jay Freeman (saurik) Date: Sun, 11 Oct 2009 05:12:10 +0000 (+0000) Subject: Implemented pointer indirect assignment. X-Git-Tag: v0.9.432~356 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/f37b3d2be92677eaab8c60e7b2ede0edc429f3c5?ds=sidebyside Implemented pointer indirect assignment. --- diff --git a/Library.mm b/Library.mm index f2ba5fc..db7a184 100644 --- a/Library.mm +++ b/Library.mm @@ -1663,6 +1663,26 @@ static JSValueRef Pointer_getProperty(JSContextRef context, JSObjectRef object, } CYCatch } +static bool Pointer_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { + CYPool pool; + Pointer *internal(reinterpret_cast(JSObjectGetPrivate(object))); + Type_privateData *typical(internal->type_); + + ssize_t index; + if (!CYGetIndex(pool, property, index)) + return NULL; + + ffi_type *ffi(typical->GetFFI()); + + uint8_t *base(reinterpret_cast(internal->value_)); + base += ffi->size * index; + + CYTry { + CYPoolFFI(NULL, context, &typical->type_, ffi, base, value); + return true; + } CYCatch +} + static JSValueRef Struct_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYPool pool; Struct_privateData *internal(reinterpret_cast(JSObjectGetPrivate(object))); @@ -2132,6 +2152,7 @@ MSInitialize { _pooled definition.className = "Pointer"; definition.staticFunctions = Pointer_staticFunctions; definition.getProperty = &Pointer_getProperty; + definition.setProperty = &Pointer_setProperty; definition.finalize = &CYData::Finalize; Pointer_ = JSClassCreate(&definition);