]> git.saurik.com Git - cycript.git/commitdiff
Show more explicit types for Objective-C Instance.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 30 Dec 2015 14:11:17 +0000 (06:11 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 30 Dec 2015 14:11:17 +0000 (06:11 -0800)
ObjectiveC/Library.mm
sig/copy.cpp
sig/types.hpp

index b3dcc0ae6fda6e724658a34350796a15649b3264..a2a3190d3b59b301cd93aaab92fdd1769cab1816 100644 (file)
@@ -2545,7 +2545,11 @@ static JSValueRef Selector_getProperty_$cyt(JSContextRef context, JSObjectRef ob
 } CYCatch(NULL) }
 
 static JSValueRef Instance_getProperty_$cyt(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
-    return CYMakeType(context, sig::Object());
+    Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(object)));
+    id self(internal->GetValue());
+    if (CYIsClass(self))
+        return CYMakeType(context, sig::Meta());
+    return CYMakeType(context, sig::Object(class_getName(object_getClass(self))));
 } CYCatch(NULL) }
 
 static JSValueRef FunctionInstance_getProperty_$cyt(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
@@ -2557,10 +2561,6 @@ static JSValueRef FunctionInstance_getProperty_$cyt(JSContextRef context, JSObje
     return CYMakeType(context, type);
 } CYCatch(NULL) }
 
-static JSValueRef Class_getProperty_$cyt(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
-    return CYMakeType(context, sig::Meta());
-} CYCatch(NULL) }
-
 static JSValueRef Instance_getProperty_constructor(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
     Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(object)));
     return CYMakeInstance(context, object_getClass(internal->GetValue()), Instance::Permanent);
@@ -2745,11 +2745,6 @@ static JSStaticFunction Class_staticFunctions[2] = {
     {NULL, NULL, 0}
 };
 
