コード例 #1
0
// FIXME(fqian): returning string is cheating, and we should
// fix this by calling toString function on the receiver.
// However, V8 implements toString in JavaScript, which requires
// switching context of receiver. I consider it is dangerous.
void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> domWrapper = V8Window::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
    v8::Local<v8::Object> target = domWrapper.IsEmpty() ? info.This() : domWrapper;
    v8::Local<v8::String> value;
    if (target->ObjectProtoToString(info.GetIsolate()->GetCurrentContext()).ToLocal(&value))
        v8SetReturnValue(info, value);
}
コード例 #2
0
// FIXME(fqian): returning string is cheating, and we should
// fix this by calling toString function on the receiver.
// However, V8 implements toString in JavaScript, which requires
// switching context of receiver. I consider it is dangerous.
void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Handle<v8::Object> domWrapper = V8Window::findInstanceInPrototypeChain(info.This(), info.GetIsolate());
    if (domWrapper.IsEmpty()) {
        v8SetReturnValue(info, info.This()->ObjectProtoToString());
        return;
    }
    v8SetReturnValue(info, domWrapper->ObjectProtoToString());
}
コード例 #3
0
void ArgConverter::NativeScriptLongFunctionCallback(const v8::FunctionCallbackInfo<Value>& args)
{
	auto isolate = Isolate::GetCurrent();
	args.This()->SetHiddenValue(V8StringConstants::GetJavaLong(), Boolean::New(isolate, true));
	args.This()->SetHiddenValue(V8StringConstants::GetMarkedAsLong(), args[0]);
	args.This()->Set(V8StringConstants::GetValue(), args[0]);

	args.This()->SetPrototype(Local<NumberObject>::New(Isolate::GetCurrent(), *NAN_NUMBER_OBJECT));
}
// FIXME(fqian): returning string is cheating, and we should
// fix this by calling toString function on the receiver.
// However, V8 implements toString in JavaScript, which requires
// switching context of receiver. I consider it is dangerous.
void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    v8::Handle<v8::Object> domWrapper = args.This()->FindInstanceInPrototypeChain(V8Window::GetTemplate(args.GetIsolate(), worldTypeInMainThread(args.GetIsolate())));
    if (domWrapper.IsEmpty()) {
        v8SetReturnValue(args, args.This()->ObjectProtoToString());
        return;
    }
    v8SetReturnValue(args, domWrapper->ObjectProtoToString());
}
コード例 #5
0
ファイル: cluster.hpp プロジェクト: 1N50MN14/qdb-api-nodejs
        static void newObject(const v8::FunctionCallbackInfo<v8::Value> & args)
        {
            if (args.IsConstructCall()) 
            {
                MethodMan call(args);

                if (args.Length() != 2) 
                {
                    call.throwException("Wrong number of arguments");
                    return;
                }

                // the first parameter is a Cluster object, let's unwrap it to get access to the underlying handle
                auto obj = call.checkedArgObject(0);

                if (!obj.second)
                {
                    call.throwException("Invalid parameter supplied to object");
                    return;
                } 

                auto str = call.checkedArgString(1);
                if (!str.second)
                {
                    call.throwException("Expected a string as an argument");
                    return;
                }

                v8::String::Utf8Value utf8str(str.first);

                // get access to the underlying handle
                Cluster * c = ObjectWrap::Unwrap<Cluster>(obj.first);

                Object * b = new Object(*c, *utf8str);

                b->Wrap(args.This());
                args.GetReturnValue().Set(args.This());
            } 
            else 
            {
                v8::Isolate* isolate = v8::Isolate::GetCurrent();
                // Invoked as plain function `MyObject(...)`, turn into construct call.
                const int argc = 2;
                v8::Local<v8::Value> argv[argc] = { args[0], args[1] };
                v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
                args.GetReturnValue().Set(cons->NewInstance(argc, argv));
            }      
        }
