本文整理汇总了C++中MOAILuaState::GetField方法的典型用法代码示例。如果您正苦于以下问题:C++ MOAILuaState::GetField方法的具体用法?C++ MOAILuaState::GetField怎么用?C++ MOAILuaState::GetField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOAILuaState
的用法示例。
在下文中一共展示了MOAILuaState::GetField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: arrayFromLua
/**
* Create a jobjectArray from the Lua stack
* @param lua_state The lua Stack
* @param index The index to convert
*/
jobjectArray JniUtils::arrayFromLua ( lua_State* L, int index ) {
MOAILuaState state ( L );
JNI_GET_ENV ( jvm, env );
int numEntries = 0;
for ( int key = 1; ; ++key ) {
state.GetField ( 1, key );
cc8* value = JniUtils::parseLuaTable ( state, -1 );
lua_pop ( state, 1 );
if ( !value ) {
numEntries = key - 1;
break;
}
}
jobjectArray array = env->NewObjectArray ( numEntries, env->FindClass( "java/lang/String" ), 0 );
for ( int key = 1; ; ++key ) {
state.GetField ( 1, key );
cc8* value = JniUtils::parseLuaTable ( state, -1 );
lua_pop ( state, 1 );
if ( value ) {
JNI_GET_JSTRING ( value, jvalue );
env->SetObjectArrayElement ( array, key - 1, jvalue );
}
else {
break;
}
}
return array;
}
示例2: SerializeIn
//----------------------------------------------------------------//
void MOAIGlyphSet::SerializeIn ( MOAILuaState& state ) {
UNUSED ( state );
this->mSize = state.GetField ( -1, "mSize", this->mSize );
this->mHeight = state.GetField ( -1, "mHeight", this->mHeight );
this->mAscent = state.GetField ( -1, "mAscent", this->mAscent );
if ( state.GetFieldWithType ( -1, "mGlyphMap", LUA_TTABLE )) {
u32 itr = state.PushTableItr ( -1 );
while ( state.TableItrNext ( itr )) {
u32 c = state.GetValue < u32 >( -2, 0 );
MOAIGlyph& glyph = this->mGlyphMap [ c ];
glyph.SerializeIn ( state );
}
state.Pop ( 1 );
}
GlyphMapIt glyphMapIt = this->mGlyphMap.begin ();
for ( ; glyphMapIt != this->mGlyphMap.end (); ++glyphMapIt ) {
MOAIGlyph& glyph = glyphMapIt->second;
if ( glyph.mPageID == MOAIGlyph::NULL_PAGE_ID ) {
glyph.mNext = this->mPending;
this->mPending = &glyph;
}
else {
glyph.mNext = this->mGlyphs;
this->mGlyphs = &glyph;
}
}
}
示例3: SerializeIn
//----------------------------------------------------------------//
void MOAIGlyph::SerializeIn ( MOAILuaState& state ) {
this->mCode = state.GetField ( -1, "mCode", this->mCode );
this->mPageID = state.GetField ( -1, "mPageID", this->mPageID );
this->mWidth = state.GetField ( -1, "mWidth", this->mWidth );
this->mHeight = state.GetField ( -1, "mHeight", this->mHeight );
this->mAdvanceX = state.GetField ( -1, "mAdvanceX", this->mAdvanceX );
this->mBearingX = state.GetField ( -1, "mBearingX", this->mBearingX );
this->mBearingY = state.GetField ( -1, "mBearingY", this->mBearingY );
this->mSrcX = state.GetField ( -1, "mSrcX", this->mSrcX );
this->mSrcY = state.GetField ( -1, "mSrcY", this->mSrcY );
if ( state.GetFieldWithType ( -1, "mKernTable", LUA_TTABLE )) {
u32 size = lua_objlen ( state, -1 );
this->mKernTable.Init ( size );
for ( u32 i = 0; i < size; ++i ) {
if ( state.GetFieldWithType ( -1, i + 1, LUA_TTABLE )) {
this->mKernTable [ i ].mName = state.GetField ( -1, "mName", 0 );
this->mKernTable [ i ].mX = state.GetField ( -1, "mX", 0.0f );
this->mKernTable [ i ].mY = state.GetField ( -1, "mY", 0.0f );
}
state.Pop ( 1 );
}
state.Pop ( 1 );
}
}
示例4: _luaToJSONArray
//----------------------------------------------------------------//
json_t* _luaToJSONArray ( lua_State* L, int idx ) {
MOAILuaState state ( L );
json_t* arr = json_array ();
bool more = true;
for ( int key = 1; more; ++key ) {
state.GetField ( idx, key );
json_t* value = _luaToJSON ( state, -1 );
lua_pop ( state, 1 );
if ( value && value->type != JSON_NULL ) {
json_array_append_new ( arr, value );
}
else {
more = false;
}
}
return arr;
}
示例5: _init
/** @name init
@text Initialize AdColony.
@in string appId Available in AdColony dashboard settings.
@in table zones A list of zones to configure. Available in AdColony dashboard settings.
@out nil
*/
int MOAIAdColonyAndroid::_init ( lua_State* L ) {
MOAILuaState state ( L );
cc8* identifier = lua_tostring ( state, 1 );
JNI_GET_ENV ( jvm, env );
JNI_GET_JSTRING ( identifier, jidentifier );
jobjectArray jzones = NULL;
if ( state.IsType ( 2, LUA_TTABLE )) {
int numEntries = 0;
for ( int key = 1; ; ++key ) {
state.GetField ( 2, key );
cc8* value = _luaParseTable ( state, -1 );
lua_pop ( state, 1 );
if ( !value ) {
numEntries = key - 1;
break;
}
}
jzones = env->NewObjectArray ( numEntries, env->FindClass( "java/lang/String" ), 0 );
for ( int key = 1; ; ++key ) {
state.GetField ( 2, key );
cc8* value = _luaParseTable ( state, -1 );
lua_pop ( state, 1 );
if ( value ) {
JNI_GET_JSTRING ( value, jvalue );
env->SetObjectArrayElement ( jzones, key - 1, jvalue );
}
else {
break;
}
}
}
if ( jzones == NULL ) {
jzones = env->NewObjectArray ( 0, env->FindClass( "java/lang/String" ), 0 );
}
jclass adcolony = env->FindClass ( "com/ziplinegames/moai/MoaiAdColony" );
if ( adcolony == NULL ) {
ZLLog::Print ( "MOAIAdColonyAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiAdColony" );
} else {
jmethodID init = env->GetStaticMethodID ( adcolony, "init", "(Ljava/lang/String;[Ljava/lang/String;)V" );
if ( init == NULL ) {
ZLLog::Print ( "MOAIAdColonyAndroid: Unable to find static java method %s", "init" );
} else {
env->CallStaticVoidMethod ( adcolony, init, jidentifier, jzones );
}
}
return 0;
}
示例6: _login
/** @name login
@text Prompt the user to login to Facebook.
@opt table permissions Optional set of required permissions. See Facebook documentation for a full list. Default is nil.
@out nil
*/
int MOAIFacebookAndroid::_login ( lua_State *L ) {
MOAILuaState state ( L );
JNI_GET_ENV ( jvm, env );
jobjectArray jpermissions = NULL;
if ( state.IsType ( 1, LUA_TTABLE )) {
int numEntries = 0;
for ( int key = 1; ; ++key ) {
state.GetField ( 1, key );
cc8* value = _luaParseTable ( state, -1 );
lua_pop ( state, 1 );
if ( !value ) {
numEntries = key - 1;
break;
}
}
jpermissions = env->NewObjectArray ( numEntries, env->FindClass( "java/lang/String" ), 0 );
for ( int key = 1; ; ++key ) {
state.GetField ( 1, key );
cc8* value = _luaParseTable ( state, -1 );
lua_pop ( state, 1 );
if ( value ) {
JNI_GET_JSTRING ( value, jvalue );
env->SetObjectArrayElement ( jpermissions, key - 1, jvalue );
}
else {
break;
}
}
}
if ( jpermissions == NULL ) {
jpermissions = env->NewObjectArray ( 0, env->FindClass( "java/lang/String" ), 0 );
}
jclass facebook = env->FindClass ( "com/ziplinegames/moai/MoaiFacebook" );
if ( facebook == NULL ) {
ZLLog::Print ( "MOAIFacebookAndroid: Unable to find java class %s", "com/ziplinegames/moai/MoaiFacebook" );
} else {
jmethodID login = env->GetStaticMethodID ( facebook, "login", "([Ljava/lang/String;)V" );
if ( login == NULL ) {
ZLLog::Print ( "MOAIFacebookAndroid: Unable to find static java method %s", "login" );
} else {
env->CallStaticVoidMethod ( facebook, login, jpermissions );
}
}
return 0;
}