Mercurial Hosting > luan
comparison src/luan/Lua.java @ 35:e51906de0f11
implement metatables
git-svn-id: https://luan-java.googlecode.com/svn/trunk@36 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 18 Dec 2012 07:05:58 +0000 |
parents | 8217d8485715 |
children | 2a35154aec14 |
comparison
equal
deleted
inserted
replaced
34:0cdc1da466ee | 35:e51906de0f11 |
---|---|
1 package luan; | 1 package luan; |
2 | 2 |
3 | 3 |
4 public class Lua { | 4 public class Lua { |
5 public static final String version = "Luan 0.0"; | |
5 | 6 |
6 public static String type(Object obj) { | 7 public static String type(Object obj) { |
7 if( obj == null ) | 8 if( obj == null ) |
8 return "nil"; | 9 return "nil"; |
9 if( obj instanceof String ) | 10 if( obj instanceof String ) |
61 if( obj instanceof LuaFunction ) | 62 if( obj instanceof LuaFunction ) |
62 return (LuaFunction)obj; | 63 return (LuaFunction)obj; |
63 throw new LuaException( "attempt to call a " + type(obj) + " value" ); | 64 throw new LuaException( "attempt to call a " + type(obj) + " value" ); |
64 } | 65 } |
65 | 66 |
67 public static LuaTable getMetatable(Object obj) { | |
68 if( !(obj instanceof LuaTable) ) | |
69 return null; | |
70 LuaTable table = (LuaTable)obj; | |
71 return table.getMetatable(); | |
72 } | |
73 | |
66 } | 74 } |