X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/6419a40fb7c8e1c92e2bb7a6691f071fbfa76e77..7e7f901067152dfaf6c9617e28c36a9b10a6d1cf:/Internal.hpp diff --git a/Internal.hpp b/Internal.hpp index 4e37d7a..7e6b1fd 100644 --- a/Internal.hpp +++ b/Internal.hpp @@ -42,6 +42,12 @@ sig::Type *Structor_(CYPool &pool, sig::Aggregate *aggregate); struct CYRoot : CYData { + // XXX: without this, CYData is zero-initialized?! + CYRoot() : + CYData() + { + } + _finline JSValueRef GetPrototype(JSContextRef context) const { return NULL; } @@ -198,6 +204,33 @@ struct CYProtect { } }; +class CYBuffer { + private: + JSObjectRef owner_; + CYPool *pool_; + + public: + CYBuffer(JSContextRef context) : + owner_(CYPrivate::Make(context)), + pool_(CYPrivate::Get(context, owner_)->pool_) + { + auto internal(CYPrivate::Get(context, owner_)); + internal->pool_->malloc(10); + } + + operator JSObjectRef() const { + return owner_; + } + + operator CYPool *() const { + return pool_; + } + + CYPool *operator ->() const { + return pool_; + } +}; + namespace cy { struct Functor : CYRoot