示例#1
0
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;
}
示例#2
0
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);
   }
示例#3
0
// 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);
}
示例#4
0
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;
}