From d8704ce45722442cb7eb741e49a6dca230a5ac47 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 19 Dec 2015 06:29:16 -0800 Subject: [PATCH] Include type in toCYON for opaque Pointer address. --- Execute.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Execute.cpp b/Execute.cpp index db347d9..1f40626 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1515,9 +1515,24 @@ static JSValueRef Pointer_callAsFunction_toCYON(JSContextRef context, JSObjectRe JSObjectRef toCYON(CYCastJSObject(context, CYGetProperty(context, Array, toCYON_s))); return CYCallAsFunction(context, toCYON, _this, count, arguments); } else if (internal->type_->type_ == NULL) pointer: { - char string[32]; - sprintf(string, "%p", internal->value_); - return CYCastJSValue(context, string); + CYLocalPool pool; + std::ostringstream str; + + sig::Type type; + type.name = NULL; + type.flags = 0; + + type.primitive = sig::pointer_P; + type.data.data.type = internal->type_->type_; + type.data.data.size = 0; + + CYOptions options; + CYOutput output(*str.rdbuf(), options); + (new(pool) CYTypeExpression(Decode(pool, &type)))->Output(output, CYNoFlags); + + str << "(" << internal->value_ << ")"; + std::string value(str.str()); + return CYCastJSValue(context, CYJSString(CYUTF8String(value.c_str(), value.size()))); } else try { JSValueRef value(CYGetProperty(context, _this, cyi_s)); if (JSValueIsUndefined(context, value)) -- 2.47.2