From f37b3d2be92677eaab8c60e7b2ede0edc429f3c5 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 11 Oct 2009 05:12:10 +0000 Subject: [PATCH] Implemented pointer indirect assignment. --- Library.mm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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); -- 2.45.2