当前位置: 首页>>代码示例>>C++>>正文


C++ JSValue::IsObject方法代码示例

本文整理汇总了C++中JSValue::IsObject方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::IsObject方法的具体用法?C++ JSValue::IsObject怎么用?C++ JSValue::IsObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSValue的用法示例。


在下文中一共展示了JSValue::IsObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DispatchJavaScriptMethods

void C_AwesomiumBrowserManager::DispatchJavaScriptMethods(C_AwesomiumBrowserInstance* pBrowserInstance)
{
	//WebView* pWebView = m_webViews[pWebTab];

	std::string previousObjectName = "-1";

	JSValue response;
	JSObject responseObject;
	std::vector<JavaScriptMethodCall_t*>& methodCalls = pBrowserInstance->GetJavaScriptMethodCalls();
	for (auto pJavaScriptMethodCall : methodCalls)
	{
		if (previousObjectName != pJavaScriptMethodCall->objectName)
		{
			previousObjectName = pJavaScriptMethodCall->objectName;
			response = pBrowserInstance->GetWebView()->ExecuteJavascriptWithResult(WSLit(pJavaScriptMethodCall->objectName.c_str()), WSLit(""));
			if (!response.IsObject())
				continue;

			responseObject = response.ToObject();
		}

		JSArray arguments;
		for (auto argument : pJavaScriptMethodCall->methodArguments)
			arguments.Push(WSLit(argument.c_str()));

		responseObject.InvokeAsync(WSLit(pJavaScriptMethodCall->methodName.c_str()), arguments);
	}

	//m_pWebBrowser->DispatchJavaScriptMethods(pWebTab);
}
开发者ID:smsithlord,项目名称:AArcade-Source,代码行数:30,代码来源:c_awesomiumbrowsermanager.cpp

示例2: parseFunction

optional<Function<T>> parseFunction(const char* name, const JSValue& value) {
    if (!value.IsObject()) {
        auto constant = parseProperty<T>(name, value);
        if (!constant) {
            return {};
        }
        return { Function<T>(*constant) };
    }

    if (!value.HasMember("stops")) {
        Log::Warning(Event::ParseStyle, "function must specify a function type");
        return {};
    }

    float base = 1.0f;

    if (value.HasMember("base")) {
        const JSValue& value_base = value["base"];

        if (!value_base.IsNumber()) {
            Log::Warning(Event::ParseStyle, "base must be numeric");
            return {};
        }

        base = value_base.GetDouble();
    }

    auto stops = parseStops<T>(name, value["stops"]);

    if (!stops) {
        return {};
    }

    return { Function<T>(*stops, base) };
}
开发者ID:AJcravea,项目名称:mapbox-gl-native,代码行数:35,代码来源:property_parsing.cpp

示例3: requireModule

	JSValue GlobalObject::requireModule(const JSObject& parent, const std::string& moduleId)
	{
		TITANIUM_GLOBALOBJECT_LOCK_GUARD;

		const auto js_context = parent.get_context();

		// check if we have special module such as ti.map
		if (requiredBuiltinModuleExists(js_context, moduleId)) {
			return requireBuiltinModule(js_context, moduleId);
		}

		// check if we have native module
		if (requiredNativeModuleExists(js_context, moduleId)) {
			return requireNativeModule(js_context, moduleId);
		}

		auto module_path = requestResolveModule(parent, moduleId);
		if (module_path.empty()) {
			// Fall back to assuming equivalent of "/" + moduleId?
			module_path = requestResolveModule(parent, "/" + moduleId);
			if (module_path.empty()) {
				detail::ThrowRuntimeError("require", "Could not load module " + moduleId);
			}
		}

		// check if we have already loaded the module
		if (module_cache__.find(module_path) != module_cache__.end()) {
			return module_cache__.at(module_path);
		}

		const auto module_js = readRequiredModule(parent, module_path);

		if (module_js.empty()) {
			detail::ThrowRuntimeError("require", "Could not load module " + moduleId);
		}

		try {
			JSValue result = js_context.CreateUndefined();
			if (boost::ends_with(module_path, ".json")){
				result = js_context.CreateValueFromJSON(module_js);
			} else if (js_context.JSCheckScriptSyntax(module_js, moduleId)) {
				const std::vector<JSValue> args = { js_context.CreateString(moduleId), js_context.CreateString(module_js) };
				result = require_function__(args, js_context.get_global_object());
			} else {
				detail::ThrowRuntimeError("require", "Could not load module "+moduleId);
			}
			if (!result.IsObject()) {
				TITANIUM_LOG_WARN("GlobalObject::require: module '", moduleId, "' replaced 'exports' with a non-object: ", to_string(result));
			}
			// cache it so that we can reuse it
			module_cache__.insert({module_path, result});
			return result;
		} catch (const std::exception& exception) {
			detail::ThrowRuntimeError("require", "Error while require("+moduleId+") "+static_cast<std::string>(exception.what()));
		} catch (...) {
			detail::ThrowRuntimeError("require", "Unknown error while require("+moduleId+")");
		}
		return js_context.CreateUndefined();
	}
