MCPcopy Create free account
hub / github.com/9miao/CrossApp / c_string_to_jsval

Function c_string_to_jsval

scripting/javascript/bindings/ScriptingCore.cpp:1593–1609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1591}
1592
1593jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length /* = -1 */) {
1594 if (v == NULL) {
1595 return JSVAL_NULL;
1596 }
1597 jsval ret = JSVAL_NULL;
1598 int utf16_size = 0;
1599 jschar* strUTF16 = (jschar*)cc_utf8_to_utf16(v, length, &utf16_size);
1600
1601 if (strUTF16 && utf16_size > 0) {
1602 JSString* str = JS_NewUCStringCopyN(cx, strUTF16, utf16_size);
1603 if (str) {
1604 ret = STRING_TO_JSVAL(str);
1605 }
1606 delete[] strUTF16;
1607 }
1608 return ret;
1609}
1610
1611jsval ccpoint_to_jsval(JSContext* cx, CADipPoint& v) {
1612 JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL);

Callers 15

CCARRAY_FOREACHFunction · 0.85
CCDICT_FOREACHFunction · 0.85
std_string_to_jsvalFunction · 0.85
onOpenMethod · 0.85
onMessageMethod · 0.85
onCloseMethod · 0.85
onErrorMethod · 0.85
string_vector_to_jsvalFunction · 0.85

Calls 2

cc_utf8_to_utf16Function · 0.85
STRING_TO_JSVALFunction · 0.50

Tested by 2

string_vector_to_jsvalFunction · 0.68