X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/b799113bd4ec270504dd9f552142c1adfd6e583a..ca52e3a3a95947a04788d3fce01d8d856e5f1544:/Internal.hpp?ds=sidebyside diff --git a/Internal.hpp b/Internal.hpp index f7ad60d..b4dd4a1 100644 --- a/Internal.hpp +++ b/Internal.hpp @@ -161,14 +161,27 @@ namespace cy { struct Functor : CYValue { + private: + void set() { + sig::sig_ffi_cif(*pool_, &sig::ObjectiveC, &signature_, &cif_); + } + + public: sig::Signature signature_; ffi_cif cif_; - Functor(const char *type, void (*value)()) : + Functor(const sig::Signature &signature, void (*value)()) : CYValue(reinterpret_cast(value)) { - sig::Parse(*pool_, &signature_, type, &Structor_); - sig::sig_ffi_cif(*pool_, &sig::ObjectiveC, &signature_, &cif_); + sig::Copy(*pool_, signature_, signature); + set(); + } + + Functor(const char *encoding, void (*value)()) : + CYValue(reinterpret_cast(value)) + { + sig::Parse(*pool_, &signature_, encoding, &Structor_); + set(); } void (*GetValue() const)() { @@ -184,8 +197,8 @@ struct Closure_privateData : JSGlobalContextRef context_; JSObjectRef function_; - Closure_privateData(JSContextRef context, JSObjectRef function, const char *type) : - cy::Functor(type, NULL), + Closure_privateData(JSContextRef context, JSObjectRef function, const sig::Signature &signature) : + cy::Functor(signature, NULL), context_(CYGetJSContext(context)), function_(function) { @@ -199,7 +212,7 @@ struct Closure_privateData : } }; -Closure_privateData *CYMakeFunctor_(JSContextRef context, JSObjectRef function, const char *type, void (*callback)(ffi_cif *, void *, void **, void *)); +Closure_privateData *CYMakeFunctor_(JSContextRef context, JSObjectRef function, const sig::Signature &signature, void (*callback)(ffi_cif *, void *, void **, void *)); void CYExecuteClosure(ffi_cif *cif, void *result, void **arguments, void *arg, JSValueRef (*adapter)(JSContextRef, size_t, JSValueRef[], JSObjectRef)); #endif/*CYCRIPT_INTERNAL_HPP*/