コード例 #6
0
void MetadataNode::ClassConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
	try
	{
		SET_PROFILER_FRAME();

		auto thiz = info.This();
		auto node = reinterpret_cast<MetadataNode*>(info.Data().As<External>()->Value());

		Local<Object> outerThis;
		string extendName;
		auto className = node->m_name;

		SetInstanceMetadata(info.GetIsolate(), thiz, node);

		ArgsWrapper argWrapper(info, ArgType::Class, outerThis);

		string fullClassName = CreateFullClassName(className, extendName);
		bool success = NativeScriptRuntime::RegisterInstance(thiz, fullClassName, argWrapper, outerThis, false);
	}
	catch (NativeScriptException& e)
	{
		e.ReThrowToV8();
	}
	catch (std::exception e) {
		stringstream ss;
		ss << "Error: c++ exception: " << e.what() << endl;
		NativeScriptException nsEx(ss.str());
		nsEx.ReThrowToV8();
	}
	catch (...) {
		NativeScriptException nsEx(std::string("Error: c++ exception!"));
		nsEx.ReThrowToV8();
	}
}
コード例 #7
0
ファイル: dynprop.cpp プロジェクト: andoma/pdfium
static void FXJSE_DynPropGetterAdapter_MethodCallback(
    const v8::FunctionCallbackInfo<v8::Value>& info) {
  v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>();
  FXJSE_CLASS* lpClass = static_cast<FXJSE_CLASS*>(
      hCallBackInfo->GetAlignedPointerFromInternalField(0));
  v8::Local<v8::String> hPropName =
      hCallBackInfo->GetInternalField(1).As<v8::String>();
  ASSERT(lpClass && !hPropName.IsEmpty());
  v8::String::Utf8Value szPropName(hPropName);
  CFX_ByteStringC szFxPropName = *szPropName;
  CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
  lpThisValue->ForceSetValue(info.This());
  CFXJSE_Value* lpRetValue = CFXJSE_Value::Create(info.GetIsolate());
  CFXJSE_ArgumentsImpl impl = {&info, lpRetValue};
  lpClass->dynMethodCall(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue),
                         szFxPropName,
                         reinterpret_cast<CFXJSE_Arguments&>(impl));
  if (!lpRetValue->DirectGetValue().IsEmpty()) {
    info.GetReturnValue().Set(lpRetValue->DirectGetValue());
  }
  delete lpRetValue;
  lpRetValue = nullptr;
  delete lpThisValue;
  lpThisValue = nullptr;
}
コード例 #8
0
ファイル: messagedlg.cpp プロジェクト: hgh086/iupNode
void IMessageDlg::_init(const v8::FunctionCallbackInfo<v8::Value>& args) {
	Isolate* isolate = args.GetIsolate();
	IMessageDlg* obj = new IMessageDlg();
	// Create messagedlg
	obj->hwnd = IupMessageDlg();
	if (args.Length()>=1 && args[0]->IsNumber()) {
		int ty = args[0]->Int32Value();
		switch(ty) {
			case 1:
			IupSetStrAttribute(obj->hwnd,"BUTTONS", "OKCANCEL");
			IupSetStrAttribute(obj->hwnd,"DIALOGTYPE", "QUESTION");
			break;
			case 2:
			IupSetStrAttribute(obj->hwnd,"BUTTONS", "YESNO");
			IupSetStrAttribute(obj->hwnd,"DIALOGTYPE", "QUESTION");
			break;
			default:
			IupSetStrAttribute(obj->hwnd,"BUTTONS", "OK");
			IupSetStrAttribute(obj->hwnd,"DIALOGTYPE", "INFORMATION");
			break;
		}
	}
	if (args.Length()>=2 && args[1]->IsString()) {
		Local<String> tt = Local<String>::Cast(args[1]);
		String::Utf8Value str(tt);
		IupSetStrAttribute(obj->hwnd,"TITLE", *str);
	}
	if (args.Length()>=3 && args[2]->IsString()) {
		Local<String> tt = Local<String>::Cast(args[2]);
		String::Utf8Value str(tt);
		IupSetStrAttribute(obj->hwnd,"VALUE", *str);
	}
	obj->Wrap(args.This());
	args.GetReturnValue().Set(Undefined(isolate));
}
コード例 #9
0
ファイル: fs_nodejs.cpp プロジェクト: josthkko/qminer
void TNodeJsFIn::New(const v8::FunctionCallbackInfo<v8::Value>& Args) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::HandleScope HandleScope(Isolate);

    if (Args.IsConstructCall()) {
        EAssertR(Args.Length() == 1 && Args[0]->IsString(),
            "Expected a file path.");
        TStr FNm(*v8::String::Utf8Value(Args[0]->ToString()));
        EAssertR(TFile::Exists(FNm), "File does not exist.");

        TNodeJsFIn* JsFIn = new TNodeJsFIn(FNm);
        v8::Local<v8::Object> Instance = Args.This();
		
		v8::Handle<v8::String> key = v8::String::NewFromUtf8(Isolate, "class");
		v8::Handle<v8::String> value = v8::String::NewFromUtf8(Isolate, ClassId.CStr());
		Instance->SetHiddenValue(key, value);

        JsFIn->Wrap(Instance);
        Args.GetReturnValue().Set(Instance);
    } else {
        const int Argc = 1;
        v8::Local<v8::Value> Argv[Argc] = { Args[0] };
        v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(Isolate, constructor);
        v8::Local<v8::Object> Instance = cons->NewInstance(Argc, Argv);
        Args.GetReturnValue().Set(Instance);
    }
}
コード例 #10
0
ファイル: dynprop.cpp プロジェクト: andoma/pdfium
static void FXJSE_V8ProxyCallback_getPropertyNames(
    const v8::FunctionCallbackInfo<v8::Value>& info) {
  v8::Local<v8::Object> hChainObj =
      info.This()->GetPrototype().As<v8::Object>();
  v8::Local<v8::Value> hChainPropertyNames = hChainObj->GetPropertyNames();
  info.GetReturnValue().Set(hChainPropertyNames);
}
コード例 #11
0
ファイル: dynprop.cpp プロジェクト: andoma/pdfium
static void FXJSE_V8ProxyCallback_defineProperty(
    const v8::FunctionCallbackInfo<v8::Value>& info) {
  const FXJSE_CLASS* lpClass =
      static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
  if (!lpClass) {
    return;
  }
  v8::Isolate* pIsolate = info.GetIsolate();
  v8::HandleScope scope(pIsolate);
  v8::Local<v8::String> hPropName = info[0]->ToString();
  v8::Local<v8::Object> hPropDescriptor = info[1]->ToObject();
  v8::String::Utf8Value szPropName(hPropName);
  if (!hPropDescriptor->Has(v8::String::NewFromUtf8(pIsolate, "value"))) {
    return;
  }
  v8::Local<v8::Value> hPropValue =
      hPropDescriptor->Get(v8::String::NewFromUtf8(pIsolate, "value"));
  CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
  CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
  CFXJSE_Value* lpPropValue = CFXJSE_Value::Create(info.GetIsolate());
  lpThisValue->ForceSetValue(info.This());
  lpPropValue->ForceSetValue(hPropValue);
  FXJSE_DynPropSetterAdapter(
      lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName,
      reinterpret_cast<FXJSE_HVALUE>(lpPropValue));
  delete lpThisValue;
  lpThisValue = nullptr;
  delete lpPropValue;
  lpPropValue = nullptr;
}
コード例 #12
0
ファイル: nativecontrol.cpp プロジェクト: ONLYOFFICE/core
void _zipOpenFileBase64(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    if (args.Length() < 1)
    {
        args.GetReturnValue().Set(v8::Null(v8::Isolate::GetCurrent()));
        return;
    }

    CNativeControl* pNative = unwrap_nativeobject(args.This());
    bool bIsOpen = pNative->m_oZipWorker.OpenBase64(to_cstringA(args[0]));
    if (!bIsOpen)
    {
        args.GetReturnValue().Set(v8::Null(v8::Isolate::GetCurrent()));
        return;
    }

    v8::Local<v8::Object> obj = v8::Object::New(v8::Isolate::GetCurrent());
    for (std::vector<std::wstring>::iterator i = pNative->m_oZipWorker.m_arFiles.begin(); i != pNative->m_oZipWorker.m_arFiles.end(); i++)
    {
        std::string sFile = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(*i);

        v8::Local<v8::String> _k = v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sFile.c_str(), v8::String::kNormalString, -1);
        v8::Local<v8::String> _v = v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sFile.c_str(), v8::String::kNormalString, -1);

        obj->Set(_k, _v);
    }

    args.GetReturnValue().Set(obj);
}
コード例 #13
0
HumixFaceRec::HumixFaceRec(const v8::FunctionCallbackInfo<v8::Value>& args)
    : mVideoCap(NULL),
      mTrained(false) {

    init();
    Wrap(args.This());
}
コード例 #14
0
static void forEachMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "forEach", "TestInterfaceGarbageCollected", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 1)) {
        setMinimumArityTypeError(exceptionState, 1, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    TestInterfaceGarbageCollected* impl = V8TestInterfaceGarbageCollected::toImpl(info.Holder());
    ScriptValue callback;
    ScriptValue thisArg;
    {
        if (!info[0]->IsFunction()) {
            exceptionState.throwTypeError("The callback provided as parameter 1 is not a function.");
            exceptionState.throwIfNeeded();
            return;
        }
        callback = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]);
        thisArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[1]);
    }
    ScriptState* scriptState = ScriptState::current(info.GetIsolate());
    impl->forEachForBinding(scriptState, ScriptValue(scriptState, info.This()), callback, thisArg, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.throwIfNeeded();
        return;
    }
}
コード例 #15
0
ファイル: memorystream.cpp プロジェクト: ONLYOFFICE/core
void _ms_writestring2(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    CMemoryStream* pNative = unwrap_memorystream(args.This());
    v8::String::Value data(args[0]);
    pNative->WriteString2((wchar_t*)*data, data.length());
    args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
コード例 #16
0
void MetadataNode::ExtendedClassConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
	SET_PROFILER_FRAME();

	assert(info.IsConstructCall());

	auto isolate = info.GetIsolate();
	auto thiz = info.This();
	auto extData = reinterpret_cast<ExtendedClassData*>(info.Data().As<External>()->Value());

	auto implementationObject = Local<Object>::New(isolate, *extData->implementationObject);

	const auto& extendName = extData->extendedName;
//	auto className = TNS_PREFIX + extData->node->m_name;

	SetInstanceMetadata(isolate, thiz, extData->node);
	thiz->SetInternalField(static_cast<int>(ObjectManager::MetadataNodeKeys::CallSuper), True(isolate));
	thiz->SetHiddenValue(ConvertToV8String("t::implObj"), implementationObject);

	ArgsWrapper argWrapper(info, ArgType::Class, Local<Object>());

//	string fullClassName = CreateFullClassName(className, extendName);
	string fullClassName = extData->fullClassName;

	bool success = NativeScriptRuntime::RegisterInstance(thiz, fullClassName, argWrapper, implementationObject, false);
}
コード例 #17
0
ファイル: book_wrap.cpp プロジェクト: kneth/DemoNodeExtension
void BookWrap::Lookup(const v8::FunctionCallbackInfo<v8::Value>& args) {
    Isolate* isolate = args.GetIsolate();
    HandleScope scope(isolate);
    
    if (args.Length() == 1) {
        if (args[0]->IsString()) {
            const String::Utf8Value s(args[0]->ToString());
            Book* b = ObjectWrap::Unwrap<BookWrap>(args.This())->m_book;
            try {
                Person* p = b->lookup(*s);
                Local<Object> obj = PersonWrap::NewInstance();
                PersonWrap* pw = ObjectWrap::Unwrap<PersonWrap>(obj);
                pw->m_person = p;
                args.GetReturnValue().Set(obj);
            }
            catch (...) {
                isolate->ThrowException(Exception::RangeError(String::NewFromUtf8(isolate, "Not found")));
                args.GetReturnValue().SetUndefined();
            }
        }
        else {
            isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "String expected")));
            args.GetReturnValue().SetUndefined();
        }
    }
    else {
        isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "One argument expected")));
        args.GetReturnValue().SetUndefined();
    }
}
コード例 #18
0
ファイル: fs_nodejs.cpp プロジェクト: josthkko/qminer
void TNodeJsFOut::New(const v8::FunctionCallbackInfo<v8::Value>& Args) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::EscapableHandleScope HandleScope(Isolate);

    if (Args.IsConstructCall()) {
        EAssertR(Args.Length() >= 1 && Args[0]->IsString(),
            "Expected file path.");

        TStr FNm(*v8::String::Utf8Value(Args[0]->ToString()));
        bool AppendP = Args.Length() >= 2 && Args[1]->IsBoolean() && Args[1]->BooleanValue();

        TNodeJsFOut* JsFOut = new TNodeJsFOut(FNm, AppendP);

        v8::Local<v8::Object> Instance = Args.This();
        JsFOut->Wrap(Instance);

        Args.GetReturnValue().Set(Instance);
    } else {
        const int Argc = 1;
        v8::Local<v8::Value> Argv[Argc] = { Args[0] };
        v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(Isolate, constructor);
        cons->NewInstance(Argc, Argv);
        v8::Local<v8::Object> Instance = cons->NewInstance(Argc, Argv);
        Args.GetReturnValue().Set(Instance);
    }
}
コード例 #19
0
ファイル: cluster.hpp プロジェクト: 1N50MN14/qdb-api-nodejs
        static void New(const v8::FunctionCallbackInfo<v8::Value>& args)
        {
            if (args.IsConstructCall()) 
            {
                MethodMan call(args);

                if (args.Length() != 1) 
                {
                    call.throwException("Wrong number of arguments");
                    return;
                }

                auto str = call.checkedArgString(0);
                if (!str.second)
                {
                    call.throwException("Expected a connection string as an argument");
                    return;
                }

                v8::String::Utf8Value utf8str(str.first);

                // create and open handle
                qdb_handle_t h = qdb_open_tcp();
                const qdb_error_t err = qdb_connect(h, *utf8str);
                if (err != qdb_e_ok)
                {
                    qdb_close(h);
                    call.throwException(qdb_error(err));;
                    return;    
                }

                // handle is now owned by the cluster object
                Cluster * cl = new Cluster(h);

                cl->Wrap(args.This());
                args.GetReturnValue().Set(args.This());
            } 
            else 
            {
                v8::Isolate* isolate = v8::Isolate::GetCurrent();
                // Invoked as plain function `MyObject(...)`, turn into construct call.
                const int argc = 1;
                v8::Local<v8::Value> argv[argc] = { args[0] };
                v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
                args.GetReturnValue().Set(cons->NewInstance(argc, argv));
            }
        }
