Пример #1
0
 public int luaCB_text(Lua l, LuaPlugin plugin) {
   try {
     plugin.generateLuaClass(l, new TextOutFile(plugin, object));
   } catch (IOException e) {
     l.pushNil();
     l.pushString("IOException: " + e.getMessage());
     return 2;
   } catch (IllegalArgumentException e) {
     l.pushNil();
     l.pushString("Illegal argument: " + e.getMessage());
     return 2;
   }
   return 1;
 }
Пример #2
0
 public int luaCB_four_to_five(Lua l, LuaPlugin plugin) {
   try {
     plugin.generateLuaClass(l, new BinaryOutFile(plugin, new FourToFiveEncoder(object)));
   } catch (IOException e) {
     l.pushNil();
     l.pushString("IOException: " + e.getMessage());
     return 2;
   } catch (IllegalArgumentException e) {
     l.pushNil();
     l.pushString("Illegal argument: " + e.getMessage());
     return 2;
   }
   return 1;
 }
Пример #3
0
 public int luaCB_deflate(Lua l, LuaPlugin plugin) {
   try {
     plugin.generateLuaClass(l, new BinaryOutFile(plugin, new DeflaterOutputStream(object)));
   } catch (IOException e) {
     l.pushNil();
     l.pushString("IOException: " + e.getMessage());
     return 2;
   } catch (IllegalArgumentException e) {
     l.pushNil();
     l.pushString("Illegal argument: " + e.getMessage());
     return 2;
   }
   return 1;
 }
Пример #4
0
 public static int luaCB_open(Lua l, LuaPlugin plugin) {
   l.pushNil();
   String name = l.checkString(1);
   try {
     plugin.generateLuaClass(l, new BinaryOutFile(plugin, new FileOutputStream(name)));
   } catch (IOException e) {
     l.pushNil();
     l.pushString("IOException: " + e.getMessage());
     return 2;
   } catch (IllegalArgumentException e) {
     l.pushNil();
     l.pushString("Illegal argument: " + e.getMessage());
     return 2;
   }
   return 1;
 }
Пример #5
0
 public int luaCB_write(Lua l, LuaPlugin plugin) {
   l.pushNil();
   try {
     String towrite = l.checkString(2);
     if (towrite == "") {
       l.pushBoolean(true);
       return 1;
     }
     byte[] tmp = new byte[towrite.length()];
     for (int i = 0; i < towrite.length(); i++) tmp[i] = (byte) towrite.charAt(i);
     object.write(tmp);
     l.pushBoolean(true);
   } catch (IOException e) {
     l.pushBoolean(false);
     l.pushString("IOException: " + e.getMessage());
     return 2;
   }
   return 1;
 }