Improve get name for func.
This commit is contained in:
@@ -74,10 +74,13 @@ public class LuaFunction extends LuaValue {
|
|||||||
|
|
||||||
/** Return the last part of the class name, to be used as a function name in tojstring and elsewhere.
|
/** Return the last part of the class name, to be used as a function name in tojstring and elsewhere.
|
||||||
* @return String naming the last part of the class name after the last dot (.) or dollar sign ($).
|
* @return String naming the last part of the class name after the last dot (.) or dollar sign ($).
|
||||||
|
* If the first character is '_', it is skipped.
|
||||||
*/
|
*/
|
||||||
public String classnamestub() {
|
public String classnamestub() {
|
||||||
String s = getClass().getName();
|
String s = getClass().getName();
|
||||||
return s.substring(Math.max(s.lastIndexOf('.'),s.lastIndexOf('$'))+1);
|
int offset = Math.max(s.lastIndexOf('.'), s.lastIndexOf('$')) + 1;
|
||||||
|
if (s.charAt(offset) == '_') offset++;
|
||||||
|
return s.substring(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a human-readable name for this function. Returns the last part of the class name by default.
|
/** Return a human-readable name for this function. Returns the last part of the class name by default.
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ public class StringLib extends TwoArgFunction {
|
|||||||
*/
|
*/
|
||||||
public LuaValue call(LuaValue modname, LuaValue env) {
|
public LuaValue call(LuaValue modname, LuaValue env) {
|
||||||
LuaTable string = new LuaTable();
|
LuaTable string = new LuaTable();
|
||||||
string.set("byte", new byte_());
|
string.set("byte", new _byte());
|
||||||
string.set("char", new char_());
|
string.set("char", new _char());
|
||||||
string.set("dump", new dump());
|
string.set("dump", new dump());
|
||||||
string.set("find", new find());
|
string.set("find", new find());
|
||||||
string.set("format", new format());
|
string.set("format", new format());
|
||||||
@@ -117,7 +117,7 @@ public class StringLib extends TwoArgFunction {
|
|||||||
*
|
*
|
||||||
* @param args the calling args
|
* @param args the calling args
|
||||||
*/
|
*/
|
||||||
static final class byte_ extends VarArgFunction {
|
static final class _byte extends VarArgFunction {
|
||||||
public Varargs invoke(Varargs args) {
|
public Varargs invoke(Varargs args) {
|
||||||
LuaString s = args.checkstring(1);
|
LuaString s = args.checkstring(1);
|
||||||
int l = s.m_length;
|
int l = s.m_length;
|
||||||
@@ -148,7 +148,7 @@ public class StringLib extends TwoArgFunction {
|
|||||||
*
|
*
|
||||||
* @param args the calling VM
|
* @param args the calling VM
|
||||||
*/
|
*/
|
||||||
static final class char_ extends VarArgFunction {
|
static final class _char extends VarArgFunction {
|
||||||
public Varargs invoke(Varargs args) {
|
public Varargs invoke(Varargs args) {
|
||||||
int n = args.narg();
|
int n = args.narg();
|
||||||
byte[] bytes = new byte[n];
|
byte[] bytes = new byte[n];
|
||||||
|
|||||||
Reference in New Issue
Block a user