开发者ID:FokkeZB,项目名称:titanium_mobile_windows,代码行数:59,代码来源:GlobalObject.cpp

示例4: parseProperty

optional<Function<Faded<std::string>>> parseProperty(const char* name, const JSValue& value) {
    if (value.IsObject()) {
        return parseFadedFunction<std::string>(value);
    }

    auto constant = parseProperty<std::string>(name, value);
    if (!constant) {
        return {};
    }
    return Function<Faded<std::string>>(*constant);
}
开发者ID:AJcravea,项目名称:mapbox-gl-native,代码行数:11,代码来源:property_parsing.cpp

示例5: js_to_MediaQueryInfoType

		MediaQueryInfoType js_to_MediaQueryInfoType(const JSValue& js_info)
		{
			const auto ctx = js_info.get_context();
			
			if (js_info.IsObject()) {
				const auto js_info_obj = static_cast<JSObject>(js_info);
				const auto exact = static_cast<bool>(js_info_obj.GetProperty("exact"));
				const auto value = js_info_obj.GetProperty("value");
				return { exact, value };
			}
			return { true, js_info };
		};
开发者ID:appcelerator-forks,项目名称:appcelerator.titanium_mobile_windows,代码行数:12,代码来源:MediaQueryInfoType.cpp

示例6: get_context

		TITANIUM_FUNCTION(DB, remove)
		{
			close();

			// Now we grab the file object and call deleteFile on it
			JSValue file = get_file();
			TITANIUM_ASSERT(file.IsObject());  // precondition
			JSObject FileObject = static_cast<JSObject>(file);

			const auto file_ptr = FileObject.GetPrivate<Titanium::Filesystem::File>();

			if (file_ptr != nullptr && file_ptr->exists()) {
				file_ptr->deleteFile();
			}

			return get_context().CreateUndefined();
		}
开发者ID:appcelerator-forks,项目名称:appcelerator.titanium_mobile_windows,代码行数:17,代码来源:DB.cpp

示例7: parseSources

void Parser::parseSources(const JSValue& value) {
    if (!value.IsObject()) {
        Log::Warning(Event::ParseStyle, "sources must be an object");
        return;
    }

    for (const auto& property : value.GetObject()) {
        std::string id = *conversion::toString(property.name);

        conversion::Result<std::unique_ptr<Source>> source =
            conversion::convert<std::unique_ptr<Source>>(property.value, id);
        if (!source) {
            Log::Warning(Event::ParseStyle, source.error().message);
            continue;
        }

        sourcesMap.emplace(id, (*source).get());
        sources.emplace_back(std::move(*source));
    }
}
开发者ID:OrdnanceSurvey,项目名称:mapbox-gl-native,代码行数:20,代码来源:parser.cpp

示例8: parseSources

void Parser::parseSources(const JSValue& value) {
    if (!value.IsObject()) {
        Log::Warning(Event::ParseStyle, "sources must be an object");
        return;
    }

    for (auto it = value.MemberBegin(); it != value.MemberEnd(); ++it) {
        std::string id = *conversion::toString(it->name);

        conversion::Result<std::unique_ptr<Source>> source
            = conversion::convert<std::unique_ptr<Source>>(it->value, id);
        if (!source) {
            Log::Warning(Event::ParseStyle, source.error().message);
            continue;
        }

        sourcesMap.emplace(id, (*source).get());
        sources.emplace_back(std::move(*source));
    }
}
开发者ID:CyberLight,项目名称:mapbox-gl-native,代码行数:20,代码来源:parser.cpp

示例9: TransitionOptions

