Esempio n. 1
0
static v8::Handle<v8::Value> insertItemBeforeCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGPathSegList.insertItemBefore");
    if (args.Length() < 2)
        return throwError("Not enough arguments", V8Proxy::TypeError);
    RefPtr<SVGPathSegListPropertyTearOff > imp = V8SVGPathSegList::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8SVGPathSeg::HasInstance(args[0])) {
        V8Proxy::throwTypeError();
        return notHandledByInterceptor();
    }
    EXCEPTION_BLOCK(SVGPathSeg*, newItem, V8SVGPathSeg::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8SVGPathSeg::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
    EXCEPTION_BLOCK(unsigned, index, toUInt32(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)));
    RefPtr<SVGPathSeg> result = imp->insertItemBefore(newItem, index, ec);
    if (UNLIKELY(ec))
        goto fail;
    return toV8(result.release());
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
Esempio n. 2
0
// JsExtV8Archive Interface
dmz::V8Value
dmz::JsExtV8Archive::_archive_observe (
      const v8::Arguments &Args,
      JsExtV8Archive &self,
      HashTableHandleTemplate<CallbackTable> &preTable,
      HashTableHandleTemplate<CallbackTable> &table,
      HashTableHandleTemplate<CallbackTable> &postTable) {

   v8::HandleScope scope;

   V8Value result = v8::Undefined ();

   if (self._core) {

      const int Length = Args.Length ();

      V8Object obj = v8_to_object (Args[0]);
      const Handle Instance (self._core->get_instance_handle (obj));
      const String Name (self._core->get_instance_name (obj));
      Handle archive (self._defaultArchive);
      String type;
      V8Function func;

      if (Length == 2) { func = v8_to_function (Args[1]); }
      else if (Length == 3) {

         archive = self._to_handle (Args[1]);
         func = v8_to_function (Args[2]);
      }
      else if (Length >= 4) {

         archive = self._to_handle (Args[1]);
         type = v8_to_string (Args[2]);
         func = v8_to_function (Args[3]);
      }

      if (self._register_callback (
            Instance,
            Name,
            archive,
            obj,
            func,
            (type == LocalPre ? preTable : (type == LocalPost ? postTable : table)))) {

         result = func;
      }
   }

   return scope.Close (result);
}
Esempio n. 3
0
File: Wrapper.cpp Progetto: pix/jav8
v8::Handle<v8::Value> CJavaFunction::Caller(const v8::Arguments& args) 
{
  CJavaFunction& func = *static_cast<CJavaFunction *>(v8::Handle<v8::External>::Cast(args.Data())->Value());

  jni::V8Env env(func.GetEnv());

  bool hasThiz = CManagedObject::IsWrapped(args.This()->ToObject());
  jobject thiz = hasThiz ? CManagedObject::Unwrap(args.This()->ToObject()).GetObject() : NULL;
  
  jobjectArray params = (jobjectArray) env.NewObjectArray(args.Length());

  for (size_t i=0; i<args.Length(); i++)
  {
    env->SetObjectArrayElement(params, i, env.Wrap(args[i]));
  }
  
  jobject method = func.GetMethod(args);
  static jmethodID mid = env.GetMethodID(env.buildins.java.lang.reflect.Method, "invoke", "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;");
  
  jobject result = env->CallObjectMethod(method, mid, thiz, params);

  return env.Close(env.Wrap(result));  
}
v8::Handle<v8::Value> V8CanvasRenderingContext2D::putImageDataCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.CanvasRenderingContext2D.putImageData()");

    // Two froms:
    // * putImageData(ImageData, x, y)
    // * putImageData(ImageData, x, y, dirtyX, dirtyY, dirtyWidth, dirtyHeight)
    if (args.Length() != 3 && args.Length() != 7) {
        V8Proxy::setDOMException(SYNTAX_ERR);
        return notHandledByInterceptor();
    }

    CanvasRenderingContext2D* context = V8CanvasRenderingContext2D::toNative(args.Holder());

    ImageData* imageData = 0;

    // Need to check that the argument is of the correct type, since
    // toNative() expects it to be correct. If the argument was incorrect
    // we leave it null, and putImageData() will throw the correct exception
    // (TYPE_MISMATCH_ERR).
    if (V8DOMWrapper::isWrapperOfType(args[0], &V8ImageData::info))
        imageData = V8ImageData::toNative(v8::Handle<v8::Object>::Cast(args[0]));

    ExceptionCode ec = 0;

    if (args.Length() == 7)
        context->putImageData(imageData, toFloat(args[1]), toFloat(args[2]), toFloat(args[3]), toFloat(args[4]), toFloat(args[5]), toFloat(args[6]), ec);
    else
        context->putImageData(imageData, toFloat(args[1]), toFloat(args[2]), ec);

    if (ec != 0) {
        V8Proxy::setDOMException(ec);
        return notHandledByInterceptor();
    }

    return v8::Undefined();
}
Esempio n. 5
0
static Handle<Value> LocationReplace(const v8::Arguments& args)
{
    Local<Object> self = args.Holder();
    Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
    void* ptr = wrap->Value();

    jsLocation* url = static_cast<jsLocation*>(ptr);
    if (url->win != NULL && args.Length() > 0) {
        url->url.assign_with_referer(value_to_string(args[0]), &url->url);
        url->win->history->push_back(url->url.tostring());
        url->win->load(url->url.tostring());
    } else {
        std::string log_info = "Location changed from '";
        if(url->url.is_valid()) {
            log_info += url->url.tostring();
        } else {
            log_info += "undefined";
        }
        log_info += "' to \n\thref: ";
        if (args.Length() > 0) {
            url->url.assign_with_referer(value_to_string(args[0]), &url->url);
            if(url->url.is_valid()) {
                log_info += url->url.tostring();
            } else {
                log_info += "undefined";
            }
        } else {
            if(url->url.is_valid()) {
                log_info += url->url.tostring();
            } else {
                log_info += "undefined";
            }
        }
        append_results(log_info);
    }
    return Handle<Value>();
}
Esempio n. 6
0
v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args)
{
    XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder());

    InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());

    ExceptionCode ec = 0;
    if (args.Length() < 1)
        xmlHttpRequest->send(ec);
    else {
        v8::Handle<v8::Value> arg = args[0];
        if (isUndefinedOrNull(arg))
            xmlHttpRequest->send(ec);
        else if (isDocumentType(arg)) {
            v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
            Document* document = V8Document::toNative(object);
            ASSERT(document);
            xmlHttpRequest->send(document, ec);
        } else if (V8Blob::HasInstance(arg)) {
            v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
            Blob* blob = V8Blob::toNative(object);
            ASSERT(blob);
            xmlHttpRequest->send(blob, ec);
        } else if (V8DOMFormData::HasInstance(arg)) {
            v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
            DOMFormData* domFormData = V8DOMFormData::toNative(object);
            ASSERT(domFormData);
            xmlHttpRequest->send(domFormData, ec);
#if ENABLE(WEBGL) || ENABLE(BLOB)
        } else if (V8ArrayBuffer::HasInstance(arg)) {
            v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
            ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(object);
            ASSERT(arrayBuffer);
            xmlHttpRequest->send(arrayBuffer, ec);
        } else if (V8ArrayBufferView::HasInstance(arg)) {
            v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg);
            ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(object);
            ASSERT(arrayBufferView);
            xmlHttpRequest->send(arrayBufferView, ec);
#endif
        } else
            xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), ec);
    }

    if (ec)
        return setDOMException(ec, args.GetIsolate());

    return v8::Undefined();
}
Esempio n. 7
0
v8::Handle<v8::Value> Util::getParentFrom( const v8::Arguments& args ) {
	if ( args.Length() < 1 ) {
		return v8::Undefined();
	}

	v8::String::Utf8Value path( args[0] );
	std::string p = *path;

	size_t index = p.rfind( '/' );
	if ( std::string::npos == index ) {
		return args[0];
	}

	return v8::String::NewSymbol( p.substr( 0, index ).c_str() );
}
Esempio n. 8
0
static v8::Handle<v8::Value> JS_runAsClient( const v8::Arguments& args )
{
	v8::HandleScope handleScope;

	int argc = args.Length();

	CSocket *sock = jsGetCObject<CSocket>(args.Holder());

	if( !sock )
	{
		return handleScope.Close( v8::Boolean::New(false) );
	}

	return handleScope.Close( v8::Boolean::New( sock->runAsClient() ) );
}
Esempio n. 9
0
v8::Handle<v8::Value> V8DOMFormData::constructorCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.FormData.Constructor");

    if (!args.IsConstructCall())
        return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);

    HTMLFormElement* form = 0;
    if (args.Length() > 0 && V8HTMLFormElement::HasInstance(args[0]))
        form = V8HTMLFormElement::toNative(args[0]->ToObject());
    RefPtr<DOMFormData> domFormData = DOMFormData::create(form);

    V8DOMWrapper::setDOMWrapper(args.Holder(), &info, domFormData.get());
    return toV8(domFormData.release(), args.Holder());
}
Esempio n. 10
0
    v8::Handle<v8::Value> setCursor(const v8::Arguments& args) {

        ALLEGRO_SYSTEM_MOUSE_CURSOR cursor = ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT;
        if (args.Length() > 0) {
            cursor = (ALLEGRO_SYSTEM_MOUSE_CURSOR)ToInt32(args[0]);
        }

        if (al_set_system_mouse_cursor(Game::allegro.display, cursor)) {
            return v8::True();
                
        } else {
            return v8::False();
        }

    }
