예제 #1
0
Handle<v8::Value> clrFuncProxy(const v8::Arguments& args)
{
    DBG("clrFuncProxy");
    HandleScope scope;
    Handle<v8::External> correlator = Handle<v8::External>::Cast(args.Callee()->Get(v8::String::NewSymbol("_edgeContext")));
    ClrFuncWrap* wrap = (ClrFuncWrap*)(correlator->Value());
    ClrFunc^ clrFunc = wrap->clrFunc;
    return scope.Close(clrFunc->Call(args[0], args[1]));
}
예제 #2
0
v8::Handle<v8::Value> V8AdaptorFunction::invocationCallback(const v8::Arguments& args)
{
    v8::Handle<v8::Object> wrapped = v8::Handle<v8::Object>::Cast(args.Callee()->GetHiddenValue(V8HiddenPropertyName::adaptorFunctionPeer()));
    // FIXME: This can be faster if we can access underlying native callback directly.
    // We won't need this once https://bugs.webkit.org/show_bug.cgi?id=108138 is addressed.
    Vector<v8::Handle<v8::Value> > argArray(args.Length());
    for (int i = 0; i < args.Length(); ++i)
        argArray.append(args[i]);
    if (args.IsConstructCall())
        return wrapped->CallAsConstructor(argArray.size(), argArray.data());
    return wrapped->CallAsFunction(args.This(), argArray.size(), argArray.data());
}
예제 #3
0
v8::Handle<v8::Value> V8PerIsolateData::constructorOfToString(const v8::Arguments& args)
{
    // The DOM constructors' toString functions grab the current toString
    // for Functions by taking the toString function of itself and then
    // calling it with the constructor as its receiver. This means that
    // changes to the Function prototype chain or toString function are
    // reflected when printing DOM constructors. The only wart is that
    // changes to a DOM constructor's toString's toString will cause the
    // toString of the DOM constructor itself to change. This is extremely
    // obscure and unlikely to be a problem.
    v8::Handle<v8::Value> value = args.Callee()->Get(v8::String::NewSymbol("toString"));
    if (!value->IsFunction()) 
        return v8::String::New("");
    return v8::Handle<v8::Function>::Cast(value)->Call(args.This(), 0, 0);
}
예제 #4
0
Handle<Value> v8FuncCallback(const v8::Arguments& args)
{
    DBG("v8FuncCallback");
    HandleScope scope;
    Handle<v8::External> correlator = Handle<v8::External>::Cast(args.Callee()->Get(v8::String::NewSymbol("_edgeContext")));
    NodejsFuncInvokeContextWrap* wrap = (NodejsFuncInvokeContextWrap*)(correlator->Value());
    NodejsFuncInvokeContext^ context = wrap->context;
    if (!args[0]->IsUndefined() && !args[0]->IsNull())
    {
        context->CompleteWithError(gcnew System::Exception(exceptionV82stringCLR(args[0])));
    }
    else 
    {
        context->CompleteWithResult(args[1]);
    }
    return scope.Close(Undefined());
}
예제 #5
0
	static v8::Handle<v8::Value> FunctionCallbackImpl(const v8::Arguments& args)
	{
		v8::HandleScope handle_scope;
		JSExtension* handler = static_cast<JSExtension*>(v8::External::Cast(*(args.Data()))->Value());

		ChromiumDLL::JSObjHandle* argv = new ChromiumDLL::JSObjHandle[args.Length()];

		for(int i = 0; i < args.Length(); i++)
			argv[i] = new JSObject(args[i]);

		ChromiumDLL::JSObjHandle  obj(new JSObject(args.This()));
		v8::Handle<v8::Value> value = v8::Null();

		v8::Local<v8::Function> funct = args.Callee();
		v8::Handle<v8::Value> name = funct->GetName();
		v8::String::AsciiValue str(name);

		try
		{
			ChromiumDLL::JavaScriptFunctionArgs jsargs;
			jsargs.function = *str;
			jsargs.factory = &g_Factory;
			jsargs.argc = args.Length();
			jsargs.object = obj;
			jsargs.argv = argv;
			jsargs.context = nullptr;

			ChromiumDLL::JSObjHandle ret = handler->m_pExtender->execute(&jsargs);
			delete [] argv;

			JSObject *native = dynamic_cast<JSObject*>(ret.get());

			if (native)
				value = native->getNative();

			ret->delRef();
		}
		catch (std::exception& e)
		{
			delete [] argv;
			value = v8::ThrowException(v8::String::New(e.what()));
		}

		return value;
	}