本文整理汇总了C++中v8::Handle::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::Get方法的具体用法?C++ Handle::Get怎么用?C++ Handle::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::Handle
的用法示例。
在下文中一共展示了Handle::Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PopulateInstance
void JSPlanarVideoFrame::PopulateInstance(v8::Handle<v8::Object> inst) {
// We really need to populate the various planes
PopulatePlaneInstance(inst->Get(v8::String::New("y"))->ToObject(), PLANAR_Y);
PopulatePlaneInstance(inst->Get(v8::String::New("u"))->ToObject(), PLANAR_U);
PopulatePlaneInstance(inst->Get(v8::String::New("v"))->ToObject(), PLANAR_V);
inst->SetInternalField(0, v8::External::New(this));
}
示例2: v8ToMongo
BSONObj v8ToMongo( v8::Handle<v8::Object> o ){
BSONObjBuilder b;
v8::Handle<v8::String> idName = String::New( "_id" );
if ( o->HasRealNamedProperty( idName ) ){
v8ToMongoElement( b , idName , "_id" , o->Get( idName ) );
}
Local<v8::Array> names = o->GetPropertyNames();
for ( unsigned int i=0; i<names->Length(); i++ ){
v8::Local<v8::String> name = names->Get(v8::Integer::New(i) )->ToString();
if ( o->GetPrototype()->IsObject() &&
o->GetPrototype()->ToObject()->HasRealNamedProperty( name ) )
continue;
v8::Local<v8::Value> value = o->Get( name );
const string sname = toSTLString( name );
if ( sname == "_id" )
continue;
v8ToMongoElement( b , name , sname , value );
}
return b.obj();
}
示例3: dispatchDidParseSource
void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> object)
{
listener->didParseSource(
toWebCoreStringWithNullCheck(object->Get(v8::String::New("id"))),
toWebCoreStringWithNullCheck(object->Get(v8::String::New("name"))),
toWebCoreStringWithNullCheck(object->Get(v8::String::New("source"))),
object->Get(v8::String::New("lineOffset"))->ToInteger()->Value());
}
示例4: jsObjectIndexPropsToJavaArray
jobjectArray TypeConverter::jsObjectIndexPropsToJavaArray(v8::Handle<v8::Object> jsObject, int start, int length)
{
JNIEnv *env = JNIScope::getEnv();
if (!env) {
return NULL;
}
HandleScope scope;
int arrayLength = length == 0 ? 0 : length - start;
jobjectArray javaArray = env->NewObjectArray(arrayLength, JNIUtil::objectClass, NULL);
int index = 0;
for (int index = start; index < length; ++index) {
v8::Local<Value> prop = jsObject->Get(index);
bool isNew;
jobject javaObject = jsValueToJavaObject(prop, &isNew);
env->SetObjectArrayElement(javaArray, index - start, javaObject);
if (isNew) {
env->DeleteLocalRef(javaObject);
}
}
return javaArray;
}
示例5: setupThirdPartyMain
// install a do-nothing "_third_party_main" as a built-in native module to
// bypass the normal startup
void setupThirdPartyMain(v8::Handle<v8::Object> process_l) {
TRACEIN;
v8::HandleScope scope;
// call process.binding("natives"). We have to call it through Javascript
// because the C++ implementation -- Binding() in node.cc -- is declared static.
v8::Local<v8::Value> binding_v = process_l->Get(v8::String::New("binding"));
assert(binding_v->IsFunction());
v8::Local<v8::Function> binding = v8::Local<v8::Function>::Cast(binding_v);
v8::Local<v8::Value> args[] = { v8::String::New("natives") };
v8::TryCatch try_catch;
binding->Call(process_l, 1, args);
if (try_catch.HasCaught()) {
node::FatalException(try_catch);
}
// add blank source code for _third_party_main to the bindings_cache's "natives"
// object, which holds source code for native modules that are included as strings
// this tricks Node.js into not calling it's normal node-main
v8::Local<v8::Object> nativesObj = node::binding_cache->Get(
v8::String::NewSymbol("natives") )->ToObject();
v8::Handle<v8::String> source = BUILTIN_ASCII_ARRAY(pdg_main_native, sizeof(pdg_main_native)-1);
nativesObj->Set(v8::String::New("_third_party_main"), source);
TRACEOUT;
}
示例6: eval
Value Interpreter::eval(const String& data, const String& name)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate, mData->context);
v8::Context::Scope contextScope(context);
v8::Handle<v8::String> fileName = v8::String::NewFromUtf8(isolate, name.constData());
v8::Handle<v8::String> source = v8::String::NewFromUtf8(isolate, data.constData());
v8::TryCatch try_catch;
v8::Handle<v8::Script> script = v8::Script::Compile(source, fileName);
if (script.IsEmpty()) {
error() << "script" << name << "didn't compile";
return Value();
}
const v8::Handle<v8::Value> result = script->Run();
if (try_catch.HasCaught()) {
const v8::Handle<v8::Message> msg = try_catch.Message();
{
const v8::String::Utf8Value str(msg->Get());
error() << ToCString(str);
}
{
const v8::String::Utf8Value str(msg->GetScriptResourceName());
error() << String::format<64>("At %s:%d", ToCString(str), msg->GetLineNumber());
}
return Value();
}
return mData->v8ValueToValue(result);
}
示例7: printAllPropertyNames
void printAllPropertyNames(v8::Handle<v8::Object> objToPrint)
{
v8::Local<v8::Array> allProps = objToPrint->GetPropertyNames();
std::vector<v8::Local<v8::Object> > propertyNames;
for (int s=0; s < (int)allProps->Length(); ++s)
{
v8::Local<v8::Object>toPrint= v8::Local<v8::Object>::Cast(allProps->Get(s));
String errorMessage = "Error: error decoding first string in debug_checkCurrentContextX. ";
String strVal, strVal2;
bool stringDecoded = decodeString(toPrint, strVal,errorMessage);
if (!stringDecoded)
{
SILOG(js,error,errorMessage);
return;
}
v8::Local<v8::Value> valueToPrint = objToPrint->Get(v8::String::New(strVal.c_str(), strVal.length()));
errorMessage = "Error: error decoding second string in debug_checkCurrentContextX. ";
stringDecoded = decodeString(valueToPrint,strVal2,errorMessage);
if (!stringDecoded)
{
SILOG(js,error,errorMessage);
return;
}
std::cout<<" property "<< s <<": "<<strVal <<": "<<strVal2<<"\n";
}
}
示例8: jsArrayToJavaArray
jarray TypeConverter::jsArrayToJavaArray(v8::Handle<v8::Array> jsArray)
{
JNIEnv *env = JNIScope::getEnv();
if (env == NULL) {
return NULL;
}
int arrayLength = jsArray->Length();
jobjectArray javaArray = env->NewObjectArray(arrayLength, JNIUtil::objectClass, NULL);
if (javaArray == NULL) {
LOGE(TAG, "unable to create new jobjectArray");
return NULL;
}
for (int i = 0; i < arrayLength; i++) {
v8::Local<v8::Value> element = jsArray->Get(i);
bool isNew;
jobject javaObject = jsValueToJavaObject(element, &isNew);
env->SetObjectArrayElement(javaArray, i, javaObject);
if (isNew) {
env->DeleteLocalRef(javaObject);
}
}
return javaArray;
}
示例9: consoleMessage
void V8ConsoleMessage::handler(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
// Use the frame where JavaScript is called from.
Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
if (!frame)
return;
Page* page = frame->page();
if (!page)
return;
v8::Handle<v8::String> errorMessageString = message->Get();
ASSERT(!errorMessageString.IsEmpty());
String errorMessage = toWebCoreString(errorMessageString);
v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
RefPtr<ScriptCallStack> callStack;
// Currently stack trace is only collected when inspector is open.
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
bool useURL = resourceName.IsEmpty() || !resourceName->IsString();
String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName);
V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber());
consoleMessage.dispatchNow(page, callStack);
}
示例10: messageHandlerInMainThread
static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
DOMWindow* firstWindow = firstDOMWindow();
if (!firstWindow->isCurrentlyDisplayedInFrame())
return;
String errorMessage = toWebCoreString(message->Get());
v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
RefPtr<ScriptCallStack> callStack;
// Currently stack trace is only collected when inspector is open.
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString();
String resource = shouldUseDocumentURL ? firstWindow->document()->url() : toWebCoreString(resourceName);
RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, message->GetLineNumber(), message->GetStartColumn());
// messageHandlerInMainThread can be called while we're creating a new context.
// Since we cannot create a wrapper in the intermediate timing, we need to skip
// creating a wrapper for |event|.
DOMWrapperWorld* world = DOMWrapperWorld::current();
Frame* frame = firstWindow->document()->frame();
if (world && frame && frame->script()->existingWindowShell(world)) {
v8::Local<v8::Value> wrappedEvent = toV8(event.get(), v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
if (!wrappedEvent.IsEmpty()) {
ASSERT(wrappedEvent->IsObject());
v8::Local<v8::Object>::Cast(wrappedEvent)->SetHiddenValue(V8HiddenPropertyName::error(), data);
}
}
AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
firstWindow->document()->reportException(event.release(), callStack, corsStatus);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:34,代码来源:V8Initializer.cpp
示例11: messageHandlerInWorker
static void messageHandlerInWorker(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
static bool isReportingException = false;
// Exceptions that occur in error handler should be ignored since in that case
// WorkerGlobalScope::reportException will send the exception to the worker object.
if (isReportingException)
return;
isReportingException = true;
// During the frame teardown, there may not be a valid context.
if (ScriptExecutionContext* context = getScriptExecutionContext()) {
String errorMessage = toWebCoreString(message->Get());
String sourceURL = toWebCoreString(message->GetScriptResourceName());
RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, message->GetLineNumber(), message->GetStartColumn());
v8::Local<v8::Value> wrappedEvent = toV8(event.get(), v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
if (!wrappedEvent.IsEmpty()) {
ASSERT(wrappedEvent->IsObject());
v8::Local<v8::Object>::Cast(wrappedEvent)->SetHiddenValue(V8HiddenPropertyName::error(), data);
}
AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
context->reportException(event.release(), 0, corsStatus);
}
isReportingException = false;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:25,代码来源:V8Initializer.cpp
示例12: eventListenerEffectiveFunction
static v8::Handle<v8::Function> eventListenerEffectiveFunction(v8::Isolate* isolate, v8::Handle<v8::Object> listenerObject)
{
v8::Handle<v8::Function> function;
if (listenerObject->IsFunction()) {
function = v8::Handle<v8::Function>::Cast(listenerObject);
} else if (listenerObject->IsObject()) {
// Try the "handleEvent" method (EventListener interface).
v8::Handle<v8::Value> property = listenerObject->Get(v8AtomicString(isolate, "handleEvent"));
if (property.IsEmpty() || !property->IsFunction()) {
// Fall back to the "constructor" property.
property = listenerObject->Get(v8AtomicString(isolate, "constructor"));
}
if (!property.IsEmpty() && property->IsFunction())
function = v8::Handle<v8::Function>::Cast(property);
}
return function;
}
示例13: messageHandlerInMainThread
static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
{
ASSERT(isMainThread());
// It's possible that messageHandlerInMainThread() is invoked while we're initializing a window.
// In that half-baked situation, we don't have a valid context nor a valid world,
// so just return immediately.
if (DOMWrapperWorld::windowIsBeingInitialized())
return;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
// If called during context initialization, there will be no entered window.
LocalDOMWindow* enteredWindow = enteredDOMWindow(isolate);
if (!enteredWindow)
return;
String errorMessage = toCoreString(message->Get());
v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
RefPtr<ScriptCallStack> callStack = nullptr;
int scriptId = message->GetScriptOrigin().ScriptID()->Value();
// Currently stack trace is only collected when inspector is open.
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) {
callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture, isolate);
bool success = false;
int topScriptId = callStack->at(0).scriptId().toInt(&success);
if (success && topScriptId == scriptId)
scriptId = 0;
} else {
Vector<ScriptCallFrame> callFrames;
callStack = ScriptCallStack::create(callFrames);
}
v8::Handle<v8::Value> resourceName = message->GetScriptOrigin().ResourceName();
bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString();
String resource = shouldUseDocumentURL ? enteredWindow->document()->url() : toCoreString(resourceName.As<v8::String>());
ScriptState* scriptState = ScriptState::current(isolate);
RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, message->GetLineNumber(), message->GetStartColumn() + 1, &scriptState->world());
if (V8DOMWrapper::isDOMWrapper(data)) {
v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data);
const WrapperTypeInfo* type = toWrapperTypeInfo(obj);
if (V8DOMException::wrapperTypeInfo.isSubclass(type)) {
DOMException* exception = V8DOMException::toNative(obj);
if (exception && !exception->messageForConsole().isEmpty())
event->setUnsanitizedMessage("Uncaught " + exception->toStringForConsole());
}
}
// This method might be called while we're creating a new context. In this case, we
// avoid storing the exception object, as we can't create a wrapper during context creation.
// FIXME: Can we even get here during initialization now that we bail out when GetEntered returns an empty handle?
LocalFrame* frame = enteredWindow->document()->frame();
if (frame && frame->script().existingWindowProxy(scriptState->world())) {
V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scriptState->context()->Global(), isolate);
}
enteredWindow->document()->reportException(event.release(), scriptId, callStack);
}
示例14: init
static void init(v8::Handle<v8::Object> target) {
NodeWxApp::Init(target);
wxNode_wxFrame::Init(target);
wxNode_wxMenu::Init(target);
wxNode_wxMenuBar::Init(target);
wxNode_wxPoint::Init(target);
wxNode_wxSize::Init(target);
wxNode_wxTextCtrl::Init(target);
wxNode_wxPanel::Init(target);
wxNode_wxListBox::Init(target);
wxNode_wxSizerFlags::Init(target);
wxNode_wxWindow::Init(target);
wxNode_wxNotebook::Init(target);
wxNode_wxBoxSizer::Init(target);
wxNode_wxButton::Init(target);
wxNode_wxStaticText::Init(target);
wxNode_wxIcon::Init(target);
wxNode_wxDialog::Init(target);
NodeWxMessageBox::Init(target);
NodeWxLogStatus::Init(target);
{
v8::Function* newWxSize = v8::Function::Cast(*target->Get(v8::String::New("wxSize")));
v8::Local<v8::Value> argv[0];
v8::Handle<v8::Object> s = newWxSize->CallAsConstructor(0, argv)->ToObject();
v8::Function *initFn = v8::Function::Cast(*s->Get(v8::String::New("init")));
v8::Local<v8::Value> initArgv[2];
initArgv[0] = v8::Number::New(wxDefaultSize.GetWidth());
initArgv[1] = v8::Number::New(wxDefaultSize.GetHeight());
initFn->Call(s, 2, initArgv);
target->Set(v8::String::NewSymbol("wxDefaultSize"), s);
}
{
v8::Function* newWxPosition = v8::Function::Cast(*target->Get(v8::String::New("wxPoint")));
v8::Local<v8::Value> argv[0];
v8::Handle<v8::Object> s = newWxPosition->CallAsConstructor(0, argv)->ToObject();
v8::Function *initFn = v8::Function::Cast(*s->Get(v8::String::New("init")));
v8::Local<v8::Value> initArgv[2];
initArgv[0] = v8::Number::New(wxDefaultSize.x);
initArgv[1] = v8::Number::New(wxDefaultSize.y);
initFn->Call(s, 2, initArgv);
target->Set(v8::String::NewSymbol("wxDefaultPosition"), s);
}
}
示例15: dispatchDidParseSource
void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> object)
{
String sourceID = toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("id")));
ScriptDebugListener::Script script;
script.url = toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("name")));
script.source = toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("source")));
script.sourceMappingURL = toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("sourceMappingURL")));
script.startLine = object->Get(v8::String::New("startLine"))->ToInteger()->Value();
script.startColumn = object->Get(v8::String::New("startColumn"))->ToInteger()->Value();
script.endLine = object->Get(v8::String::New("endLine"))->ToInteger()->Value();
script.endColumn = object->Get(v8::String::New("endColumn"))->ToInteger()->Value();
script.isContentScript = object->Get(v8::String::New("isContentScript"))->ToBoolean()->Value();
listener->didParseSource(sourceID, script);
}