Examples of LuaError


Examples of org.luaj.vm2.LuaError

                    defaultAnimationName = animationName; // set first animation as the default one
                }
            }
            catch (SpriteException ex) {
                // Error in the input file.
                throw new LuaError(ex);
            }
            catch (Exception ex) {
                // Error in the editor.
                ex.printStackTrace();
                throw new LuaError(ex);
            }

            return LuaValue.NIL;
        }
View Full Code Here

Examples of org.luaj.vm2.LuaError

    org.luaj.vm2.LoadState.compiler = instance;
  }

  protected static void _assert(boolean b) {   
    if (!b)
      throw new LuaError("compiler assert failed");
  }
View Full Code Here

Examples of org.luaj.vm2.LuaError

        f.name = names[i];
        f.env = env;
        env.set(f.name, f);
      }
    } catch ( Exception e ) {
      throw new LuaError( "bind failed: "+e );
    }
  } 
View Full Code Here

Examples of org.luaj.vm2.LuaError

  void lexerror( String msg, int token ) {
    String cid = chunkid( source.tojstring() ); // TODO: get source name from source
    L.pushfstring( cid+":"+linenumber+": "+msg );
    if ( token != 0 )
      L.pushfstring( "syntax error: "+msg+" near "+txtToken(token) );
    throw new LuaError(cid+":"+linenumber+": "+msg);
  }
View Full Code Here

Examples of org.luaj.vm2.LuaError

        } else {
          this.argerror(1, "gc op");
        }
        return NIL;
      case 1: // "error", // ( message [,level] ) -> ERR
        throw new LuaError( arg1.isnil()? null: arg1.tojstring(), arg2.optint(1) );
      case 2: { // "setfenv", // (f, table) -> void
        LuaTable t = arg2.checktable();
        LuaValue f = getfenvobj(arg1);
        if ( ! f.isfunction() && ! f.isclosure() )
          error("'setfenv' cannot change environment of given object");
View Full Code Here

Examples of org.luaj.vm2.LuaError

      }
       
      case CREATEPROXY: {       
        final int niface = args.narg()-1;
        if ( niface <= 0 )
          throw new LuaError("no interfaces");
        final LuaValue lobj = args.checktable(niface+1);
       
        // get the interfaces
        final Class[] ifaces = new Class[niface];
        for ( int i=0; i<niface; i++ )
          ifaces[i] = classForName(args.checkjstring(i+1));
       
        // create the invocation handler
        InvocationHandler handler = new InvocationHandler() {
          public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            String name = method.getName();
            LuaValue func = lobj.get(name);
            if ( func.isnil() )
              return null;
            boolean isvarargs = ((method.getModifiers() & METHOD_MODIFIERS_VARARGS) != 0);
            int n = args!=null? args.length: 0;
            LuaValue[] v;
            if ( isvarargs ) {               
              Object o = args[--n];
              int m = Array.getLength( o );
              v = new LuaValue[n+m];
              for ( int i=0; i<n; i++ )
                v[i] = CoerceJavaToLua.coerce(args[i]);
              for ( int i=0; i<m; i++ )
                v[i+n] = CoerceJavaToLua.coerce(Array.get(o,i));               
            } else {
              v = new LuaValue[n];
              for ( int i=0; i<n; i++ )
                v[i] = CoerceJavaToLua.coerce(args[i]);
            }
            LuaValue result = func.invoke(v).arg1();
            return CoerceLuaToJava.coerce(result, method.getReturnType());
          }
        };
       
        // create the proxy object
        Object proxy = Proxy.newProxyInstance(getClass().getClassLoader(), ifaces, handler);
       
        // return the proxy
        return LuaValue.userdataOf( proxy );
      }
      case LOADLIB: {
        // get constructor
        String classname = args.checkjstring(1);
        String methodname = args.checkjstring(2);
        Class clazz = classForName(classname);
        Method method = clazz.getMethod(methodname, new Class[] {});
        Object result = method.invoke(clazz, new Object[] {});
        if ( result instanceof LuaValue ) {
          return (LuaValue) result;
        } else {
          return NIL;
        }
      }
      default:
        throw new LuaError("not yet supported: "+this);
      }
    } catch (LuaError e) {
      throw e;
    } catch (InvocationTargetException ite) {
      throw new LuaError(ite.getTargetException());
    } catch (Exception e) {
      throw new LuaError(e);
    }
  }
View Full Code Here

Examples of org.luaj.vm2.LuaError

    f.deleteOnExit();
    return new FileImpl( new RandomAccessFile(f,"rw") );
  }
 
  private static void notimplemented() {
    throw new LuaError("not implemented");
  }
View Full Code Here

Examples of org.luaj.vm2.LuaError

  public Varargs invoke(Varargs args) {
    Object[] a = convertArgs(args);
    try {
      return CoerceJavaToLua.coerce( constructor.newInstance(a) );
    } catch (InvocationTargetException e) {
      throw new LuaError(e.getTargetException());
    } catch (Exception e) {
      return LuaValue.error("coercion error "+e);
    }
  }
View Full Code Here

Examples of org.luaj.vm2.LuaError

  LuaValue invokeMethod(Object instance, Varargs args) {
    Object[] a = convertArgs(args);
    try {
      return CoerceJavaToLua.coerce( method.invoke(instance, a) );
    } catch (InvocationTargetException e) {
      throw new LuaError(e.getTargetException());
    } catch (Exception e) {
      return LuaValue.error("coercion error "+e);
    }
  }
View Full Code Here

Examples of org.luaj.vm2.LuaError

    Field f = jclass.getField(key);
    if ( f != null )
      try {
        return CoerceJavaToLua.coerce(f.get(m_instance));
      } catch (Exception e) {
        throw new LuaError(e);
      }
    LuaValue m = jclass.getMethod(key);
    if ( m != null )
      return m;
    return super.get(key);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.