optional<TransitionOptions> parseTransitionOptions(const char *, const JSValue& value) {
    if (!value.IsObject()) {
        return {};
    }

    optional<Duration> duration;
    if (value.HasMember("duration") && value["duration"].IsNumber()) {
        duration.emplace(Milliseconds(value["duration"].GetUint()));
    }

    optional<Duration> delay;
    if (value.HasMember("delay") && value["delay"].IsNumber()) {
        delay.emplace(Milliseconds(value["delay"].GetUint()));
    }

    if (!duration && !delay) {
        return {};
    }

    return TransitionOptions(duration, delay);
}
开发者ID:EmronAlbert,项目名称:mapbox-gl-native,代码行数:21,代码来源:property_parsing.cpp

示例10: BindMethods

	void BindMethods(WebView* web_view) {
		// Create a global js object named 'app'
		JSValue result = web_view->CreateGlobalJavascriptObject(WSLit("app"));
		if (result.IsObject()) {
			// Bind our custom method to it.
			JSObject& app_object = result.ToObject();
			method_dispatcher_.Bind(app_object,
				WSLit("backgroundGrey"),
				JSDelegate(this, &TutorialApp::BackgroundGrey));

			method_dispatcher_.Bind(app_object,
				WSLit("backgroundWhite"),
				JSDelegate(this, &TutorialApp::BackgroundWhite));

			method_dispatcher_.Bind(app_object,
				WSLit("backgroundBluish"),
				JSDelegate(this, &TutorialApp::BackgroundBluish));
		}

		// Bind our method dispatcher to the WebView
		web_view->set_js_method_handler(&method_dispatcher_);
	}
开发者ID:LenihanConor,项目名称:Cluiche,代码行数:22,代码来源:Main.cpp

示例11: DispatchJavaScriptMethod

void C_AwesomiumBrowserManager::DispatchJavaScriptMethod(C_AwesomiumBrowserInstance* pBrowserInstance, std::string objectName, std::string objectMethod, std::vector<std::string> methodArguments)
{
	//WebView* pWebView = m_webViews[pWebTab];

	JSValue response = pBrowserInstance->GetWebView()->ExecuteJavascriptWithResult(WSLit(objectName.c_str()), WSLit(""));
	if (response.IsObject())
	{
		JSObject object = response.ToObject();
		JSArray arguments;

		for (auto argument : methodArguments)
			arguments.Push(WSLit(argument.c_str()));

		object.InvokeAsync(WSLit(objectMethod.c_str()), arguments);
	}

	//m_pWebBrowser->DispatchJavaScriptMethod(pWebTab, objectName, objectMethod, methodArguments);
	/*
	for (auto arg : args)
	{
	DevMsg("Argument: %s\n", arg->text.c_str());
	}
	*/
}
开发者ID:smsithlord,项目名称:AArcade-Source,代码行数:24,代码来源:c_awesomiumbrowsermanager.cpp

示例12: NativeModuleExample

