本文整理汇总了C++中JSObjectGetProperty函数的典型用法代码示例。如果您正苦于以下问题:C++ JSObjectGetProperty函数的具体用法?C++ JSObjectGetProperty怎么用?C++ JSObjectGetProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JSObjectGetProperty函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ASSERT_ARG
void InspectorController::addScriptConsoleMessage(const ConsoleMessage* message)
{
ASSERT_ARG(message, message);
JSStringRef messageConstructorString = JSStringCreateWithUTF8CString("ConsoleMessage");
JSObjectRef messageConstructor = JSValueToObject(m_scriptContext, JSObjectGetProperty(m_scriptContext, m_scriptObject, messageConstructorString, 0), 0);
JSStringRelease(messageConstructorString);
JSStringRef addMessageString = JSStringCreateWithUTF8CString("addMessageToConsole");
JSObjectRef addMessage = JSValueToObject(m_scriptContext, JSObjectGetProperty(m_scriptContext, m_scriptObject, addMessageString, 0), 0);
JSStringRelease(addMessageString);
JSValueRef sourceValue = JSValueMakeNumber(m_scriptContext, message->source);
JSValueRef levelValue = JSValueMakeNumber(m_scriptContext, message->level);
JSStringRef messageString = JSStringCreateWithCharacters(message->message.characters(), message->message.length());
JSValueRef messageValue = JSValueMakeString(m_scriptContext, messageString);
JSValueRef lineValue = JSValueMakeNumber(m_scriptContext, message->line);
JSStringRef urlString = JSStringCreateWithCharacters(message->url.characters(), message->url.length());
JSValueRef urlValue = JSValueMakeString(m_scriptContext, urlString);
JSValueRef args[] = { sourceValue, levelValue, messageValue, lineValue, urlValue };
JSObjectRef messageObject = JSObjectCallAsConstructor(m_scriptContext, messageConstructor, 5, args, 0);
JSStringRelease(messageString);
JSStringRelease(urlString);
JSObjectCallAsFunction(m_scriptContext, addMessage, m_scriptObject, 1, &messageObject, 0);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:27,代码来源:InspectorController.cpp
示例2: HyperloopJSValueIsArray
/*
* Tests whether a JavaScript value is an array object
*
* This invokes Array.isArray(value) and returns its result
*/
EXPORTAPI bool HyperloopJSValueIsArray(JSContextRef ctx, JSValueRef value)
{
if (JSValueIsObject(ctx, value))
{
JSObjectRef global = JSContextGetGlobalObject(ctx);
JSValueRef exception = JSValueMakeNull(ctx);
JSStringRef string = JSStringCreateWithUTF8CString("Array");
JSObjectRef array = JSValueToObject(ctx, JSObjectGetProperty(ctx, global, string, &exception), &exception);
JSStringRelease(string);
if (!JSValueIsNull(ctx, exception))
{
return false;
}
string = JSStringCreateWithUTF8CString("isArray");
JSObjectRef isArray = JSValueToObject(ctx, JSObjectGetProperty(ctx, array, string, &exception), &exception);
JSStringRelease(string);
if (!JSValueIsNull(ctx, exception))
{
return false;
}
JSValueRef result = JSObjectCallAsFunction(ctx, isArray, global, 1, &value, &exception);
if (JSValueIsNull(ctx, exception) && JSValueIsBoolean(ctx, result))
{
return JSValueToBoolean(ctx, result);
}
}
return false;
}
开发者ID:Sophrinix,项目名称:hyperloop-common,代码行数:36,代码来源:hyperloop.cpp
示例3: search
static JSValueRef search(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* /*exception*/)
{
InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
if (!controller)
return JSValueMakeUndefined(ctx);
if (argumentCount < 2 || !JSValueIsString(ctx, arguments[1]))
return JSValueMakeUndefined(ctx);
Node* node = toNode(toJS(arguments[0]));
if (!node)
return JSValueMakeUndefined(ctx);
JSStringRef string = JSValueToStringCopy(ctx, arguments[1], 0);
String target(JSStringGetCharactersPtr(string), JSStringGetLength(string));
JSStringRelease(string);
JSObjectRef globalObject = JSContextGetGlobalObject(ctx);
JSStringRef constructorString = JSStringCreateWithUTF8CString("Array");
JSObjectRef arrayConstructor = JSValueToObject(ctx, JSObjectGetProperty(ctx, globalObject, constructorString, 0), 0);
JSStringRelease(constructorString);
JSObjectRef array = JSObjectCallAsConstructor(ctx, arrayConstructor, 0, 0, 0);
JSStringRef pushString = JSStringCreateWithUTF8CString("push");
JSValueRef pushValue = JSObjectGetProperty(ctx, array, pushString, 0);
JSStringRelease(pushString);
JSObjectRef push = JSValueToObject(ctx, pushValue, 0);
RefPtr<Range> searchRange(rangeOfContents(node));
int exception = 0;
do {
RefPtr<Range> resultRange(findPlainText(searchRange.get(), target, true, false));
if (resultRange->collapsed(exception))
break;
// A non-collapsed result range can in some funky whitespace cases still not
// advance the range's start position (4509328). Break to avoid infinite loop.
VisiblePosition newStart = endVisiblePosition(resultRange.get(), DOWNSTREAM);
if (newStart == startVisiblePosition(searchRange.get(), DOWNSTREAM))
break;
KJS::JSLock lock;
JSValueRef arg0 = toRef(toJS(toJS(ctx), resultRange.get()));
JSObjectCallAsFunction(ctx, push, array, 1, &arg0, 0);
setStart(searchRange.get(), newStart);
} while (true);
return array;
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:51,代码来源:InspectorController.cpp
示例4: lengthPropertyName
bool TestRunner::findString(JSContextRef context, JSStringRef string, JSObjectRef optionsArray)
{
JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
if (!JSValueIsNumber(context, lengthValue))
return false;
QWebPage::FindFlags findFlags = QWebPage::FindCaseSensitively;
int length = static_cast<int>(JSValueToNumber(context, lengthValue, 0));
for (int i = 0; i < length; ++i) {
JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0);
if (!JSValueIsString(context, value))
continue;
JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
findFlags &= ~QWebPage::FindCaseSensitively;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts"))
findFlags |= QWebPage::FindAtWordBeginningsOnly;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart"))
findFlags |= QWebPage::TreatMedialCapitalAsWordBeginning;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards"))
findFlags |= QWebPage::FindBackward;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround"))
findFlags |= QWebPage::FindWrapsAroundDocument;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection"))
findFlags |= QWebPage::FindBeginsInSelection;
}
DumpRenderTree* drt = DumpRenderTree::instance();
return drt->webPage()->findText(JSStringCopyQString(string), findFlags);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:33,代码来源:TestRunnerQt.cpp
示例5: EvilExceptionObject_convertToType
static JSValueRef EvilExceptionObject_convertToType(JSContextRef context, JSObjectRef object, JSType type, JSValueRef* exception)
{
UNUSED_PARAM(object);
UNUSED_PARAM(exception);
JSStringRef funcName;
switch (type) {
case kJSTypeNumber:
funcName = JSStringCreateWithUTF8CString("toNumber");
break;
case kJSTypeString:
funcName = JSStringCreateWithUTF8CString("toStringExplicit");
break;
default:
return NULL;
break;
}
JSValueRef func = JSObjectGetProperty(context, object, funcName, exception);
JSStringRelease(funcName);
JSObjectRef function = JSValueToObject(context, func, exception);
if (!function)
return NULL;
JSValueRef value = JSObjectCallAsFunction(context, function, object, 0, NULL, exception);
if (!value)
return (JSValueRef)JSStringCreateWithUTF8CString("convertToType failed");
return value;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:27,代码来源:testapi.c
示例6: JSObjectGetProperty
unsigned JSArray::length() {
JSValueRef val = JSObjectGetProperty(ctx_, instance_, JSString("length"), nullptr);
if (JSValueIsNumber(ctx_, val))
return static_cast<unsigned>(JSValueToNumber(ctx_, val, nullptr));
return 0;
}
开发者ID:FinnProjects,项目名称:ultralight,代码行数:7,代码来源:JSHelpers.cpp
示例7: JSObjectGetProperty
VJSValue VJSObject::GetProperty( const VString& inPropertyName, JS4D::ExceptionRef *outException) const
{
JSStringRef jsName = JS4D::VStringToString( inPropertyName);
JSValueRef valueRef = JSObjectGetProperty( fContext, fObject, jsName, outException);
JSStringRelease( jsName);
return VJSValue( fContext, valueRef);
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:7,代码来源:VJSValue.cpp
示例8: JSStringCreateWithUTF8CString
bool JS4D::DateObjectToVTime( ContextRef inContext, ObjectRef inObject, VTime& outTime, ExceptionRef *outException)
{
// it's caller responsibility to check inObject is really a Date using ValueIsInstanceOf
// call getTime()
bool ok = false;
JSStringRef jsString = JSStringCreateWithUTF8CString( "getTime");
JSValueRef getTime = JSObjectGetProperty( inContext, inObject, jsString, outException);
JSObjectRef getTimeFunction = JSValueToObject( inContext, getTime, outException);
JSStringRelease( jsString);
JSValueRef result = (getTime != NULL) ? JSObjectCallAsFunction( inContext, getTimeFunction, inObject, 0, NULL, outException) : NULL;
if (result != NULL)
{
// The getTime() method returns the number of milliseconds since midnight of January 1, 1970.
double r = JSValueToNumber( inContext, result, outException);
sLONG8 n = (sLONG8) r;
if (n == r)
{
outTime.FromUTCTime( 1970, 1, 1, 0, 0, 0, 0);
outTime.AddMilliseconds( n);
ok = true;
}
else
{
outTime.SetNull( true);
}
}
else
{
outTime.SetNull( true);
}
return ok;
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:33,代码来源:JS4D.cpp
示例9: JSValueMakeNumber
JS4D::ObjectRef JS4D::VTimeToObject( ContextRef inContext, const VTime& inTime, ExceptionRef *outException)
{
if (inTime.IsNull())
return NULL; // can't return JSValueMakeNull as an object
sWORD year, month, day, hour, minute, second, millisecond;
inTime.GetLocalTime( year, month, day, hour, minute, second, millisecond);
JSValueRef args[6];
args[0] = JSValueMakeNumber( inContext, year);
args[1] = JSValueMakeNumber( inContext, month-1);
args[2] = JSValueMakeNumber( inContext, day);
args[3] = JSValueMakeNumber( inContext, hour);
args[4] = JSValueMakeNumber( inContext, minute);
args[5] = JSValueMakeNumber( inContext, second);
#if NEW_WEBKIT
JSObjectRef date = JSObjectMakeDate( inContext, 6, args, outException);
#else
JSStringRef jsClassName = JSStringCreateWithUTF8CString("Date");
JSObjectRef constructor = JSValueToObject( inContext, JSObjectGetProperty( inContext, JSContextGetGlobalObject( inContext), jsClassName, NULL), NULL);
JSStringRelease( jsClassName);
JSObjectRef date = JSObjectCallAsConstructor( inContext, constructor, 6, args, outException);
#endif
return date;
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:28,代码来源:JS4D.cpp
示例10: ASSERT
void InspectorController::scriptObjectReady()
{
ASSERT(m_scriptContext);
if (!m_scriptContext)
return;
JSObjectRef global = JSContextGetGlobalObject(m_scriptContext);
ASSERT(global);
JSStringRef inspectorString = JSStringCreateWithUTF8CString("WebInspector");
JSValueRef inspectorValue = JSObjectGetProperty(m_scriptContext, global, inspectorString, 0);
JSStringRelease(inspectorString);
ASSERT(inspectorValue);
if (!inspectorValue)
return;
m_scriptObject = JSValueToObject(m_scriptContext, inspectorValue, 0);
ASSERT(m_scriptObject);
JSValueProtect(m_scriptContext, m_scriptObject);
// Make sure our window is visible now that the page loaded
m_client->showWindow();
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:25,代码来源:InspectorController.cpp
示例11: JSContextGetGlobalObject
JNIEXPORT void JNICALL
Java_com_appcelerator_hyperloop_HyperloopJNI_HyperloopCallActivityOnCreate
(JNIEnv *env, jobject thiz, jlong jsContextRef, jobject activity, jobject savedInstanceState)
{
JSContextRef context = (JSContextRef)jsContextRef;
JSObjectRef globalObject = JSContextGetGlobalObject(context);
JSStringRef onCreate = JSStringCreateWithUTF8CString("onCreate");
JSObjectRef onCreateFunc = JSValueToObject(context,
JSObjectGetProperty(context, globalObject, onCreate, NULL), NULL);
JSStringRelease(onCreate);
// save current Activity
JSObjectRef activityObj = MakeObjectForJava_android_app_Activity(context, activity);
// save parameter
JSValueRef args[1];
args[0] = MakeObjectForJava_android_os_Bundle(context, savedInstanceState);
JSValueRef exception = JSValueMakeNull(context);
// Call onCreate function
if (JSObjectIsFunction(context, onCreateFunc)) {
JSObjectCallAsFunction(context, onCreateFunc, activityObj, 1, args, &exception);
}
if (!JSValueIsNull(context, exception)) {
JSStringRef string = JSValueToStringCopy(context, exception, NULL);
CCHAR_FROM_JSSTRINGREF(string, cstring);
LOGD("Java_com_appcelerator_hyperloop_HyperloopJNI_HyperloopCallActivityOnCreate '%s'", cstring);
free(cstring);
JSStringRelease(string);
}
}
开发者ID:appcelerator-forks,项目名称:appcelerator.hyperloop,代码行数:34,代码来源:HyperloopJNIExport.c
示例12: arrayLength
static unsigned arrayLength(JSContextRef context, JSObjectRef array)
{
JSRetainPtr<JSStringRef> lengthString(Adopt, JSStringCreateWithUTF8CString("length"));
JSValueRef lengthValue = JSObjectGetProperty(context, array, lengthString.get(), 0);
if (!lengthValue)
return 0;
return static_cast<unsigned>(JSValueToNumber(context, lengthValue, 0));
}
开发者ID:sanyaade-webdev,项目名称:webkit,代码行数:8,代码来源:EventSendingController.cpp
示例13: JSStringCreateWithUTF8CString
JSValueRef ObjectWrapper::GetValue(const KeyType key)
{
JSStringRef strKey = JSStringCreateWithUTF8CString(key.c_str());
JSValueRef value = JSObjectGetProperty(g_ctx, m_obj, strKey, NULL);
JSStringRelease(strKey);
return value;
}
开发者ID:vnmc,项目名称:zephyros,代码行数:8,代码来源:jsbridge_webview.cpp
示例14: getChildren
static JSValueRef getChildren(JSContextRef ctx, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
{
KJS::JSLock lock(false);
if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
return JSValueMakeUndefined(ctx);
ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
const Vector<RefPtr<ProfileNode> >& children = profileNode->children();
JSObjectRef global = JSContextGetGlobalObject(ctx);
JSRetainPtr<JSStringRef> arrayString(Adopt, JSStringCreateWithUTF8CString("Array"));
JSValueRef arrayProperty = JSObjectGetProperty(ctx, global, arrayString.get(), exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSObjectRef arrayConstructor = JSValueToObject(ctx, arrayProperty, exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSObjectRef result = JSObjectCallAsConstructor(ctx, arrayConstructor, 0, 0, exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSRetainPtr<JSStringRef> pushString(Adopt, JSStringCreateWithUTF8CString("push"));
JSValueRef pushProperty = JSObjectGetProperty(ctx, result, pushString.get(), exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSObjectRef pushFunction = JSValueToObject(ctx, pushProperty, exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
for (Vector<RefPtr<ProfileNode> >::const_iterator it = children.begin(); it != children.end(); ++it) {
JSValueRef arg0 = toRef(toJS(toJS(ctx), (*it).get() ));
JSObjectCallAsFunction(ctx, pushFunction, result, 1, &arg0, exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
}
return result;
}
开发者ID:acss,项目名称:owb-mirror,代码行数:45,代码来源:JavaScriptProfileNode.cpp
示例15: JSObjectGetProperty
Value Object::getProperty(const String& propName) const {
JSValueRef exn;
JSValueRef property = JSObjectGetProperty(m_context, m_obj, propName, &exn);
if (!property) {
std::string exceptionText = Value(m_context, exn).toString().str();
throwJSExecutionException("Failed to get property: %s", exceptionText.c_str());
}
return Value(m_context, property);
}
开发者ID:0m15,项目名称:react-native-1,代码行数:9,代码来源:Value.cpp
示例16: JSStringCreateWithUTF8CString
pdf_jsimp_obj *pdf_jsimp_property(pdf_jsimp *imp, pdf_jsimp_obj *obj, char *prop)
{
JSStringRef jprop = JSStringCreateWithUTF8CString(prop);
JSValueRef jval = JSObjectGetProperty(imp->jscore_ctx, JSValueToObject(imp->jscore_ctx, obj->ref, NULL), jprop, NULL);
JSStringRelease(jprop);
return wrap_val(imp, jval);
}
开发者ID:azaleafisitania,项目名称:sumatrapdf,代码行数:9,代码来源:pdf-jsimp-jscore.c
示例17: MyObject_hasInstance
static bool MyObject_hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleValue, JSValueRef* exception)
{
UNUSED_PARAM(context);
JSStringRef numberString = JSStringCreateWithUTF8CString("Number");
JSObjectRef numberConstructor = JSValueToObject(context, JSObjectGetProperty(context, JSContextGetGlobalObject(context), numberString, NULL), NULL);
JSStringRelease(numberString);
return JSValueIsInstanceOfConstructor(context, possibleValue, numberConstructor, NULL);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:10,代码来源:testapi.c
示例18: jsvalue_instanceof
gboolean jsvalue_instanceof(JSContextRef ctx, JSValueRef test, const char *klass)
{
JSStringRef property = JSStringCreateWithUTF8CString(klass);
JSObjectRef ctor = JSValueToObject(ctx,
JSObjectGetProperty(ctx, JSContextGetGlobalObject(ctx),
property, NULL),
NULL);
JSStringRelease(property);
return JSValueIsInstanceOfConstructor(ctx, test, ctor, NULL);
}
开发者ID:electricface,项目名称:dde,代码行数:10,代码来源:jsextension.c
示例19: JSContextGetGlobalObject
bool JS4D::ValueIsInstanceOf( ContextRef inContext, ValueRef inValue, const VString& inConstructorName, ExceptionRef *outException)
{
JSStringRef jsString = JS4D::VStringToString( inConstructorName);
JSObjectRef globalObject = JSContextGetGlobalObject( inContext);
JSObjectRef constructor = JSValueToObject( inContext, JSObjectGetProperty( inContext, globalObject, jsString, outException), outException);
xbox_assert( constructor != NULL);
JSStringRelease( jsString);
return (constructor != NULL) && (inValue != NULL) && JSValueIsInstanceOfConstructor( inContext, inValue, constructor, outException);
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:10,代码来源:JS4D.cpp
示例20: web_view_callback
bool
web_view_callback (struct js_callback_data *data) {
unsigned short i;
JSValueRef js_args[data->args_len];
for (i = 0; i < data->args_len; i++) {
switch (data->args[i].type) {
case kJSTypeBoolean:
js_args[i] = JSValueMakeBoolean(data->widget->js_context, data->args[i].value.boolean);
break;
case kJSTypeNull:
js_args[i] = JSValueMakeNull(data->widget->js_context);
break;
case kJSTypeNumber:
js_args[i] = JSValueMakeNumber(data->widget->js_context, data->args[i].value.number);
break;
case kJSTypeObject:
js_args[i] = data->args[i].value.object;
break;
case kJSTypeString: {
JSStringRef str = JSStringCreateWithUTF8CString(data->args[i].value.string);
js_args[i] = JSValueMakeString(data->widget->js_context, str);
JSStringRelease(str);
break;
}
case kJSTypeUndefined:
js_args[i] = JSValueMakeUndefined(data->widget->js_context);
break;
}
}
if (!data->widget->js_context || !data->widget->js_object) {
LOG_ERR("missing JS context or object!");
return false;
}
JSStringRef str_ondatachanged = JSStringCreateWithUTF8CString("onDataChanged");
JSValueRef func = JSObjectGetProperty(data->widget->js_context, data->widget->js_object, str_ondatachanged, NULL);
JSObjectRef function = JSValueToObject(data->widget->js_context, func, NULL);
JSStringRelease(str_ondatachanged);
/* let the thread know we're done with the data so it can cleanup */
pthread_cond_signal(&update_cond);
if (!JSObjectIsFunction(data->widget->js_context, function)) {
LOG_DEBUG("onDataChanged callback for 'widget_%s' with type '%s' is not a function or is not set", data->widget->name, data->widget->type);
return false; /* only run once */
}
JSObjectCallAsFunction(data->widget->js_context, function, NULL, data->args_len, js_args, NULL);
return false; /* only run once */
}
开发者ID:jhanssen,项目名称:candybar,代码行数:55,代码来源:widgets.c
注:本文中的JSObjectGetProperty函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论