Ejemplo n.º 1
0
static bool _js_set_SIOClient_tag(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp)
{
     CCLOG("JSB SocketIO.setTag method called");
    JSObject* jsobj = obj.get();
    js_proxy_t *proxy = jsb_get_js_proxy(jsobj);
    SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL);
    JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
    
    if (cobj) {
        std::string out = "";

        jsval_to_std_string(cx, vp, &out);
        cobj->setTag(out.c_str());
        return true;
    } else {
        JS_ReportError(cx, "Error: SocketIO instance is invalid.");
        return false;
    }

}
static bool _js_set_SIOClient_tag(JSContext* cx, uint32_t argc, jsval* vp)
{
    CCLOG("JSB SocketIO.setTag method called");
    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    JSObject* jsobj = args.thisv().toObjectOrNull();
    js_proxy_t *proxy = jsb_get_js_proxy(jsobj);
    SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL);
    JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object");
    
    if (cobj)
    {
        std::string out = "";

        jsval_to_std_string(cx, args.get(0), &out);
        cobj->setTag(out.c_str());
        return true;
    } else
    {
        JS_ReportError(cx, "Error: SocketIO instance is invalid.");
        return false;
    }
}