X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/8effd3814c3f69bc2628345eef1accd89e936ddc..284f434e679db9480ba276b2e98d3fe5aeffa23b:/ObjectiveC/Internal.hpp?ds=sidebyside diff --git a/ObjectiveC/Internal.hpp b/ObjectiveC/Internal.hpp index 759c875..fcfec70 100644 --- a/ObjectiveC/Internal.hpp +++ b/ObjectiveC/Internal.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 {{{ */ @@ -27,23 +27,25 @@ #include "../Internal.hpp" struct Selector_privateData : - CYValue + CYRoot { + SEL value_; + _finline Selector_privateData(SEL value) : - CYValue(value) + value_(value) { } }; struct Instance : - CYValue + CYPrivateOld { - enum Flags { - None = 0, - Permanent = (1 << 0), - Uninitialized = (1 << 1), - }; + typedef unsigned Flags; + static const Flags None = 0; + static const Flags Permanent = 1 << 0; + static const Flags Uninitialized = 1 << 1; + id value_; Flags flags_; Instance(id value, Flags flags); @@ -53,6 +55,10 @@ struct Instance : static JSClassRef GetClass(id value, Flags flags); + _finline bool IsPermanent() const { + return (flags_ & Permanent) != 0; + } + _finline bool IsUninitialized() const { return (flags_ & Uninitialized) != 0; } @@ -60,35 +66,70 @@ struct Instance : namespace cy { struct Super : - CYValue + CYRoot { + id value_; Class class_; _finline Super(id value, Class _class) : - CYValue(value), + value_(value), class_(_class) { } }; } struct Messages : - CYValue + CYRoot +{ + virtual Class GetClass() const = 0; +}; + +struct Prototype : + Messages { - _finline Messages(Class value) : - CYValue(value) + static constexpr const char *const Cache_ = "p"; + + Class value_; + + _finline Prototype(Class value) : + value_(value) { } + Class GetClass() const override { + return value_; + } + + JSValueRef GetPrototype(JSContextRef context) const; +}; + +struct Constructor : + Messages +{ + static constexpr const char *const Cache_ = "m"; + + Class value_; + + _finline Constructor(Class value) : + value_(value) + { + } + + Class GetClass() const override { + return value_; + } + JSValueRef GetPrototype(JSContextRef context) const; }; struct Interior : - CYValue + CYRoot { + id value_; CYProtect owner_; _finline Interior(id value, JSContextRef context, JSObjectRef owner) : - CYValue(value), + value_(value), owner_(context, owner) { }