org.luaj.vm2.lib.VarArgFunction Java Examples

The following examples show how to use org.luaj.vm2.lib.VarArgFunction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LuaGeneration.java    From Cubes with MIT License 6 votes vote down vote up
public static LuaValue[] convertParamsToLua(Object instance, Object[] objects, final Callable supercall) {
  LuaValue[] parameters = new LuaValue[objects.length + 2];
  parameters[0] = LuaConversion.convertToLua(instance);
  for (int i = 0; i < objects.length; i++) {
    parameters[i + 1] = LuaConversion.convertToLua(objects[i]);
  }
  parameters[parameters.length - 1] = new VarArgFunction() {
    @Override
    public Varargs invoke(Varargs args) {
      try {
        Object o = supercall.call();
        return LuaConversion.convertToLua(o);
      } catch (Exception e) {
        throw new DynamicDelegationError("Supercall threw exception - called from supplied delegation", e);
      }
    }
  };
  return parameters;
}