コード例 #20
0
ファイル: filters.hpp プロジェクト: hdfeos/hdf5.node
        static void isAvailable(const v8::FunctionCallbackInfo<v8::Value>& args) {
            v8::Isolate* isolate = v8::Isolate::GetCurrent();
            v8::HandleScope scope(isolate);

            Filters* obj = ObjectWrap::Unwrap<Filters>(args.This());

            args.GetReturnValue().Set((H5Zfilter_avail(args[0]->ToInt32()->Value())) ? true : false);
        }
コード例 #21
0
ファイル: ProcessWrap.cpp プロジェクト: GliderPro/node-bb
void ProcessWrap::New(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    v8::HandleScope scope(isolate);

    if (args.IsConstructCall()) {
        // Invoked as constructor: `new MyObject(...)`
        ProcessWrap* obj = new ProcessWrap();
        obj->Wrap(args.This());
        args.GetReturnValue().Set(args.This());
    }
    else {
        // Invoked as plain function `DriverControlWrap(...)`, turn into construct call.
        v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
        args.GetReturnValue().Set(cons->NewInstance());
    }
}
コード例 #22
0
ファイル: fs_nodejs.cpp プロジェクト: quintelligence/qminer
void TNodeJsFIn::getCh(const v8::FunctionCallbackInfo<v8::Value>& Args) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::HandleScope HandleScope(Isolate);

    TNodeJsFIn* JsFIn = ObjectWrap::Unwrap<TNodeJsFIn>(Args.This());

    Args.GetReturnValue().Set(v8::String::NewFromUtf8(Isolate, TStr(JsFIn->SIn->GetCh()).CStr()));
}
コード例 #23
0
ファイル: v8_sprite.cpp プロジェクト: seobyeongky/gunman
void JsSprite::New(const v8::FunctionCallbackInfo<v8::Value>& args)
{
	HandleScope handle_scope(args.GetIsolate());
	Local<Object> thiz = args.This();
	JsSprite* wrapped = new JsSprite(args.GetIsolate(), thiz);
	
	args.GetReturnValue().Set(thiz);
}
コード例 #24
0
void V8ObjectConstructor::isValidConstructorMode(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::CreateNewObject) {
        V8ThrowException::throwTypeError("Illegal constructor", info.GetIsolate());
        return;
    }
    v8SetReturnValue(info, info.This());
}
コード例 #25
0
void MetadataNode::InterfaceConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
	SET_PROFILER_FRAME();

	auto thiz = info.This();
	auto node = reinterpret_cast<MetadataNode*>(info.Data().As<External>()->Value());

	Handle<Object> implementationObject;
	Handle<String> v8ExtendName;
	string extendLocation;
	bool extendLocationFound = GetExtendLocation(extendLocation);
	if (info.Length() == 1)
	{
		if (!extendLocationFound)
		{
			ASSERT_FAIL("Invalid extend() call. No name specified for extend. Location: %s", extendLocation.c_str());
		}

		ASSERT_MESSAGE(info[0]->IsObject(), "Invalid extend() call. No implementation object specified. Location: %s", extendLocation.c_str());
		implementationObject = info[0]->ToObject();
	}
	else if (info.Length() == 2)
	{
		ASSERT_MESSAGE(info[0]->IsString(), "Invalid extend() call. No name for extend specified. Location: %s", extendLocation.c_str());
		ASSERT_MESSAGE(info[1]->IsObject(), "Invalid extend() call. Named extend should be called with second object parameter containing overridden methods. Location: %s", extendLocation.c_str());

		DEBUG_WRITE("InterfaceConstructorCallback: getting extend name");
		v8ExtendName = info[0]->ToString();
		implementationObject = info[1]->ToObject();
	}
	else
	{
		ASSERT_FAIL("Invalid extend() call. Location: %s", extendLocation.c_str());
	}

	auto className = node->m_implType;
	auto extendName = ConvertToString(v8ExtendName);
	auto extendNameAndLocation = extendLocation + extendName;
	SetInstanceMetadata(info.GetIsolate(), implementationObject, node);

	//@@@ Refactor
	string fullClassName = CreateFullClassName(className, extendNameAndLocation);
	thiz->SetHiddenValue(ConvertToV8String("implClassName"), ConvertToV8String(fullClassName));
	//

	jclass generatedClass = s_resolveClass(fullClassName, implementationObject);
	implementationObject->SetHiddenValue(ConvertToV8String(fullClassName), External::New(Isolate::GetCurrent(), generatedClass));//

	implementationObject->SetPrototype(thiz->GetPrototype());
	thiz->SetPrototype(implementationObject);
	thiz->SetHiddenValue(ConvertToV8String("t::implObj"), implementationObject);

	ArgsWrapper argWrapper(info, ArgType::Interface, Handle<Object>());

	auto success = s_registerInstance(thiz, fullClassName, argWrapper, implementationObject, true);

	assert(success);
}
コード例 #26
0
ファイル: fs_nodejs.cpp プロジェクト: quintelligence/qminer
void TNodeJsFOut::close(const v8::FunctionCallbackInfo<v8::Value>& Args) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::HandleScope HandleScope(Isolate);

    TNodeJsFOut* JsFOut = ObjectWrap::Unwrap<TNodeJsFOut>(Args.This());
    JsFOut->SOut.Clr();

    Args.GetReturnValue().Set(Args.Holder());
}
コード例 #27
0
ファイル: fs_nodejs.cpp プロジェクト: quintelligence/qminer
void TNodeJsFIn::readLine(const v8::FunctionCallbackInfo<v8::Value>& Args) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::HandleScope HandleScope(Isolate);

    TNodeJsFIn* JsFIn = ObjectWrap::Unwrap<TNodeJsFIn>(Args.This());
    TChA LnChA; JsFIn->SIn->GetNextLnBf(LnChA);

    Args.GetReturnValue().Set(v8::String::NewFromUtf8(Isolate, LnChA.CStr()));
}
コード例 #28
0
ファイル: memorystream.cpp プロジェクト: ONLYOFFICE/core
void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    CMemoryStream* pNative = unwrap_memorystream(args.This());

    LONG arg = (LONG)args[0]->Int32Value();
    pNative->WriteLONG(arg);

    args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}
コード例 #29
0
void V8Location::valueOfMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    // Just return the this object the way the normal valueOf function
    // on the Object prototype would.  The valueOf function is only
    // added to make sure that it cannot be overwritten on location
    // objects, since that would provide a hook to change the string
    // conversion behavior of location objects.
    v8SetReturnValue(info, info.This());
}
コード例 #30
0
ファイル: memorystream.cpp プロジェクト: ONLYOFFICE/core
void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    CMemoryStream* pNative = unwrap_memorystream(args.This());

    double arg = (double)args[0]->NumberValue();
    pNative->WriteLONG((LONG)(arg * 100000));

    args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
}