void Window::SetState(Local<String> property, Local<Value> value, const AccessorInfo& info) { NativeWindow *window = ObjectWrap::Unwrap<NativeWindow>(info.Holder()); Local<String> val = value->ToString(); if (val->Equals(String::New("normal"))) { window->SetState(NW_STATE_NORMAL); } else if (val->Equals(String::New("minimized"))) { window->SetState(NW_STATE_MINIMIZED); } else if (val->Equals(String::New("maximized"))) { window->SetState(NW_STATE_MAXIMIZED); } else if (val->Equals(String::New("fullscreen"))) { window->SetState(NW_STATE_FULLSCREEN); } }
bool StringIMPL::Equals(char *value) const { Isolate::Scope isolate_scope(g_CurrentVM); HandleScope handle_scope(g_CurrentVM); Local<Context> context = v8::Local<v8::Context>::New(g_CurrentVM, g_GlobalContext); Context::Scope context_scope(context); Local<v8::String> compared = v8::String::NewFromUtf8(g_CurrentVM, value); Local<v8::String> stringValue = Handle<v8::String>::New(g_CurrentVM, persisted_value); return stringValue->Equals(compared); }
void test_HandleScope() { HandleScope outer; Local<Value> v; { HandleScope inner; v = inner.Close(String::New("hey")); } do_check_true(!v.IsEmpty()); Local<String> s = v->ToString(); do_check_true(!s.IsEmpty()); do_check_true(s->Equals(v)); }
void V8Context::fill_prototype_stash(Handle<Object> prototype, HV* stash) { HE *he; while (he = hv_iternext(stash)) { SV *key = HeSVKEY_force(he); char *key_str = SvPV_nolen(key); Local<String> name = String::New(key_str); if (prototype->Has(name)) continue; PerlFunctionData* pfd = name->Equals(string_to_js) // we want to_js() to be called as a package function ? new PerlFunctionData(this, (SV*)GvCV(gv_fetchmethod(stash, key_str))) : new PerlMethodData(this, key_str); prototype->Set(name, pfd->object); } }