本文整理匯總了Java中org.luaj.vm2.LuaValue.valueOf方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.valueOf方法的具體用法?Java LuaValue.valueOf怎麽用?Java LuaValue.valueOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.luaj.vm2.LuaValue
的用法示例。
在下文中一共展示了LuaValue.valueOf方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getView
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// LogUtil.d("yesong", position, convertView, getItemViewType(position), getViewTypeCount());
//數據封裝
UDLuaTable cellData = null;
final int viewType = getItemViewType(position);
final boolean hasCellSize = this.mLuaUserData.hasCellSize(position);
if (convertView == null || ((UDLuaTable) convertView.getTag()).get(KEY_VIEW_TYPE) != LuaValue.valueOf(viewType)) {//在內部創建好Cell
UDView layout = new UDViewGroup(createLayout(), mGlobals, null);//TODO 為什麽用mLuaUserData.getmetatable()不行
//對外數據封裝,必須使用LuaTable
cellData = new UDLuaTable(layout);
//View封裝
if (hasCellSize) {//有Size的定義
final LVViewGroup cellView = createLayout();
View tmp = layout.getView();
if(tmp != null) {
cellView.addView(tmp);
}
convertView = cellView;
} else {
convertView = layout.getView();
}
initView(cellData, position);
convertView.setTag(cellData);
} else {
cellData = (UDLuaTable) convertView.getTag();
}
//更新position
cellData.set(KEY_VIEW_TYPE, viewType);
if (hasCellSize) {//有Size的定義,每次更新size
initCellSize(cellData, position);//TODO 需要動態更新View的Size,需要在這裏調用,否則移動到初始化的時候。這個暫時先去掉,會有問題,複用有問題
}
//繪製數據
renderView(cellData, position);
return convertView;
}
示例2: toLuaValue
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* convert object to LuaValue
*
* @param value
* @return
*/
public static LuaValue toLuaValue(Object value) {
try {
if (value instanceof Integer) {
return LuaValue.valueOf((Integer) value);
} else if (value instanceof Long) {
return LuaValue.valueOf((Long) value);
} else if (value instanceof Double) {
return LuaValue.valueOf((Double) value);
} else if (value instanceof String) {
return LuaValue.valueOf((String) value);
} else if (value instanceof Boolean) {
return LuaValue.valueOf((Boolean) value);
} else if (value instanceof byte[]) {
return LuaValue.valueOf((byte[]) value);
} else if (value instanceof List) {
return toTable((List) value);
} else if (value instanceof Map) {
return toTable((Map) value);
} else {
return CoerceJavaToLua.coerce(value);
}
} catch (Exception e) {
e.printStackTrace();
return LuaValue.NIL;
}
}
示例3: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public LuaValue call(LuaValue gsl1, LuaValue gsl2, LuaValue gsl3) {
int x = gsl1.checkint();
int y = gsl2.checkint();
int z = gsl3.checkint();
return LuaValue.valueOf(world.getSunLight(x, y, z));
}
示例4: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public LuaValue call(LuaValue arg1, LuaValue arg2, LuaValue arg3) {
int x = arg1.checkint();
int y = arg2.checkint();
int z = arg3.checkint();
return LuaValue.valueOf(world.getSunLight(x, y, z));
}
示例5: str2d
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
boolean str2d(String str, SemInfo seminfo) {
if (str.indexOf('n')>=0 || str.indexOf('N')>=0)
seminfo.r = LuaValue.ZERO;
else if (str.indexOf('x')>=0 || str.indexOf('X')>=0)
seminfo.r = strx2number(str, seminfo);
else
seminfo.r = LuaValue.valueOf(Double.parseDouble(str.trim()));
return true;
}
示例6: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public final LuaValue call() {
return LuaValue.valueOf(System.currentTimeMillis());
}
示例7: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue u) {
return LuaValue.valueOf(Array.getLength(((LuaUserdata)u).m_instance));
}
示例8: coerce
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue coerce( Object javaValue ) {
return LuaValue.valueOf((byte[]) javaValue);
}
示例9: strx2number
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
LuaValue strx2number(String str, SemInfo seminfo) {
char[] c = str.toCharArray();
int s = 0;
while ( s < c.length && isspace(c[s]))
++s;
// Check for negative sign
double sgn = 1.0;
if (s < c.length && c[s] == '-') {
sgn = -1.0;
++s;
}
/* Check for "0x" */
if (s + 2 >= c.length )
return LuaValue.ZERO;
if (c[s++] != '0')
return LuaValue.ZERO;
if (c[s] != 'x' && c[s] != 'X')
return LuaValue.ZERO;
++s;
// read integer part.
double m = 0;
int e = 0;
while (s < c.length && isxdigit(c[s]))
m = (m * 16) + hexvalue(c[s++]);
if (s < c.length && c[s] == '.') {
++s; // skip dot
while (s < c.length && isxdigit(c[s])) {
m = (m * 16) + hexvalue(c[s++]);
e -= 4; // Each fractional part shifts right by 2^4
}
}
if (s < c.length && (c[s] == 'p' || c[s] == 'P')) {
++s;
int exp1 = 0;
boolean neg1 = false;
if (s < c.length && c[s] == '-') {
neg1 = true;
++s;
}
while (s < c.length && isdigit(c[s]))
exp1 = exp1 * 10 + c[s++] - '0';
if (neg1)
exp1 = -exp1;
e += exp1;
}
return LuaValue.valueOf(sgn * m * MathLib.dpow_d(2.0, e));
}
示例10: toLua
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public LuaValue toLua(Character character) {
return LuaValue.valueOf(character);
}
示例11: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public LuaValue call() {
return LuaValue.valueOf(Branding.VERSION_MAJOR_MINOR_POINT);
}
示例12: toLuaBoolean
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public static LuaValue toLuaBoolean(boolean value) {
return LuaValue.valueOf(value);
}
示例13: toLua
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public LuaValue toLua(String s) {
return LuaValue.valueOf(s);
}
示例14: toLuaInt
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* lua 都是從1開始
*
* @param pos
* @return
*/
public static LuaValue toLuaInt(Integer pos) {
return pos != null ? LuaValue.valueOf(pos + 1) : LuaValue.NIL;
}