From 284f434e679db9480ba276b2e98d3fe5aeffa23b Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 9 Jan 2016 09:48:37 -0800 Subject: [PATCH] Maintain a logical setup for const on sig::String. --- Execute.cpp | 6 +++--- sig/types.hpp | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Execute.cpp b/Execute.cpp index 6ded65e..3f00a87 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1678,7 +1678,7 @@ static JSValueRef Type_callAsFunction_pointerTo(JSContextRef context, JSObjectRe Type_privateData *internal(reinterpret_cast(JSObjectGetPrivate(_this))); if (dynamic_cast *>(internal->type_) != NULL) - return CYMakeType(context, sig::String()); + return CYMakeType(context, sig::String((internal->type_->flags & JOC_TYPE_CONST) != 0)); else return CYMakeType(context, sig::Pointer(*internal->type_)); } CYCatch(NULL) } @@ -1860,7 +1860,7 @@ static JSValueRef CString_getProperty_length(JSContextRef context, JSObjectRef o } CYCatch(NULL) } static JSValueRef CString_getProperty_$cyt(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry { - return CYMakeType(context, sig::String()); + return CYMakeType(context, sig::String(true)); } CYCatch(NULL) } static JSValueRef CArray_getProperty_$cyt(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry { @@ -2545,7 +2545,7 @@ extern "C" void CYSetupContext(JSGlobalContextRef context) { } #endif - CYSetProperty(context, String_prototype, cyt_s, CYMakeType(context, sig::String()), kJSPropertyAttributeDontEnum); + CYSetProperty(context, String_prototype, cyt_s, CYMakeType(context, sig::String(true)), kJSPropertyAttributeDontEnum); CYSetProperty(context, cache, CYJSString("dlerror"), CYMakeFunctor(context, "dlerror", "*"), kJSPropertyAttributeDontEnum); CYSetProperty(context, cache, CYJSString("RTLD_DEFAULT"), CYCastJSValue(context, reinterpret_cast(RTLD_DEFAULT)), kJSPropertyAttributeDontEnum); diff --git a/sig/types.hpp b/sig/types.hpp index e98147c..30d8dbd 100644 --- a/sig/types.hpp +++ b/sig/types.hpp @@ -130,6 +130,14 @@ struct Unknown : struct String : Type { + String() { + } + + String(bool constant) { + if (constant) + flags |= JOC_TYPE_CONST; + } + String *Copy(CYPool &pool, const char *rename = NULL) const override; const char *Encode(CYPool &pool) const override; -- 2.45.2