void UIBinding::_GetOpenWindows(const ValueList& args, SharedValue result)
	{
		SharedKList list = new StaticBoundList();
		std::vector<AutoUserWindow>::iterator w = openWindows.begin();
		while (w != openWindows.end()) {
			list->Append(Value::NewObject(*w++));
		}
		result->SetList(list);
	}
Example #2
0
	void HostBinding::GetAliases(const ValueList& args, SharedValue result)
	{
		SharedBoundList list = new StaticBoundList();
		std::vector<std::string> aliases = this->host.aliases();
		std::vector<std::string>::iterator iter = aliases.begin();
		while (iter!=aliases.end())
		{
			std::string alias = (*iter++);
			list->Append(Value::NewString(alias));
		}
		result->SetList(list);
	}
	void AppBinding::GetArguments(const ValueList& args, SharedValue result)
	{
		static SharedKList argList(0);
		if (argList.isNull())
		{
			// Skip the first argument which is the filename to the executable
			argList = new StaticBoundList();
			for (int i = 1; i < host->GetCommandLineArgCount(); i++)
				argList->Append(Value::NewString(host->GetCommandLineArg(i)));
		}

		result->SetList(argList);
	}
Example #4
0
	void HostBinding::GetAddresses(const ValueList& args, SharedValue result)
	{
		SharedBoundList list = new StaticBoundList();
		std::vector<IPAddress> addresses = this->host.addresses();
		std::vector<IPAddress>::iterator iter = addresses.begin();
		while (iter!=addresses.end())
		{
			IPAddress address = (*iter++);
			SharedBoundObject obj = new IPAddressBinding(address);
			SharedValue addr = Value::NewObject(obj);
			list->Append(addr);
		}
		result->SetList(list);
	}
	void IRCClientBinding::GetUsers(const ValueList& args, SharedValue result)
	{
		const char *channel = args.at(0)->ToString();
		SharedKList list = new StaticBoundList();
		channel_user* cu = irc.get_users();
		while(cu)
		{
			if (!strcmp(cu->channel,(char*)channel) && cu->nick && strlen(cu->nick)>0)
			{
				SharedKObject entry = new StaticBoundObject();
				entry->Set("name",Value::NewString(cu->nick));
				entry->Set("operator",Value::NewBool(cu->flags & IRC_USER_OP));
				entry->Set("voice",Value::NewBool(cu->flags & IRC_USER_VOICE));
				list->Append(Value::NewObject(entry));
			}
			cu = cu->next;
		}
		result->SetList(list);
	}
Example #6
0
	void Blob::Split(const ValueList& args, SharedValue result)
	{
		// This method now follows the spec located at:
		// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/split
		// Except support for regular expressions
		args.VerifyException("Blob.split", "?s,i");

		SharedKList list = new StaticBoundList();
		result->SetList(list);

		std::string target = "";
		if (this->length > 0)
		{
			target = this->buffer;
		}
		else
		{
			list->Append(Value::NewString(target));
			return;
		}

		if (args.size() <= 0)
		{
			list->Append(Value::NewString(target));
			return;
		}

		std::string separator = args.GetString(0);
		int limit = INT_MAX;
		if (args.size() > 1)
		{
			limit = args.GetInt(1);
		}

		// We could use Poco's tokenizer here, but it doesn't split strings
		// like "abc,def,," -> ['abc', 'def', '', ''] correctly. It produces
		// ['abc', 'def', ''] which is a different behavior than the JS split.
		// So we roll our own for now -- it's not very efficient right now, but
		// it should be correct.
		size_t next = target.find(separator);
		while (target.size() > 0 && next != std::string::npos)
		{
			std::string token;
			if (separator.size() == 0)
			{
				token = target.substr(0, 1);
			}
			else
			{
				token = target.substr(0, next);
			}
			target = target.substr(next + 1);
			next = target.find(separator);

			if ((int) list->Size() >= limit)
				return;

			list->Append(Value::NewString(token));
		}

		if ((int) list->Size() < limit && separator.size() != 0)
			list->Append(Value::NewString(target));
	}
Example #7
0
	void ComponentBinding::_GetManifest(const ValueList& args, SharedValue result)
	{
		vector<pair<string, string> > manifest = this->component->ReadManifest();
		SharedKList manifestList = APIBinding::ManifestToKList(manifest);
		result->SetList(manifestList);
	}