]> git.saurik.com Git - cycript.git/blobdiff - Execute.cpp
Use a single std::istream& to replace file_/data_.
[cycript.git] / Execute.cpp
index ab1b1d61928b888ec998c75397199460545282e0..f8b70e54bbfec764a32420611cf26b2e5b6e8b5b 100644 (file)
@@ -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<Type_privateData *>(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<Type_privateData *>(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<Type_privateData *>(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},
@@ -1311,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;