示例#1
0
    void APIBinding::_CreateDependency(const ValueList& args, KValueRef result)
    {
        args.VerifyException("createDepenendency", "i,s,s,?i");
        int type = args.GetInt(0, UNKNOWN);
        string name = args.GetString(1);
        string version = args.GetString(2);
        int requirement = (int) args.GetNumber(3, Dependency::EQ);

        if (type != MODULE && type != RUNTIME
            && type != SDK && type != MOBILESDK
            && type != APP_UPDATE)
        {
            throw ValueException::FromString(
                "Tried to create a dependency with an unknown dependency type");
        }
        else if (requirement != Dependency::EQ
            && requirement != Dependency::GT
            && requirement != Dependency::LT
            && requirement != Dependency::GTE
            && requirement != Dependency::LTE)
        {
            throw ValueException::FromString(
                "Tried to create a dependency with an unknown requirement type");
        }
        else
        {
            SharedDependency d = Dependency::NewDependencyFromValues(
                static_cast<KComponentType>(type), name, version);
            KObjectRef dBinding = new DependencyBinding(d);
            result->SetObject(dBinding);
        }
    }
示例#2
0
文件: blob.cpp 项目: jonnymind/kroll
	void Blob::LastIndexOf(const ValueList& args, SharedValue result)
	{
		// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/lastIndexOf
		args.VerifyException("Blob.lastIndexOf", "s,?i");

		if (this->length <= 0)
		{
			result->SetInt(-1);
		}
		else
		{
			std::string target = this->buffer;
			std::string needle = args.at(0)->ToString();
			int start = target.size() + 1;
			if (args.size() > 1)
			{
				start = args.GetNumber(1);
				if (start < 0)
				{
					start = 0;
				}
			}
			result->SetInt(target.rfind(needle, start));
		}
	}
示例#3
0
 void TCPSocket::_SetTimeout(const ValueList& args, KValueRef result)
 {
     args.VerifyException("setTimeout", "n");
     SetTimeout((long)args.GetNumber(0));
 }