X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/0559abf83c4cc9bbd896b69dfaae1e8422521479..11bc0b9e5dc0120f007ed9b2bfc7810e8a2b0162:/sig/types.hpp diff --git a/sig/types.hpp b/sig/types.hpp index d437475..ea0a307 100644 --- a/sig/types.hpp +++ b/sig/types.hpp @@ -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 {{{ */ @@ -37,6 +37,7 @@ class CYPool; struct CYTypedIdentifier; +struct CYTypedParameter; namespace sig { @@ -56,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; @@ -65,10 +66,6 @@ struct Type { virtual ffi_type *GetFFI(CYPool &pool) const = 0; virtual void PoolFFI(CYPool *pool, JSContextRef context, ffi_type *ffi, void *data, JSValueRef value) const = 0; virtual JSValueRef FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize = false, JSObjectRef owner = NULL) const = 0; - - virtual size_t Translate(Type *&type) const { - return _not(size_t); - } }; template @@ -101,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; @@ -114,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; @@ -127,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,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; @@ -153,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; @@ -162,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 @@ -173,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; @@ -193,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; @@ -215,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; @@ -223,13 +222,9 @@ struct Array : 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; - - size_t Translate(Type *&type) const override { - type = &this->type; - return size; - } }; +#ifdef CY_OBJECTIVEC struct Object : Type { @@ -240,8 +235,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; @@ -250,6 +244,7 @@ struct Object : 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 Aggregate : Type @@ -264,7 +259,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; @@ -279,33 +274,46 @@ struct Callable : Type { Signature signature; + + CYTypedIdentifier *Decode(CYPool &pool) const override; + virtual CYTypedIdentifier *Modify(CYPool &pool, CYTypedIdentifier *result, CYTypedParameter *parameters) const = 0; }; struct Function : Callable { - Function *Copy(CYPool &pool, const char *name = NULL) const override; + bool variadic; + + Function(bool variadic) : + variadic(variadic) + { + } + + Function *Copy(CYPool &pool, const char *rename = NULL) const override; const char *Encode(CYPool &pool) const override; - CYTypedIdentifier *Decode(CYPool &pool) const override; + CYTypedIdentifier *Modify(CYPool &pool, CYTypedIdentifier *result, CYTypedParameter *parameters) 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; }; +#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; + CYTypedIdentifier *Modify(CYPool &pool, CYTypedIdentifier *result, CYTypedParameter *parameters) 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 Type *joc_parse_type(char **name, char eos, bool variable, bool signature); void joc_parse_signature(Signature *signature, char **name, char eos, bool variable);