]> git.saurik.com Git - cycript.git/blobdiff - sig/types.hpp
Do not use corrupt struct to store type reference.
[cycript.git] / sig / types.hpp
index f0530466c8a01d5c4e364cc36bdfb286a282daf7..2f536ac53a910bd6935763d505c9de1ecf1551b5 100644 (file)
@@ -1,5 +1,5 @@
-/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2015  Jay Freeman (saurik)
+/* Cycript - The Truly Universal Scripting Language
+ * Copyright (C) 2009-2016  Jay Freeman (saurik)
 */
 
 /* GNU Affero General Public License, Version 3 {{{ */
@@ -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;
@@ -134,10 +134,11 @@ struct String :
     JSValueRef FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const override;
 };
 
+#ifdef CY_OBJECTIVEC
 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 +151,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;
@@ -159,6 +160,7 @@ struct Selector :
     void PoolFFI(CYPool *pool, JSContextRef context, ffi_type *ffi, void *data, JSValueRef value) const override;
     JSValueRef FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const override;
 };
+#endif
 
 struct Bits :
     Type
@@ -170,7 +172,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 +192,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 +214,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;
@@ -222,6 +224,7 @@ struct Array :
     JSValueRef FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const override;
 };
 
+#ifdef CY_OBJECTIVEC
 struct Object :
     Type
 {
@@ -232,7 +235,40 @@ struct Object :
     {
     }
 
-    Object *Copy(CYPool &pool, const char *name = NULL) 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;
+
+    ffi_type *GetFFI(CYPool &pool) const override;
+    void PoolFFI(CYPool *pool, JSContextRef context, ffi_type *ffi, void *data, JSValueRef value) const override;
+    JSValueRef FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const override;
+};
+#endif
+
+struct Constant {
+    const char *name;
+    double value;
+};
+
+struct Enum :
+    Type
+{
+    Type &type;
+    unsigned count;
+    const char *name;
+
+    Constant *constants;
+
+    Enum(Type &type, unsigned count, const char *name = NULL) :
+        type(type),
+        count(count),
+        name(name),
+        constants(NULL)
+    {
+    }
+
+    Enum *Copy(CYPool &pool, const char *rename = NULL) const override;
     const char *GetName() const override;
 
     const char *Encode(CYPool &pool) const override;
@@ -256,7 +292,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 +322,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;
@@ -296,10 +332,11 @@ struct Function :
     JSValueRef FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const override;
 };
 
+#ifdef CY_OBJECTIVEC
 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;
@@ -309,6 +346,7 @@ struct Block :
     void PoolFFI(CYPool *pool, JSContextRef context, ffi_type *ffi, void *data, JSValueRef value) const override;
     JSValueRef FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const override;
 };
+#endif
 
 Type *joc_parse_type(char **name, char eos, bool variable, bool signature);
 void joc_parse_signature(Signature *signature, char **name, char eos, bool variable);