Esempio n. 11
0
v8::Handle<v8::Value> Contacts::addCategory(const v8::Arguments& args) {
	AppLogTag("Contacts", "Entered Contacts::addCategory (args length:%d)", args.Length());

//	if (args.Length() < 1 || Util::isArgumentNull(args[0])) {
    if (args.Length() < 1) {
    	AppLogTag("Contacts", "Bad parameters");
        return v8::ThrowException(v8::String::New("Bad parameters"));
    }
    v8::HandleScope scope;

    String newCategory = null;
    if(args[0]->IsString())
    {
    	newCategory = UNWRAP_STRING(args[0]).c_str();
    	AppLogTag("Contacts","Now add new Category:%ls", newCategory.GetPointer());
    }

    if(newCategory == null)
    {
    	AppLogTag("Contacts","category name is null");
    }

    Category category;
    category.SetName(newCategory);

    AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
    Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);

    pAddressbook->AddCategory(category);

    if (IsFailed(GetLastResult())) {
        return scope.Close(v8::Boolean::New(false));
    } else {
        return scope.Close(v8::Boolean::New(true));
    }
}
Esempio n. 12
0
static v8::Handle<v8::Value> skewYCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SVGMatrix.skewY");
    if (args.Length() < 1)
        return throwError("Not enough arguments", V8Proxy::TypeError);
    RefPtr<SVGPropertyTearOff<SVGMatrix> > wrapper = V8SVGMatrix::toNative(args.Holder());
    if (wrapper->role() == AnimValRole) {
        V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR);
        return v8::Handle<v8::Value>();
    }
    SVGMatrix& impInstance = wrapper->propertyReference();
    SVGMatrix* imp = &impInstance;
    EXCEPTION_BLOCK(float, angle, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)->NumberValue()));
    return toV8(WTF::getPtr(SVGPropertyTearOff<SVGMatrix>::create(imp->skewY(angle))));
}
Esempio n. 13
0
v8::Handle<v8::Value> V8AudioNode::connectCallback(const v8::Arguments& args)
{    
    if (args.Length() < 1)
        return throwError("Not enough arguments", V8Proxy::SyntaxError);

    // CAPPFIX_WEB_HTML5: WEB_AUDIO
    AudioNode* destinationNode = 0;
    if (V8AudioNode::HasInstance(args[0]))
        destinationNode = toNative(args[0]->ToObject());
    // CAPPFIX_WEB_HTML5_END

    if (!destinationNode)
        return throwError("Invalid destination node", V8Proxy::SyntaxError);
    
    unsigned output = 0;
    unsigned input = 0;
    bool ok = false;
    if (args.Length() > 1) {
        output = toInt32(args[1], ok);
        if (!ok)
            return throwError("Invalid index parameters", V8Proxy::SyntaxError);
    }

    if (args.Length() > 2) {
        input = toInt32(args[2], ok);
        if (!ok)
            return throwError("Invalid index parameters", V8Proxy::SyntaxError);
    }
        
    AudioNode* audioNode = toNative(args.Holder());
    bool success = audioNode->connect(destinationNode, output, input);
    if (!success)
        return throwError("Invalid index parameter", V8Proxy::SyntaxError);

    return v8::Undefined();
}
Esempio n. 14
0
  static v8::Handle<v8::Value> v8addEventListener(  const v8::Arguments& arguments ){
    if( arguments.Length() > 2 ){
      v8::Local<v8::External> external = v8::Local<v8::External>::Cast( arguments.This()->GetInternalField(0) );
      EventTarget* object = static_cast<EventTarget*>( external->Value() );
      
      v8::Local<v8::String> typeStr = v8::Local<v8::String>::Cast(arguments[0]);
      v8::String::AsciiValue type(typeStr);
      
      v8::Local<v8::Function> cb = v8::Local<v8::Function>::Cast(arguments[1]);
      v8::Persistent<v8::Function> handler = v8::Persistent<v8::Function>::New(cb);

      object->addEventListener( *type, handler, false );
    }
    return v8::Undefined();
  }