TEST_F(ModuleTests, properties)
{
	JSContext js_context = js_context_group.CreateContext(JSExport<Titanium::GlobalObject>::Class());
	auto global_object = js_context.get_global_object();

	XCTAssertFalse(global_object.HasProperty("Titanium"));
	auto Titanium = js_context.CreateObject();
	global_object.SetProperty("Titanium", Titanium, {JSPropertyAttribute::ReadOnly, JSPropertyAttribute::DontDelete});
	XCTAssertTrue(global_object.HasProperty("Titanium"));

	// Make the alias "Ti" for the "Titanium" property.
	XCTAssertFalse(global_object.HasProperty("Ti"));
	global_object.SetProperty("Ti", Titanium, {JSPropertyAttribute::ReadOnly, JSPropertyAttribute::DontDelete});
	XCTAssertTrue(global_object.HasProperty("Ti"));

	XCTAssertFalse(Titanium.HasProperty("Module"));
	auto Module = js_context.CreateObject(JSExport<Titanium::Module>::Class());
	Titanium.SetProperty("Module", Module, {JSPropertyAttribute::ReadOnly, JSPropertyAttribute::DontDelete});
	XCTAssertTrue(Titanium.HasProperty("Module"));

	XCTAssertTrue(Module.HasProperty("addEventListener"));
	XCTAssertTrue(Module.HasProperty("applyProperties"));
	XCTAssertTrue(Module.HasProperty("fireEvent"));

	auto nativeModuleExample = js_context.CreateObject(JSExport<NativeModuleExample>::Class());
	global_object.SetProperty("NativeModuleExample", nativeModuleExample, {JSPropertyAttribute::ReadOnly, JSPropertyAttribute::DontDelete});
	XCTAssertTrue(global_object.HasProperty("NativeModuleExample"));

	JSValue result = js_context.CreateNull();
	XCTAssertNoThrow(result = js_context.JSEvaluateScript("var module = new NativeModuleExample(); module;"));
	XCTAssertTrue(result.IsObject());

	JSObject module = static_cast<JSObject>(result);
	auto module_ptr = module.GetPrivate<NativeModuleExample>();
	XCTAssertNotEqual(nullptr, module_ptr);

	// Set the name of the event that "enables" the native module. This could be
	// the 'update' event for the Titanium.Accelerometer that turns on the
	// device's battery-consuming accelerometer measurements.
	module_ptr->set_event_name("foo");
	XCTAssertEqual("foo", module_ptr->get_event_name());

	// The native module should be disabled since there are no 'foo' event
	// listeners registered yet.
	XCTAssertNoThrow(result = js_context.JSEvaluateScript("module.enabled;"));
	XCTAssertTrue(result.IsBoolean());
	XCTAssertFalse(static_cast<bool>(result));

	// Create a listener interested in 'foo' events.
	XCTAssertNoThrow(result = js_context.JSEvaluateScript("function fooEventListener(event){};"));
	XCTAssertTrue(result.IsUndefined());

	// Add the event listener to the native module.
	XCTAssertNoThrow(js_context.JSEvaluateScript("module.addEventListener('foo', fooEventListener);"));

	// The native module should now be enabled since there is a 'foo' event
	// listeners registered.
	XCTAssertNoThrow(result = js_context.JSEvaluateScript("module.enabled;"));
	XCTAssertTrue(result.IsBoolean());
	XCTAssertTrue(static_cast<bool>(result));

	// Now remove the event listener.
	XCTAssertNoThrow(js_context.JSEvaluateScript("module.removeEventListener('foo', fooEventListener);"));

	// The native module should now be disabled since there are no more 'foo'
	// event listeners registered.
	XCTAssertNoThrow(result = js_context.JSEvaluateScript("module.enabled;"));
	XCTAssertTrue(result.IsBoolean());
	XCTAssertFalse(static_cast<bool>(result));

	auto json_result = js_context.JSEvaluateScript("JSON.stringify(Ti.Module);");
	XCTAssertEqual("{}", static_cast<std::string>(json_result));

	json_result = js_context.JSEvaluateScript("JSON.stringify(module);");
	XCTAssertEqual("{\"enabled\":false}", static_cast<std::string>(json_result));
}
开发者ID:cheekiatng,项目名称:titanium_mobile_windows,代码行数:76,代码来源:ModuleTests.cpp

示例13: OnShowPopupMenu

