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


C++ KObjectRef::GetMethod方法代码示例

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


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

示例1: Log

	void UIBinding::Log(Logger::Level level, std::string& message)
	{
		if (level > Logger::LWARN)
			return;

		std::string methodName("warn");
		if (level < Logger::LWARN)
			methodName = "error";

		std::string origMethodName(methodName);
		origMethodName.append("_orig");

		std::vector<AutoUserWindow>& openWindows = UIBinding::GetInstance()->GetOpenWindows();
		for (size_t i = 0; i < openWindows.size(); i++)
		{
			KObjectRef domWindow = openWindows[i]->GetDOMWindow();
			if (domWindow.isNull())
				continue;

			KObjectRef console = domWindow->GetObject("console", 0);
			if (console.isNull())
				continue;

			KMethodRef method = console->GetMethod(origMethodName.c_str(), 0);
			if (method.isNull())
				method = console->GetMethod(methodName.c_str(), 0);

			RunOnMainThread(method, ValueList(Value::NewString(message)), false);
		}
	}
开发者ID:ksmythe,项目名称:titanium_desktop,代码行数:30,代码来源:ui_binding.cpp

示例2: Evaluate

	KValueRef Script::Evaluate(const char *mimeType, const char *name, const char *code, KObjectRef scope)
	{
		KObjectRef evaluator = this->FindEvaluatorWithMethod("canEvaluate", mimeType);
		if (!evaluator.isNull())
		{
			KMethodRef evaluate = evaluator->GetMethod("evaluate");
			if (!evaluate.isNull())
			{
				ValueList args;
				args.push_back(Value::NewString(mimeType));
				args.push_back(Value::NewString(name));
				args.push_back(Value::NewString(code));
				args.push_back(Value::NewObject(scope));
				return evaluate->Call(args);
			}
			else
			{
				throw ValueException::FromFormat(
					"Error evaluating: No \"evaluate\" method found on evaluator for mimeType: \"%s\"", mimeType);
			}
		}
		else
		{
			throw ValueException::FromFormat("Error evaluating: No evaluator found for mimeType: \"%s\"", mimeType);
		}
	}
开发者ID:mital,项目名称:kroll,代码行数:26,代码来源:script.cpp

示例3: Configure

void Notification::Configure(KObjectRef properties)
{
	this->title = properties->GetString("title");
	this->message = properties->GetString("message");
	this->iconURL = properties->GetString("icon");
	this->timeout = properties->GetInt("timeout", -1);
	this->clickedCallback = properties->GetMethod("callback");
}
开发者ID:Val9,项目名称:titanium_desktop,代码行数:8,代码来源:notification.cpp

示例4: _GetHostByAddress

void Network::_GetHostByAddress(const ValueList& args, KValueRef result)
{
    if (args.at(0)->IsObject())
    {
        KObjectRef obj = args.at(0)->ToObject();
        AutoPtr<IPAddress> b = obj.cast<IPAddress>();
        if (!b.isNull())
        {
            // in this case, they've passed us an IPAddressBinding
            // object, which we can just retrieve the ipaddress
            // instance and resolving using it
            Poco::Net::IPAddress addr(b->GetAddress()->toString());
            AutoPtr<Host> binding = new Host(addr);
            if (binding->IsInvalid())
            {
                throw ValueException::FromString("Could not resolve address");
            }
            result->SetObject(binding);
            return;
        }
        else
        {
            KMethodRef toStringMethod = obj->GetMethod("toString");
            if (toStringMethod.isNull())
                throw ValueException::FromString("Unknown object passed");

            result->SetObject(GetHostBinding(toStringMethod->Call()->ToString()));
            return;
        }
    }
    else if (args.at(0)->IsString())
    {
        // in this case, they just passed in a string so resolve as normal
        result->SetObject(GetHostBinding(args.GetString(0)));
    }
}
开发者ID:finglish,项目名称:titanium_desktop,代码行数:36,代码来源:Network.cpp

