本文整理汇总了C++中JSArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ JSArray::size方法的具体用法?C++ JSArray::size怎么用?C++ JSArray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSArray
的用法示例。
在下文中一共展示了JSArray::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void UserInterface::JavaScriptHandler::OnMethodCall( WebView* caller, unsigned int remoteObjectID, const WebString& methodName, const JSArray& args )
{
// If called on GraphosGame
if( remoteObjectID == owner->graphosGame.remote_id() )
{
if( methodName == WSLit( "ChangeState" ) && args.size() == 1 )
{
if( args[ 0 ].ToString() == WSLit( "Game" ) )
owner->owner->ChangeState( Game );
else if( args[ 0 ].ToString() == WSLit( "Menu" ) )
owner->owner->ChangeState( Menu );
}
else if( methodName == WSLit( "SetConfig" ) && args.size() == 2 )
{
if( args[ 1 ].IsBoolean() )
Config::Get().SetData( ToString( args[ 0 ].ToString() ), args[ 1 ].ToBoolean() );
else if( args[ 1 ].IsInteger() )
Config::Get().SetData( ToString( args[ 0 ].ToString() ), args[ 1 ].ToInteger() );
else if( args[ 1 ].IsDouble() )
Config::Get().SetData( ToString( args[ 0 ].ToString() ), static_cast<float>( args[ 1 ].ToDouble() ) );
else if( args[ 1 ].IsString() )
Config::Get().SetData( ToString( args[ 0 ].ToString() ), ToString( args[ 1 ].ToString() ) );
}
else if( methodName == WSLit( "Reset" ) && args.size() == 0 )
{
owner->owner->currentState = Reseting;
}
}
}
示例2: Handle
JSValue IrcExtension::Handle(
const std::string &functionName,
const JSArray &args)
{
// connect(channelName)
if (functionName == "connect") {
// were in the middle of something
if (irc_is_connected(session)) {
return JSValue::Undefined();
}
if (hThread) {
// thread finished?
if (WaitForSingleObject(hThread, 0) == WAIT_OBJECT_0) {
CloseHandle(hThread);
hThread = NULL;
} else {
// thread is still running
return JSValue::Undefined();
}
}
if (args.size() < 1 || !args[0].IsString()) {
// TODO: log this and exit
return JSValue::Undefined();
}
channelName = ToString(args[0].ToString());
serverName = channelName + ".jtvirc.com";
port = 6667;
if (args.size() >= 2) {
if (!(args[1].IsString())) {
// log error
return JSValue::Undefined();
}
serverName = ToString(args[1].ToString());
}
if (args.size() == 3) {
if (!args[2].IsInteger()) {
// log error
return JSValue::Undefined();
}
port = (unsigned int)args[2].ToInteger();
}
isJoinedChannel = false;
hThread = (HANDLE)_beginthreadex(NULL, 0, &IrcThread, this, 0, NULL);
return JSValue::Undefined();
} else if (functionName == "disconnect") { // disconnect()
if (args.size() != 0) {
// TODO: log invalid method call
return JSValue::Undefined();
}
irc_disconnect(session);
if (hThread) {
WaitForSingleObject( hThread, INFINITE );
CloseHandle(hThread);
hThread = NULL;
}
isJoinedChannel = false;
moderators.clear();
latestMessage.Clear();
EnterCriticalSection(&messageLock);
messages.clear();
LeaveCriticalSection(&messageLock);
return JSValue::Undefined();
} else if (functionName == "getMessages") { // [message, message, ..] getMessages()
EnterCriticalSection(&messageLock);
if (args.size() != 0) {
// TODO: log invalid method call
return JSValue::Undefined();
}
JSArray returnArgs;
while(messages.size()) {
IrcMessage &message = messages[0];
JSObject newMessageObject;
newMessageObject.SetProperty(WSLit("nickname"), ToWebString(message.username));
newMessageObject.SetProperty(WSLit("message"), ToWebString(message.message));
newMessageObject.SetProperty(WSLit("color"), ToWebString(message.color));
JSArray groups;
for(auto i = message.groups.begin(); i != message.groups.end(); i++) {
//.........这里部分代码省略.........