Examples of tojstring()


Examples of org.luaj.vm2.LuaValue.tojstring()

        assertTrue( ik >= 0 && ik < 10 );
        final int mask = 1 << ik;
        assertTrue( ( intKeys & mask ) == 0 );
        intKeys |= mask;
      } else if ( k instanceof LuaString ) {
        final int ik = Integer.parseInt( k.tojstring() );
        assertEquals( String.valueOf( ik ), k.tojstring() );
        assertTrue( ik >= 0 && ik < 10 );
        final int mask = 1 << ik;
        assertTrue( "Key \""+ik+"\" found more than once", ( stringKeys & mask ) == 0 );
        stringKeys |= mask;
View Full Code Here

Examples of org.luaj.vm2.LuaValue.tojstring()

        final int mask = 1 << ik;
        assertTrue( ( intKeys & mask ) == 0 );
        intKeys |= mask;
      } else if ( k instanceof LuaString ) {
        final int ik = Integer.parseInt( k.tojstring() );
        assertEquals( String.valueOf( ik ), k.tojstring() );
        assertTrue( ik >= 0 && ik < 10 );
        final int mask = 1 << ik;
        assertTrue( "Key \""+ik+"\" found more than once", ( stringKeys & mask ) == 0 );
        stringKeys |= mask;
      } else {
View Full Code Here

Examples of org.luaj.vm2.LuaValue.tojstring()

    int nresults = results.narg();
    assertEquals( 2, nresults );
    LuaValue b = results.arg(1);
    LuaValue c = results.arg(2);
    String sb = b.tojstring();
    String sc = c.tojstring();
    assertEquals( "set("+typename+") "+value, sb );
    assertEquals( "setr("+typename+") "+value, sc );
  }

  public void testClassInheritanceLevels() {
View Full Code Here

Examples of org.luaj.vm2.LuaValue.tojstring()

            Prototype p = LuaC.instance.compile(is, "script");
           
            // double check script result before dumping
            LuaFunction f = new LuaClosure(p, _G);
            LuaValue r = f.call();
            String actual = r.tojstring();
            assertEquals( expectedPriorDump, actual );
           
            // dump into bytes
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
View Full Code Here

Examples of org.luaj.vm2.LuaValue.tojstring()

           
            // load again using compiler
            is = new ByteArrayInputStream(dumped);
            f = LoadState.load(is, "dumped", _G);
            r = f.call();
            actual = r.tojstring();
            assertEquals( expectedPostDump, actual );

            // write test chunk
            if ( System.getProperty(SAVECHUNKS) != null && script.equals(mixedscript) ) {
              new File("build").mkdirs();
View Full Code Here

Examples of org.luaj.vm2.LuaValue.tojstring()

        if ( s.isnil() ) {
          func = null;
          bytes = null;
          return -1;
        }
        bytes = s.tojstring().getBytes();
        offset = 0;
      }
      if ( offset >= bytes.length )
        return -1;
      return bytes[offset++];
View Full Code Here

Examples of org.luaj.vm2.LuaValue.tojstring()

      }
      case NEWINSTANCE:
      case NEW: {
        // get constructor
        final LuaValue c = args.checkvalue(1);
        final Class clazz = (opcode==NEWINSTANCE? classForName(c.tojstring()): (Class) c.checkuserdata(Class.class));
        final Varargs consargs = args.subargs(2);
        return JavaClass.forClass(clazz).getConstructor().invoke(consargs);
      }
       
      case CREATEPROXY: {       
View Full Code Here

Examples of org.luaj.vm2.LuaValue.tojstring()

   
    // get package path
    LuaValue pp = PACKAGE.get(_PATH);
    if ( ! pp.isstring() )
      return valueOf("package.path is not a string");
    String path = pp.tojstring();
   
    // check the path elements
    int e = -1;
    int n = path.length();
    StringBuffer sb = null;
View Full Code Here

Examples of org.luaj.vm2.LuaValue.tojstring()

    if (!lv.isNil(LuaFields.COMMANDS)) {
      Iterator<LuaPair> pairsIter = lv.getTable(LuaFields.COMMANDS).arrayIterator();
      while (pairsIter.hasNext()) {
        LuaValue c = pairsIter.next().value;
        if (c.isstring()) {
          cmds.add(c.tojstring());
        } else if (c.istable()) {
          cmds.add(toCommand(new LuaWrapper(c.checktable())));
        }
      }
    } else if (!lv.isNil(LuaFields.COMMAND)) {
View Full Code Here

Examples of org.luaj.vm2.Varargs.tojstring()

    Varargs chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
    if ( ! chunk.arg1().toboolean() )
      fail( chunk.arg(2).toString() );
    Varargs results = chunk.arg1().invoke();
    int nresults = results.narg();
    String sa = results.tojstring(1);
    String sb = results.tojstring(2);
    String sc = results.tojstring(3);
    assertEquals( 3, nresults );
    assertEquals( "12345678901234567890", sa );
    assertEquals( "12345678901234567890", sb );
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.