void MenuListener::OnShowPopupMenu(WebView *caller, const WebPopupMenuInfo &menu_info)
{
//	DevMsg("DISABLED FOR TESTING!\n");
//	return;

	//C_WebTab* pWebTab = g_pAnarchyManager->GetWebManager()->GetWebBrowser()->FindWebTab(caller);
	//C_WebTab* pHudWebTab = g_pAnarchyManager->GetWebManager()->GetHudWebTab();
	//WebView* pHudWebView = g_pAnarchyManager->GetWebManager()->GetWebBrowser()->FindWebView(pHudWebTab);

	C_AwesomiumBrowserInstance* pAwesomiumBrowserInstance = g_pAnarchyManager->GetAwesomiumBrowserManager()->FindAwesomiumBrowserInstance(caller);	// FIXME: This should be a general EmbeddedInstance of any type.
	C_AwesomiumBrowserInstance* pHudBrowserInstance = g_pAnarchyManager->GetAwesomiumBrowserManager()->FindAwesomiumBrowserInstance("hud");
	WebView* pHudWebView = pHudBrowserInstance->GetWebView();

	DevMsg("Pop menu detected!\n");

	std::vector<std::string> methodArguments;
	methodArguments.push_back(pAwesomiumBrowserInstance->GetId());
	methodArguments.push_back(VarArgs("%i", menu_info.bounds.x));
	methodArguments.push_back(VarArgs("%i", menu_info.bounds.y));
	methodArguments.push_back(VarArgs("%i", menu_info.bounds.width));
	methodArguments.push_back(VarArgs("%i", menu_info.bounds.height));
	methodArguments.push_back(VarArgs("%i", menu_info.item_height));
	methodArguments.push_back(VarArgs("%f", menu_info.item_font_size));
	methodArguments.push_back(VarArgs("%i", menu_info.selected_item));
	methodArguments.push_back(VarArgs("%i", menu_info.right_aligned));

	for (int i = 0; i < menu_info.items.size(); i++)
	{
		if (menu_info.items[i].type == kWebMenuItemType_Option)
			methodArguments.push_back("Option");
		else if (menu_info.items[i].type == kWebMenuItemType_CheckableOption)
			methodArguments.push_back("CheckableOption");
		else if (menu_info.items[i].type == kWebMenuItemType_Group)
			methodArguments.push_back("Group");
		else if (menu_info.items[i].type == kWebMenuItemType_Separator)
			methodArguments.push_back("Separator");

		methodArguments.push_back(WebStringToCharString(menu_info.items[i].label));
		methodArguments.push_back(WebStringToCharString(menu_info.items[i].tooltip));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].action));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].right_to_left));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].has_directional_override));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].enabled));
		methodArguments.push_back(VarArgs("%i", menu_info.items[i].checked));
	}
	
	std::string objectName = "window.arcadeHud";
	std::string objectMethod = "showPopupMenu";

	JSValue response = pHudWebView->ExecuteJavascriptWithResult(WSLit(objectName.c_str()), WSLit(""));
	if (response.IsObject())
	{
		JSObject object = response.ToObject();
		JSArray arguments;

		for (auto argument : methodArguments)
			arguments.Push(WSLit(argument.c_str()));

		object.InvokeAsync(WSLit(objectMethod.c_str()), arguments);
	}
}
开发者ID:smsithlord,项目名称:AArcade-Source,代码行数:61,代码来源:c_awesomiumlisteners.cpp

示例14:

