Beispiel #1
0
        static int Main(string[] args)
        {
            // prepend the exe name to the arg list as it's done in C
            // so that we don't have to change any of the args indexing
            // code above
            List <string> newargs = new List <string>(args);

            newargs.Insert(0, Assembly.GetExecutingAssembly().Location);
            args = (string[])newargs.ToArray();

            Lua.LuaState L;
            Smain        s    = new Smain();
            int          argc = args.Length;
            int          i    = doargs(argc, args);

            newargs.RemoveRange(0, i);
            argc -= i; args = (string[])newargs.ToArray();
            if (argc <= 0)
            {
                usage("no input files given");
            }
            L = Lua.lua_open();
            if (L == null)
            {
                fatal("not enough memory for state");
            }
            s.argc = argc;
            s.argv = args;
            if (Lua.lua_cpcall(L, pmain, s) != 0)
            {
                fatal(Lua.lua_tostring(L, -1));
            }
            Lua.lua_close(L);
            return(Lua.EXIT_SUCCESS);
        }
Beispiel #2
0
        static int Main(string[] args)
        {
            // prepend the exe name to the arg list as it's done in C
            // so that we don't have to change any of the args indexing
            // code above
            List <string> newargs = new List <string>(args);

            newargs.Insert(0, Assembly.GetExecutingAssembly().Location);
            args = (string[])newargs.ToArray();

            int   status;
            Smain s = new Smain();

            Lua.LuaState L = Lua.lua_open();  /* create state */
            if (L == null)
            {
                l_message(args[0], "cannot create state: not enough memory");
                return(Lua.EXIT_FAILURE);
            }
            s.argc = args.Length;
            s.argv = args;
            status = Lua.lua_cpcall(L, pmain, s);
            report(L, status);
            Lua.lua_close(L);
            return((status != 0) || (s.status != 0) ? Lua.EXIT_FAILURE : Lua.EXIT_SUCCESS);
        }