示例5: if

	AutoPtr<PreprocessData> Script::Preprocess(const char *url, KObjectRef scope)
	{
		KObjectRef evaluator = this->FindEvaluatorWithMethod("canPreprocess", url);
		if (!evaluator.isNull())
		{
			KMethodRef preprocess = evaluator->GetMethod("preprocess");
			if (!preprocess.isNull())
			{
				ValueList args;
				args.push_back(Value::NewString(url));
				args.push_back(Value::NewObject(scope));
				
				KValueRef result = preprocess->Call(args);
				
				if (result->IsObject())
				{
					KObjectRef object = result->ToObject();
					AutoPtr<PreprocessData> data = new PreprocessData();
					if (object->HasProperty("data"))
					{
						KValueRef objectData = object->Get("data");
						if (objectData->IsObject())
						{
							BlobRef blobData = objectData->ToObject().cast<Blob>();
							if (!blobData.isNull())
							{
								data->data = blobData;
							}
						}
						else if (objectData->IsString())
						{
							data->data = new Blob(objectData->ToString(), strlen(objectData->ToString()));
						}
					}
					else
					{
						throw ValueException::FromString("Preprocessor didn't return any data");
					}
					if (object->HasProperty("mimeType"))
					{
						data->mimeType = object->Get("mimeType")->ToString();
					}
					else
					{
						throw ValueException::FromString("Preprocessor didn't return a mimeType");
					}
					
					return data;
				}
			}
			else
			{
				throw ValueException::FromFormat(
					"Error preprocessing: No \"preprocess\" method found on evaluator for url: \"%s\"", url);
			}
		}
		else
		{
			throw ValueException::FromFormat("Error preprocessing: No evaluator found for url: \"%s\"", url);
		}
		return 0;
	}
开发者ID:mital,项目名称:kroll,代码行数:62,代码来源:script.cpp

示例6: BeginRequest

	bool HTTPClientBinding::BeginRequest(KValueRef sendData)
	{
		if (this->Get("connected")->ToBool())
		{
			return false;
		}

		// Reset internal variables for new request
		if (this->dirty)
		{
			this->Reset();
		}

		// Determine what data type we have to send
		if (sendData->IsObject())
		{
			KObjectRef dataObject = sendData->ToObject();
			KMethodRef nativePathMethod(dataObject->GetMethod("nativePath"));
			KMethodRef sizeMethod(dataObject->GetMethod("size"));

			if (nativePathMethod.isNull() || sizeMethod.isNull())
			{
				std::string err("Unsupported File-like object: did not have"
					"nativePath and size methods");
				logger->Error(err);
				throw ValueException::FromString(err);
			}

			const char* filename = nativePathMethod->Call()->ToString();
			if (!filename)
			{
				std::string err("Unsupported File-like object: nativePath method"
					"did not return a String");
				logger->Error(err);
				throw ValueException::FromString(err);
			}

			this->datastream = new std::ifstream(filename,
				std::ios::in | std::ios::binary);
			if (this->datastream->fail())
			{
				std::string err("Failed to open file: ");
				err.append(filename);
				logger->Error(err);
				throw ValueException::FromString(err);
			}

			this->contentLength = sizeMethod->Call()->ToInt();
		}
		else if (sendData->IsString())
		{
			std::string dataString(sendData->ToString());
			if (!dataString.empty())
			{
				this->datastream = new std::istringstream(dataString,
						std::ios::in | std::ios::binary);
				this->contentLength = dataString.length();
			}
		}
		else
		{
			// Sending no data
			this->datastream = 0;
		}

		this->dirty = true;
		this->Set("connected", Value::NewBool(true));

		if (this->async)
		{
			this->thread = new Poco::Thread();
			this->thread->start(*this);
		}
		else
		{
			this->ExecuteRequest();
		}

		return true;
	}
开发者ID:mital,项目名称:titanium_desktop,代码行数:80,代码来源:http_client_binding.cpp


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