X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/dbf05bfd2ab79568fe706daa9112037192d4d9dd..1fe330114b9b59b11dea95b8f941f478eae8f020:/JavaScript.hpp diff --git a/JavaScript.hpp b/JavaScript.hpp index 7a4d8a4..3265b2e 100644 --- a/JavaScript.hpp +++ b/JavaScript.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 {{{ */ @@ -39,11 +39,14 @@ #include "Pooling.hpp" #include "String.hpp" +#include "Utility.hpp" extern JSStringRef Array_s; +extern JSStringRef constructor_s; extern JSStringRef cy_s; extern JSStringRef cyi_s; extern JSStringRef cyt_s; +extern JSStringRef cyt__s; extern JSStringRef length_s; extern JSStringRef message_s; extern JSStringRef name_s; @@ -63,9 +66,12 @@ JSObjectRef CYGetGlobalObject(JSContextRef context); extern "C" void CYSetupContext(JSGlobalContextRef context); const char *CYExecute(JSContextRef context, CYPool &pool, CYUTF8String code); + +#ifndef __ANDROID__ void CYCancel(); +#endif -void CYSetArgs(int argc, const char *argv[]); +void CYSetArgs(const char *argv0, const char *script, int argc, const char *argv[]); bool CYCastBool(JSContextRef context, JSValueRef value); double CYCastDouble(JSContextRef context, JSValueRef value); @@ -110,6 +116,13 @@ JSObjectRef CYCastJSObject(JSContextRef context, JSValueRef value); JSValueRef CYJSUndefined(JSContextRef context); JSValueRef CYJSNull(JSContextRef context); +void *CYCastPointerEx_(JSContextRef context, JSObjectRef value); + +template +_finline Type_ CYCastPointerEx(JSContextRef context, JSObjectRef value) { + return reinterpret_cast(CYCastPointerEx_(context, value)); +} + void *CYCastPointer_(JSContextRef context, JSValueRef value, bool *guess = NULL); template @@ -156,6 +169,8 @@ JSValueRef CYArrayGet(JSContextRef context, JSObjectRef array, size_t index); void CYArrayPush(JSContextRef context, JSObjectRef array, size_t length, const JSValueRef arguments[]); void CYArrayPush(JSContextRef context, JSObjectRef array, JSValueRef value); +bool CYGetOffset(CYPool &pool, JSContextRef context, JSStringRef value, ssize_t &index); + const char *CYPoolCString(CYPool &pool, JSContextRef context, JSValueRef value); JSStringRef CYCopyJSString(const char *value); @@ -178,20 +193,19 @@ class CYJSString { } public: - CYJSString(const CYJSString &rhs) : - string_(CYCopyJSString(rhs.string_)) + CYJSString() : + string_(NULL) { } - template - CYJSString(Arg0_ arg0) : - string_(CYCopyJSString(arg0)) + CYJSString(const CYJSString &rhs) : + string_(CYCopyJSString(rhs.string_)) { } - template - CYJSString(Arg0_ arg0, Arg1_ arg1) : - string_(CYCopyJSString(arg0, arg1)) + template + CYJSString(Args_ &&... args) : + string_(CYCopyJSString(cy::Forward(args)...)) { } @@ -201,6 +215,11 @@ class CYJSString { return *this; } + CYJSString &operator =(CYJSString &&rhs) { + std::swap(string_, rhs.string_); + return *this; + } + ~CYJSString() { Clear_(); }