TEST_F(FileTests, logging)
{
	JSContext js_context = js_context_group.CreateContext(JSExport<Titanium::GlobalObject>::Class());
	auto global_object = js_context.get_global_object();

	XCTAssertFalse(global_object.HasProperty("Titanium"));
	auto Titanium = js_context.CreateObject();
	global_object.SetProperty("Titanium", Titanium, {JSPropertyAttribute::ReadOnly, JSPropertyAttribute::DontDelete});
	XCTAssertTrue(global_object.HasProperty("Titanium"));

	// Make the alias "Ti" for the "Titanium" property.
	XCTAssertFalse(global_object.HasProperty("Ti"));
	global_object.SetProperty("Ti", Titanium, {JSPropertyAttribute::ReadOnly, JSPropertyAttribute::DontDelete});
	XCTAssertTrue(global_object.HasProperty("Ti"));

	XCTAssertFalse(Titanium.HasProperty("Filesystem"));
	auto Filesystem = js_context.CreateObject(JSExport<Titanium::FilesystemModule>::Class());
	Titanium.SetProperty("Filesystem", Filesystem, {JSPropertyAttribute::ReadOnly, JSPropertyAttribute::DontDelete});
	XCTAssertTrue(Titanium.HasProperty("Filesystem"));

	XCTAssertFalse(Filesystem.HasProperty("File"));
	auto File = js_context.CreateObject(JSExport<NativeFileExample>::Class());
	Filesystem.SetProperty("File", File, {JSPropertyAttribute::ReadOnly, JSPropertyAttribute::DontDelete});
	XCTAssertTrue(Filesystem.HasProperty("File"));

	XCTAssertTrue(Filesystem.HasProperty("createTempDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("createTempFile"));
	XCTAssertTrue(Filesystem.HasProperty("getFile"));
	XCTAssertTrue(Filesystem.HasProperty("isExternalStoragePresent"));
	XCTAssertTrue(Filesystem.HasProperty("openStream"));

	XCTAssertTrue(Filesystem.HasProperty("separator"));
	XCTAssertTrue(Filesystem.HasProperty("applicationCacheDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("applicationDataDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("applicationDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("applicationSupportDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("externalStorageDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("lineEnding"));
	XCTAssertTrue(Filesystem.HasProperty("resourcesDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("tempDirectory"));

	XCTAssertTrue(Filesystem.HasProperty("getSeparator"));
	XCTAssertTrue(Filesystem.HasProperty("getApplicationCacheDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getApplicationDataDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getApplicationDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getApplicationSupportDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getExternalStorageDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getLineEnding"));
	XCTAssertTrue(Filesystem.HasProperty("getResourcesDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getTempDirectory"));

	auto File_ptr = File.GetPrivate<NativeFileExample>();
	XCTAssertNotEqual(nullptr, File_ptr);

	JSValue result = js_context.CreateNull();
	XCTAssertNoThrow(result = File.CallAsConstructor(js_context.CreateNull()));
	XCTAssertTrue(result.IsObject());

	JSObject file = static_cast<JSObject>(result);

	XCTAssertTrue(file.HasProperty("executable"));
	XCTAssertTrue(file.HasProperty("hidden"));
	XCTAssertTrue(file.HasProperty("name"));
	XCTAssertTrue(file.HasProperty("nativePath"));
	XCTAssertTrue(file.HasProperty("parent"));
	XCTAssertTrue(file.HasProperty("readonly"));
	XCTAssertTrue(file.HasProperty("remoteBackup"));
	XCTAssertTrue(file.HasProperty("size"));
	XCTAssertTrue(file.HasProperty("symbolicLink"));
	XCTAssertTrue(file.HasProperty("writable"));
	XCTAssertTrue(file.HasProperty("getExecutable"));
	XCTAssertTrue(file.HasProperty("getHidden"));
	XCTAssertTrue(file.HasProperty("getName"));
	XCTAssertTrue(file.HasProperty("getNativePath"));
	XCTAssertTrue(file.HasProperty("getParent"));
	XCTAssertTrue(file.HasProperty("getReadonly"));
	XCTAssertTrue(file.HasProperty("getRemoteBackup"));
	XCTAssertTrue(file.HasProperty("getSize"));
	XCTAssertTrue(file.HasProperty("getSymbolicLink"));
	XCTAssertTrue(file.HasProperty("getWritable"));
	XCTAssertTrue(file.HasProperty("append"));
	XCTAssertTrue(file.HasProperty("copy"));
	XCTAssertTrue(file.HasProperty("createDirectory"));
	XCTAssertTrue(file.HasProperty("createFile"));
	XCTAssertTrue(file.HasProperty("createTimestamp"));
	XCTAssertTrue(file.HasProperty("deleteDirectory"));
	XCTAssertTrue(file.HasProperty("deleteFile"));
	XCTAssertTrue(file.HasProperty("exists"));
	XCTAssertTrue(file.HasProperty("extension"));
	XCTAssertTrue(file.HasProperty("getDirectoryListing"));
	XCTAssertTrue(file.HasProperty("isDirectory"));
	XCTAssertTrue(file.HasProperty("isFile"));
	XCTAssertTrue(file.HasProperty("modificationTimestamp"));
	XCTAssertTrue(file.HasProperty("move"));
	XCTAssertTrue(file.HasProperty("open"));
	XCTAssertTrue(file.HasProperty("read"));
	XCTAssertTrue(file.HasProperty("rename"));
	XCTAssertTrue(file.HasProperty("resolve"));
	XCTAssertTrue(file.HasProperty("spaceAvailable"));
	XCTAssertTrue(file.HasProperty("write"));
//.........这里部分代码省略.........
开发者ID:FokkeZB,项目名称:titanium_mobile_windows,代码行数:101,代码来源:NativeFileTests.cpp

示例15:

TEST_F(FileTests, logging)
{
	JSContext js_context = js_context_group.CreateContext(JSExport<Titanium::GlobalObject>::Class());
	auto global_object = js_context.get_global_object();

	auto Filesystem = js_context.CreateObject(JSExport<Titanium::FilesystemModule>::Class());
	auto File = js_context.CreateObject(JSExport<NativeFileExample>::Class());

	Filesystem.SetProperty("File", File);
	global_object.SetProperty("Filesystem", Filesystem);

	XCTAssertTrue(Filesystem.HasProperty("createTempDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("createTempFile"));
	XCTAssertTrue(Filesystem.HasProperty("getFile"));
	XCTAssertTrue(Filesystem.HasProperty("isExternalStoragePresent"));
	XCTAssertTrue(Filesystem.HasProperty("openStream"));

	XCTAssertTrue(Filesystem.HasProperty("separator"));
	XCTAssertTrue(Filesystem.HasProperty("applicationCacheDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("applicationDataDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("applicationDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("applicationSupportDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("externalStorageDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("lineEnding"));
	XCTAssertTrue(Filesystem.HasProperty("resourcesDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("tempDirectory"));

	XCTAssertTrue(Filesystem.HasProperty("getSeparator"));
	XCTAssertTrue(Filesystem.HasProperty("getApplicationCacheDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getApplicationDataDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getApplicationDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getApplicationSupportDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getExternalStorageDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getLineEnding"));
	XCTAssertTrue(Filesystem.HasProperty("getResourcesDirectory"));
	XCTAssertTrue(Filesystem.HasProperty("getTempDirectory"));

	auto json_result = js_context.JSEvaluateScript("JSON.stringify(Filesystem);");
	XCTAssertTrue(static_cast<std::string>(json_result).find("\"separator\":") != std::string::npos);

	auto File_ptr = File.GetPrivate<NativeFileExample>();
	XCTAssertNotEqual(nullptr, File_ptr);

	JSValue result = js_context.CreateNull();
	XCTAssertNoThrow(result = File.CallAsConstructor(js_context.CreateNull()));
	XCTAssertTrue(result.IsObject());

	JSObject file = static_cast<JSObject>(result);

	XCTAssertTrue(file.HasProperty("executable"));
	XCTAssertTrue(file.HasProperty("hidden"));
	XCTAssertTrue(file.HasProperty("name"));
	XCTAssertTrue(file.HasProperty("nativePath"));
	XCTAssertTrue(file.HasProperty("parent"));
	XCTAssertTrue(file.HasProperty("readonly"));
	XCTAssertTrue(file.HasProperty("remoteBackup"));
	XCTAssertTrue(file.HasProperty("size"));
	XCTAssertTrue(file.HasProperty("symbolicLink"));
	XCTAssertTrue(file.HasProperty("writable"));
	XCTAssertTrue(file.HasProperty("getExecutable"));
	XCTAssertTrue(file.HasProperty("getHidden"));
	XCTAssertTrue(file.HasProperty("getName"));
	XCTAssertTrue(file.HasProperty("getNativePath"));
	XCTAssertTrue(file.HasProperty("getParent"));
	XCTAssertTrue(file.HasProperty("getReadonly"));
	XCTAssertTrue(file.HasProperty("getRemoteBackup"));
	XCTAssertTrue(file.HasProperty("getSize"));
	XCTAssertTrue(file.HasProperty("getSymbolicLink"));
	XCTAssertTrue(file.HasProperty("getWritable"));
	XCTAssertTrue(file.HasProperty("append"));
	XCTAssertTrue(file.HasProperty("copy"));
	XCTAssertTrue(file.HasProperty("createDirectory"));
	XCTAssertTrue(file.HasProperty("createFile"));
	XCTAssertTrue(file.HasProperty("createTimestamp"));
	XCTAssertTrue(file.HasProperty("deleteDirectory"));
	XCTAssertTrue(file.HasProperty("deleteFile"));
	XCTAssertTrue(file.HasProperty("exists"));
	XCTAssertTrue(file.HasProperty("extension"));
	XCTAssertTrue(file.HasProperty("getDirectoryListing"));
	XCTAssertTrue(file.HasProperty("isDirectory"));
	XCTAssertTrue(file.HasProperty("isFile"));
	XCTAssertTrue(file.HasProperty("modificationTimestamp"));
	XCTAssertTrue(file.HasProperty("move"));
	XCTAssertTrue(file.HasProperty("open"));
	XCTAssertTrue(file.HasProperty("read"));
	XCTAssertTrue(file.HasProperty("rename"));
	XCTAssertTrue(file.HasProperty("resolve"));
	XCTAssertTrue(file.HasProperty("spaceAvailable"));
	XCTAssertTrue(file.HasProperty("write"));

	global_object.SetProperty("file", file);
	json_result = js_context.JSEvaluateScript("JSON.stringify(file);");
	XCTAssertTrue(static_cast<std::string>(json_result).find("\"symbolicLink\":") != std::string::npos);
}
开发者ID:appcelerator-forks,项目名称:appcelerator.titanium_mobile_windows,代码行数:94,代码来源:NativeFileTests.cpp


注:本文中的JSValue::IsObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。