Esempio n. 15
0
v8::Handle<v8::Value> V8DataView::setInt8Callback(const v8::Arguments& args)
{
    INC_STATS("DOM.DataView.setInt8");
    if (args.Length() < 2)
        return throwError("Not enough arguments", V8Proxy::SyntaxError);

    DataView* imp = V8DataView::toNative(args.Holder());
    ExceptionCode ec = 0;
    EXCEPTION_BLOCK(unsigned, byteOffset, toUInt32(args[0]));
    EXCEPTION_BLOCK(int, value, toInt32(args[1]));
    imp->setInt8(byteOffset, static_cast<int8_t>(value), ec);
    if (UNLIKELY(ec))
        V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
Esempio n. 16
0
// The callback that is invoked by v8 whenever the JavaScript 'print'
// function is called.  Prints its arguments on stdout separated by
// spaces and ending with a newline.
v8::Handle<v8::Value> Print(const v8::Arguments& args) {
	bool first = true;
	for (int i = 0; i < args.Length(); i++) {
		v8::HandleScope handle_scope;
		if (first) {
			first = false;
		} else {
			printf(" ");
		}
		internalPrint(args[i]);
	}
	printf("\n");
	fflush(stdout);
	return v8::Undefined();
}
v8::Handle<v8::Value> V8InjectedScriptHost::evaluateCallback(const v8::Arguments& args)
{
    INC_STATS("InjectedScriptHost.evaluate()");
    if (args.Length() < 1)
        return v8::ThrowException(v8::Exception::Error(v8::String::New("One argument expected.")));

    v8::Handle<v8::String> expression = args[0]->ToString();
    if (expression.IsEmpty())
        return v8::ThrowException(v8::Exception::Error(v8::String::New("The argument must be a string.")));

    v8::Handle<v8::Script> script = v8::Script::Compile(expression);
    if (script.IsEmpty()) // Return immediately in case of exception to let the caller handle it.
        return v8::Handle<v8::Value>();
    return script->Run();
}
Esempio n. 18
0
v8::Handle<v8::Value> Util::getFilenameFrom( const v8::Arguments& args ) {
	if ( args.Length() < 1 ) {
		return v8::Undefined();
	}

	v8::String::Utf8Value path( args[0] );
	std::string p = *path;

	size_t index = p.rfind( "/" );
	if ( index == std::string::npos ) {
		return args[0];
	}
	return v8::String::NewSymbol( p.substr( index + 1, p.size() - index - 1 ).c_str() );

}
Esempio n. 19
0
v8::Handle<v8::Value> V8WorkerContext::importScriptsCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.WorkerContext.importScripts()");
    if (!args.Length())
        return v8::Undefined();

    Vector<String> urls;
    for (int i = 0; i < args.Length(); i++) {
        V8TRYCATCH(v8::Handle<v8::String>, scriptUrl, args[i]->ToString());
        if (scriptUrl.IsEmpty())
            return v8::Undefined();
        urls.append(toWebCoreString(scriptUrl));
    }

    WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());

    ExceptionCode ec = 0;
    workerContext->importScripts(urls, ec);

    if (ec)
        return setDOMException(ec, args.GetIsolate());

    return v8::Undefined();
}
Esempio n. 20
0
// The callback that is invoked by v8 whenever the JavaScript 'read'
// function is called.  This function loads the content of the file named in
// the argument into a JavaScript string.
v8::Handle<v8::Value> Read(const v8::Arguments& args)
{
    if (args.Length() != 1) {
        return v8::ThrowException(v8::String::New("Bad parameters"));
    }
    v8::String::Utf8Value file(args[0]);
    if (*file == NULL) {
        return v8::ThrowException(v8::String::New("Error loading file"));
    }
    v8::Handle<v8::String> source = ReadFile(*file);
    if (source.IsEmpty()) {
        return v8::ThrowException(v8::String::New("Error loading file"));
    }
    return source;
}
Esempio n. 21
0
    v8::Handle<v8::Value> ClientWrap::SetJSONNotifyCallback( v8::Arguments const &args )
    {
      ClientWrap *wrap = node::ObjectWrap::Unwrap<ClientWrap>( args.This() );
      if ( !wrap->m_client )
        return v8::ThrowException( v8::String::New( "client has already been closed" ) );
            
      if ( args.Length() != 1 || !args[0]->IsFunction() )
        return v8::ThrowException( v8::String::New( "setJSONNotifyCallback: takes 1 function parameter (notificationCallback)" ) );
      v8::Handle<v8::Function> v8Callback = v8::Handle<v8::Function>::Cast( args[0] );

      v8::HandleScope v8HandleScope;
      wrap->m_notifyCallback = v8::Persistent<v8::Function>::New( v8Callback );
      wrap->m_client->notifyInitialState();
      return v8HandleScope.Close( v8::Handle<v8::Value>() );
    }
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tree_resize_col_contents (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QTreeWidget *tree = self->v8_to_qobject<QTreeWidget> (Args.This ());
      if (tree && Args.Length ()) { tree->resizeColumnToContents (v8_to_uint32 (Args[0])); }
   }

   return scope.Close (result);
}
v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.WebGLRenderingContext.getShaderParameter()");

    if (args.Length() != 2) {
        V8Proxy::setDOMException(SYNTAX_ERR);
        return notHandledByInterceptor();
    }

    ExceptionCode ec = 0;
    WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
    if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasInstance(args[0])) {
        V8Proxy::throwTypeError();
        return notHandledByInterceptor();
    }
    WebGLShader* shader = V8WebGLShader::HasInstance(args[0]) ? V8WebGLShader::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
    unsigned pname = toInt32(args[1]);
    WebGLGetInfo info = context->getShaderParameter(shader, pname, ec);
    if (ec) {
        V8Proxy::setDOMException(ec);
        return v8::Undefined();
    }
    return toV8Object(info);
}
Esempio n. 24
0
v8::Handle<v8::Value> V8Clipboard::getDataCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.Clipboard.getData()");
    Clipboard* clipboard = V8Clipboard::toNative(args.Holder());

    if (args.Length() != 1)
        return throwError("getData: Invalid number of arguments", V8Proxy::SyntaxError);

    bool success;
    String result = clipboard->getData(toWebCoreString(args[0]), success);
    if (success)
        return v8String(result);

    return v8::Undefined();
}
v8::Handle<v8::Value> V8SpeechRecognitionError::constructorCallback(const v8::Arguments& args)
{
    if (!args.IsConstructCall())
        return throwTypeError("DOM object constructor cannot be called as a function.");

    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
        return args.Holder();
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());

    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]);
    SpeechRecognitionErrorInit eventInit;
    if (args.Length() >= 2) {
        V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate()));
        if (!fillSpeechRecognitionErrorInit(eventInit, options))
            return v8Undefined();
    }

    RefPtr<SpeechRecognitionError> event = SpeechRecognitionError::create(type, eventInit);

    v8::Handle<v8::Object> wrapper = args.Holder();
    V8DOMWrapper::associateObjectWithWrapper(event.release(), &info, wrapper, args.GetIsolate());
    return wrapper;
}
v8::Handle<v8::Value> V8SQLResultSetRowList::itemCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.SQLResultSetRowList.item()");

    if (args.Length() == 0) {
        V8Proxy::throwError(V8Proxy::SyntaxError, "Item index is required.");
        return v8::Undefined();
    }

    if (!args[0]->IsNumber()) {
        V8Proxy::throwError(V8Proxy::TypeError, "Item index must be a number.");
        return v8::Undefined();
    }

    SQLResultSetRowList* rowList = V8SQLResultSetRowList::toNative(args.Holder());

    unsigned long index = args[0]->IntegerValue();
    if (index >= rowList->length()) {
        V8Proxy::throwError(V8Proxy::RangeError, "Item index is out of range.");
        return v8::Undefined();
    }

    v8::Local<v8::Object> item = v8::Object::New();
    unsigned numColumns = rowList->columnNames().size();
    unsigned valuesIndex = index * numColumns;

    for (unsigned i = 0; i < numColumns; ++i) {
        const SQLValue& sqlValue = rowList->values()[valuesIndex + i];
        v8::Handle<v8::Value> value;
        switch(sqlValue.type()) {
            case SQLValue::StringValue:
                value = v8String(sqlValue.string());
                break;
            case SQLValue::NullValue:
                value = v8::Null();
                break;
            case SQLValue::NumberValue:
                value = v8::Number::New(sqlValue.number());
                break;
            default:
                ASSERT_NOT_REACHED();
        }

        item->Set(v8String(rowList->columnNames()[i]), value, static_cast<v8::PropertyAttribute>(v8::DontDelete|v8::ReadOnly));
    }

    return item;
}
static v8::Handle<v8::Value> addSourceBufferCallback(const v8::Arguments& args)
{
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    MediaSource* imp = V8MediaSource::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    RefPtr<SourceBuffer> result = imp->addSourceBuffer(type, ec);
    if (UNLIKELY(ec))
        goto fail;
    return toV8(result.release(), args.Holder(), args.GetIsolate());
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> dispatchEventCallback(const v8::Arguments& args)
{
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    MediaSource* imp = V8MediaSource::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH(Event*, event, V8Event::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
    bool result = imp->dispatchEvent(event, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Boolean(result, args.GetIsolate());
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> removeSourceBufferCallback(const v8::Arguments& args)
{
    if (args.Length() < 1)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    MediaSource* imp = V8MediaSource::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    V8TRYCATCH(SourceBuffer*, buffer, V8SourceBuffer::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8SourceBuffer::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
    imp->removeSourceBuffer(buffer, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Undefined();
    }
    fail:
    return setDOMException(ec, args.GetIsolate());
}
Esempio n. 30
0
v8::Handle<v8::Value> V8CharacterData::appendDataCallback(const v8::Arguments& args) {

	v8::Local<v8::Object> self = args.Holder();
	struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr<V8CharacterDataPrivate >(self->GetInternalField(0));
	if (false) {
	} else if (args.Length() == 1 &&
	           args[0]->IsString()) {
		v8::String::AsciiValue localArg(args[0]);

		privData->nativeObj->appendData(*localArg);

		return v8::Undefined();
	}
	throw V8Exception("Parameter mismatch while calling appendData");
	return v8::Undefined();
}