Example #1
0
JSBool JavaObject::setPropertyWrapper(JSContext* ctx, JSHandleObject obj,
    JSHandleId id, JSBool strict, jsval *vp) {
#if GECKO_VERSION >= 16000
  return setProperty(ctx, obj.get(), id.get(), strict, vp);
#else
  return setProperty(ctx, obj.value(), id.value(), strict, vp);
#endif
}
Example #2
0
bool
JSStructuredCloneWriter::writeArrayBuffer(JSHandleObject obj)
{
    ArrayBufferObject &buffer = obj->asArrayBuffer();
    return out.writePair(SCTAG_ARRAY_BUFFER_OBJECT, buffer.byteLength()) &&
           out.writeBytes(buffer.dataPointer(), buffer.byteLength());
}
Example #3
0
JSBool JavaObject::getPropertyWrapper(JSContext* ctx, JSHandleObject obj,
    JSHandleId id, JSMutableHandleValue vp) {
  jsval rval;
  JSBool result = JavaObject::getProperty(ctx, obj.get(), id.get(), &rval);
  vp.set(rval);
  return result;
}
CEXPORT JSBool def_timestep_image_map_set_width(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_image_map *thiz = (timestep_image_map*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		thiz->width = vp.toInt32();
		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
CEXPORT JSBool def_timestep_image_map_get_marginLeft(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_image_map *thiz = (timestep_image_map*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		vp.setInt32(thiz->margin_left);
		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
CEXPORT JSBool def_timestep_view_get_offsetX(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_view *thiz = (timestep_view*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		vp.setNumber(thiz->offset_x);
		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
CEXPORT JSBool def_timestep_view_set_y(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_view *thiz = (timestep_view*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		thiz->y = vp.toNumber();
		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
CEXPORT JSBool def_timestep_view_get_filterType(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_view *thiz = (timestep_view*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		vp.setInt32(thiz->filter_type);
		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
CEXPORT JSBool def_timestep_image_map_get_url(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_image_map *thiz = (timestep_image_map*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		vp.setString(JS_NewStringCopyZ(cx, thiz->url));

		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
CEXPORT JSBool def_timestep_view_get___firstRender(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_view *thiz = (timestep_view*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		vp.setBoolean(thiz->__first_render);

		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
Example #11
0
static JSBool js_cocos2dx_extension_WebSocket_get_readyState(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp)
{
    JSObject* jsobj = obj.get();
	js_proxy_t *proxy = jsb_get_js_proxy(jsobj);
	WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL);
	JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
    
    if (cobj) {
        vp.set(INT_TO_JSVAL((int)cobj->getReadyState()));
        return JS_TRUE;
    } else {
        JS_ReportError(cx, "Error: WebSocket instance is invalid.");
        return JS_FALSE;
    }
}
CEXPORT JSBool def_timestep_view_get_filterColor(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_view *thiz = (timestep_view*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		rgba prop = thiz->filter_color;

char buf[64];
int len = rgba_to_string(&prop, buf);

vp.setString(JS_NewStringCopyN(cx, buf, len));

		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
CEXPORT JSBool def_timestep_view_set_filterColor(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_view *thiz = (timestep_view*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		if (vp.isString()) {
	JSString *jstr = vp.toString();

	JSTR_TO_CSTR(cx, jstr, cstr);

	rgba color;
	rgba_parse(&color, cstr);
	thiz->filter_color = color;
}

		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
Example #14
0
JSBool
document_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags, JSObject **objp)
{
    // If id is "all", and we're not detecting, resolve document.all=true.
    jsvalRoot v(cx);
    if (!JS_IdToValue(cx, id, v.addr()))
        return false;
    if (JSVAL_IS_STRING(v.value())) {
        JSString *str = JSVAL_TO_STRING(v.value());
        JSFlatString *flatStr = JS_FlattenString(cx, str);
        if (!flatStr)
            return false;
        if (JS_FlatStringEqualsAscii(flatStr, "all") && !(flags & JSRESOLVE_DETECTING)) {
            JSBool ok = JS_DefinePropertyById(cx, obj, id, JSVAL_TRUE, NULL, NULL, 0);
            *objp = ok ? obj.value() : NULL;
            return ok;
        }
    }
    *objp = NULL;
    return true;
}
CEXPORT JSBool def_timestep_image_map_set_url(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, JSMutableHandleValue vp) {
	JS_BeginRequest(cx);
	timestep_image_map *thiz = (timestep_image_map*)JS_GetPrivate(obj.get());
	if (thiz) {
		
		if (vp.isString()) {
	JSString *jstr = vp.toString();

	JSTR_TO_CSTR_PERSIST(cx, jstr, cstr);

	if (thiz->url) {
		free(thiz->url);
	}

	thiz->url = cstr;
}

		
	}
	JS_EndRequest(cx);
	return JS_TRUE;
}
Example #16
0
bool
JSStructuredCloneWriter::traverseObject(JSHandleObject obj)
{
    /*
     * Get enumerable property ids and put them in reverse order so that they
     * will come off the stack in forward order.
     */
    size_t initialLength = ids.length();
    if (!GetPropertyNames(context(), obj, JSITER_OWNONLY, &ids))
        return false;
    jsid *begin = ids.begin() + initialLength, *end = ids.end();
    size_t count = size_t(end - begin);
    Reverse(begin, end);

    /* Push obj and count to the stack. */
    if (!objs.append(ObjectValue(*obj)) || !counts.append(count))
        return false;
    checkStack();

    /* Write the header for obj. */
    return out.writePair(obj->isArray() ? SCTAG_ARRAY_OBJECT : SCTAG_OBJECT_OBJECT, 0);
}