dmz::V8Value dmz::JsExtV8Archive::_archive_release (const v8::Arguments &Args) { v8::HandleScope scope; V8Value result = v8::Undefined (); JsExtV8Archive *self = _to_self (Args); if (self && self->_core) { const Handle Instance = self->_core->get_instance_handle (Args[0]); if (Args.Length () > 1) { V8Value value = Args[1]; if (value->IsFunction ()) { V8Function func = v8_to_function (value); InstanceStruct *is = self->_instanceTable.lookup (Instance); if (is) { CallbackStruct *current = is->list; while (current) { if (current->func == func) { delete current; current = 0; } else { current = current->next; } } } } else { if (value->IsString ()) { } } } else { InstanceStruct *is = self->_instanceTable.remove (Instance); if (is) { delete is; is = 0; } } } return scope.Close (result); }
dmz::Handle dmz::JsExtV8Archive::_to_handle (V8Value value) { Handle result (_defaultArchive); if (value.IsEmpty () == false) { if (value->IsNumber ()) { result = v8_to_handle (value); } else if (value->IsString ()) { result = _defs.create_named_handle (v8_to_string (value)); } } return result; }
void dmz::V8QtObject::_do_callback (const String &Signal, const QVariantList &ValueList) { if (_state) { v8::Context::Scope cscope (_state->context); v8::HandleScope scope; QList<V8Value> args; foreach (QVariant value, ValueList) { V8Value newValue = qvariant_to_v8 (value); if (!newValue.IsEmpty ()) { args.append (newValue); } } _do_callback (Signal, args); }
// JsExtV8HTTPCurl Interface dmz::V8Value dmz::JsExtV8HTTPCurl::_http_download (const v8::Arguments &Args) { v8::HandleScope scope; V8Value result = v8::Undefined (); JsExtV8HTTPCurl *self = _to_self (Args); if (self && Args[0]->IsObject () && Args[2]->IsFunction ()) { V8Object src = V8Object::Cast (Args[0]); String address = v8_to_string (Args[1]); V8Function func = v8_to_function (Args[2]); self->_add_download (src, address, func); result = func; } return result.IsEmpty () ? result : scope.Close (result); }
dmz::Handle dmz::JsExtV8Input::_to_handle (V8Value value) { v8::HandleScope scope; Handle result (0); if (value.IsEmpty () == false) { if (value->IsString ()) { result = _defs.create_named_handle (*(v8::String::AsciiValue (value))); } else if (value->IsNumber ()) { result = value->Uint32Value (); } } return result; }