-static JSStaticValue Class_staticValues[2] = {
-    {"$cyt", &Class_getProperty_$cyt, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
-    {NULL, NULL, NULL, 0}
-};
-
 static JSStaticFunction Internal_staticFunctions[2] = {
     {"$cya", &Internal_callAsFunction_$cya, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
     {NULL, NULL, 0}
@@ -2837,7 +2832,6 @@ void CYObjectiveC_Initialize() { /*XXX*/ JSContextRef context(NULL); CYPoolTry {
     definition = kJSClassDefinitionEmpty;
     definition.className = "Class";
     definition.staticFunctions = Class_staticFunctions;
-    definition.staticValues = Class_staticValues;
     Class_ = JSClassCreate(&definition);
 
     definition = kJSClassDefinitionEmpty;
index 4fb98bdd1ce056f50168411eb0c171b4c965a2b4..d00a869c06725317cf8d7e9c405a2442adf36152 100644 (file)
@@ -45,58 +45,55 @@ void Copy(CYPool &pool, Signature &lhs, const Signature &rhs) {
         Copy(pool, lhs.elements[index], rhs.elements[index]);
 }
 
-Void *Void::Copy(CYPool &pool, const char *name) const {
+Void *Void::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Void();
 }
 
-Unknown *Unknown::Copy(CYPool &pool, const char *name) const {
+Unknown *Unknown::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Unknown();
 }
 
-String *String::Copy(CYPool &pool, const char *name) const {
+String *String::Copy(CYPool &pool, const char *rename) const {
     return new(pool) String();
 }
 
-Meta *Meta::Copy(CYPool &pool, const char *name) const {
+Meta *Meta::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Meta();
 }
 
-Selector *Selector::Copy(CYPool &pool, const char *name) const {
+Selector *Selector::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Selector();
 }
 
-Bits *Bits::Copy(CYPool &pool, const char *name) const {
+Bits *Bits::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Bits(size);
 }
 
-Pointer *Pointer::Copy(CYPool &pool, const char *name) const {
+Pointer *Pointer::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Pointer(*type.Copy(pool));
 }
 
-Array *Array::Copy(CYPool &pool, const char *name) const {
+Array *Array::Copy(CYPool &pool, const char *rename) const {
     return new(pool) Array(*type.Copy(pool), size);
 }
 
-Object *Object::Copy(CYPool &pool, const char *name) const {
-    Object *copy(new(pool) Object(pool.strdup(name)));
-    copy->name = name;
-    return copy;
+Object *Object::Copy(CYPool &pool, const char *rename) const {
+    return new(pool) Object(pool.strdup(name));
 }
 
-Aggregate *Aggregate::Copy(CYPool &pool, const char *name) const {
-    Aggregate *copy(new(pool) Aggregate(overlap, name));
+Aggregate *Aggregate::Copy(CYPool &pool, const char *rename) const {
+    Aggregate *copy(new(pool) Aggregate(overlap, rename ?: pool.strdup(name)));
     sig::Copy(pool, copy->signature, signature);
-    copy->name = name;
     return copy;
 }
 
-Function *Function::Copy(CYPool &pool, const char *name) const {
+Function *Function::Copy(CYPool &pool, const char *rename) const {
     Function *copy(new(pool) Function(variadic));
     sig::Copy(pool, copy->signature, signature);
     return copy;
 }
 
-Block *Block::Copy(CYPool &pool, const char *name) const {
+Block *Block::Copy(CYPool &pool, const char *rename) const {
     Block *copy(new(pool) Block());
     sig::Copy(pool, copy->signature, signature);
     return copy;
@@ -129,10 +126,6 @@ const char *Type::GetName() const {
     return NULL;
 }
 
-const char *Object::GetName() const {
-    return name;
-}
-
 const char *Aggregate::GetName() const {
     return name;
 }
index f0530466c8a01d5c4e364cc36bdfb286a282daf7..82ee41e09e53b1de8c54b4b90a59a60f4492c815 100644 (file)
@@ -57,7 +57,7 @@ struct Type {
     {
     }
 
-    virtual Type *Copy(CYPool &pool, const char *name = NULL) const = 0;
+    virtual Type *Copy(CYPool &pool, const char *rename = NULL) const = 0;
     virtual const char *GetName() const;
 
     virtual const char *Encode(CYPool &pool) const = 0;
@@ -98,7 +98,7 @@ struct Signature {
 struct Void :
     Type
 {
-    Void *Copy(CYPool &pool, const char *name = NULL) const override;
+    Void *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;
@@ -111,7 +111,7 @@ struct Void :
 struct Unknown :
     Type
 {
-    Unknown *Copy(CYPool &pool, const char *name = NULL) const override;
+    Unknown *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;
@@ -124,7 +124,7 @@ struct Unknown :
 struct String :
     Type
 {
-    String *Copy(CYPool &pool, const char *name = NULL) const override;
+    String *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;
@@ -137,7 +137,7 @@ struct String :
 struct Meta :
     Type
 {
-    Meta *Copy(CYPool &pool, const char *name = NULL) const override;
+    Meta *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;
@@ -150,7 +150,7 @@ struct Meta :
 struct Selector :
     Type
 {
-    Selector *Copy(CYPool &pool, const char *name = NULL) const override;
+    Selector *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;
@@ -170,7 +170,7 @@ struct Bits :
     {
     }
 
-    Bits *Copy(CYPool &pool, const char *name = NULL) const override;
+    Bits *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;
@@ -190,7 +190,7 @@ struct Pointer :
     {
     }
 
-    Pointer *Copy(CYPool &pool, const char *name = NULL) const override;
+    Pointer *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;
@@ -212,7 +212,7 @@ struct Array :
     {
     }
 
-    Array *Copy(CYPool &pool, const char *name = NULL) const override;
+    Array *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;
@@ -232,8 +232,7 @@ struct Object :
     {
     }
 
-    Object *Copy(CYPool &pool, const char *name = NULL) const override;
-    const char *GetName() const override;
+    Object *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;
@@ -256,7 +255,7 @@ struct Aggregate :
     {
     }
 
-    Aggregate *Copy(CYPool &pool, const char *name = NULL) const override;
+    Aggregate *Copy(CYPool &pool, const char *rename = NULL) const override;
     const char *GetName() const override;
 
     const char *Encode(CYPool &pool) const override;
@@ -286,7 +285,7 @@ struct Function :
     {
     }
 
-    Function *Copy(CYPool &pool, const char *name = NULL) const override;
+    Function *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Modify(CYPool &pool, CYTypedIdentifier *result, CYTypedParameter *parameters) const override;
@@ -299,7 +298,7 @@ struct Function :
 struct Block :
     Callable
 {
-    Block *Copy(CYPool &pool, const char *name = NULL) const override;
+    Block *Copy(CYPool &pool, const char *rename = NULL) const override;
 
     const char *Encode(CYPool &pool) const override;
     CYTypedIdentifier *Decode(CYPool &pool) const override;