X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/26ef7a82c9367b813682af1bea19e8e788efed64..2e2ed904884fa1dc0a0670364d44cdc3dc9a0775:/Execute.cpp diff --git a/Execute.cpp b/Execute.cpp index 7eb2f80..f8b70e5 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1,5 +1,5 @@ /* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2010 Jay Freeman (saurik) + * Copyright (C) 2009-2012 Jay Freeman (saurik) */ /* GNU Lesser General Public License, Version 3 {{{ */ @@ -1019,7 +1019,7 @@ static void All_getPropertyNames(JSContextRef context, JSObjectRef object, JSPro static JSObjectRef Pointer_new(JSContextRef context, JSObjectRef object, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { if (count != 2) - throw CYJSError(context, "incorrect number of arguments to Functor constructor"); + throw CYJSError(context, "incorrect number of arguments to Pointer constructor"); CYPool pool; @@ -1135,6 +1135,16 @@ static JSValueRef Pointer_callAsFunction_toCYON(JSContextRef context, JSObjectRe } } CYCatch } +static JSValueRef Type_getProperty_alignment(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { + Type_privateData *internal(reinterpret_cast(JSObjectGetPrivate(object))); + return CYCastJSValue(context, internal->GetFFI()->alignment); +} + +static JSValueRef Type_getProperty_size(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { + Type_privateData *internal(reinterpret_cast(JSObjectGetPrivate(object))); + return CYCastJSValue(context, internal->GetFFI()->size); +} + static JSValueRef Type_callAsFunction_toString(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { Type_privateData *internal(reinterpret_cast(JSObjectGetPrivate(_this))); CYPool pool; @@ -1183,6 +1193,12 @@ namespace cy { JSStaticFunction const * const Functor::StaticFunctions = Functor_staticFunctions; } +static JSStaticValue Type_staticValues[3] = { + {"alignment", &Type_getProperty_alignment, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, + {"size", &Type_getProperty_size, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, + {NULL, NULL, NULL, 0} +}; + static JSStaticFunction Type_staticFunctions[4] = { {"toCYON", &Type_callAsFunction_toCYON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {"toJSON", &Type_callAsFunction_toJSON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, @@ -1235,10 +1251,8 @@ const char *CYExecute(apr_pool_t *pool, CYUTF8String code) { return error; } - if (exception != NULL) { error: - result = CYCastJSValue(context, CYJSString(context, exception)); - exception = NULL; - } + if (exception != NULL) error: + return CYPoolCString(pool, context, CYJSString(context, exception)); if (JSValueIsUndefined(context, result)) return NULL; @@ -1313,6 +1327,7 @@ void CYInitializeDynamic() { definition = kJSClassDefinitionEmpty; definition.className = "Type"; + definition.staticValues = Type_staticValues; definition.staticFunctions = Type_staticFunctions; definition.getProperty = &Type_getProperty; definition.callAsFunction = &Type_callAsFunction;