/*
         * make header
         */
        public static void luaU_header(CharPtr h)
        {
            h = new CharPtr(h);
            int x = 1;

            memcpy(h, LUA_SIGNATURE, LUA_SIGNATURE.Length);
            h    = h.add(LUA_SIGNATURE.Length);
            h[0] = (char)LUAC_VERSION;
            h.inc();
            h[0] = (char)LUAC_FORMAT;
            h.inc();
            //*h++=(char)*(char*)&x;				/* endianness */
            h[0] = (char)x;                                                     /* endianness */
            h.inc();
            h[0] = (char)sizeof(int);
            h.inc();
            h[0] = (char)sizeof(uint);
            h.inc();
            h[0] = (char)sizeof(Instruction);
            h.inc();
            h[0] = (char)sizeof(lua_Number);
            h.inc();

            //(h++)[0] = ((lua_Number)0.5 == 0) ? 0 : 1;		/* is lua_Number integral? */
            h[0] = (char)0;             // always 0 on this build
        }
        private const int FORMAT            = 0;        /* this is the official format */

        /*
         * make header for precompiled chunks
         * if you change the code below be sure to update LoadHeader and FORMAT above
         * and LUAC_HEADERSIZE in lundump.h
         */
        public static void luaU_header(CharPtr h)         //FIXME:changed, lu_byte*
        {
            int x = 1;

            memcpy(h, LUA_SIGNATURE, (uint)LUA_SIGNATURE.Length);                                       //FIXME:changed, sizeof(LUA_SIGNATURE)-sizeof(char)
            h    = h.add(LUA_SIGNATURE.Length);                                                         //FIXME:changed, sizeof(LUA_SIGNATURE)-sizeof(char);
            h[0] = (char)(byte)VERSION; h.inc();                                                        //FIXME:changed, (char)
            h[0] = (char)(byte)FORMAT; h.inc();                                                         //FIXME:changed, (char)
            h[0] = (char)(byte)x; h.inc(); /* endianness */                                             //FIXME:changed, *h++=cast_byte(*(char*)&x); //FIXME:changed, (char)
            h[0] = (char)(byte)GetUnmanagedSize(typeof(int)); h.inc();                                  //FIXME:changed, (char)
            h[0] = (char)(byte)GetUnmanagedSize(typeof(uint)); h.inc();                                 //FIXME:changed, (char)
            h[0] = (char)(byte)GetUnmanagedSize(typeof(Instruction)); h.inc();                          //FIXME:changed, (char)
            h[0] = (char)(byte)GetUnmanagedSize(typeof(lua_Number)); h.inc();                           //FIXME:changed, (char)
            h[0] = (char)(byte)(((lua_Number)0.5) == 0 ? 1 : 0); h.inc(); /* is lua_Number integral? */ //FIXME:???always 0 on this build //FIXME:changed, (char)
            memcpy(h, LUAC_TAIL, (uint)LUAC_TAIL.Length);                                               //FIXME:changed, sizeof(LUAC_TAIL)-sizeof(char)
        }
Exemple #3
0
        /*
        * make header
        */
        public static void luaU_header(CharPtr h)
        {
            h = new CharPtr(h);
             int x=1;
             memcpy(h, LUA_SIGNATURE, LUA_SIGNATURE.Length);
             h = h.add(LUA_SIGNATURE.Length);
             h[0] = (char)LUAC_VERSION;
             h.inc();
             h[0] = (char)LUAC_FORMAT;
             h.inc();
             //*h++=(char)*(char*)&x;				/* endianness */
             h[0] = (char)x;						/* endianness */
             h.inc();
             h[0] = (char)sizeof(int);
             h.inc();
             h[0] = (char)sizeof(uint);
             h.inc();
             h[0] = (char)sizeof(Instruction);
             h.inc();
             h[0] = (char)sizeof(lua_Number);
             h.inc();

              //(h++)[0] = ((lua_Number)0.5 == 0) ? 0 : 1;		/* is lua_Number integral? */
             h[0] = (char)0;	// always 0 on this build
        }
Exemple #4
0
        // This strftime implementation has been made following the
        // Sanos OS open-source strftime.c implementation at
        // http://www.jbox.dk/sanos/source/lib/strftime.c.html
        private static uint strftime(CharPtr s, uint maxsize, CharPtr format, DateTime t)
        {
            int sIndex = s.index;

            CharPtr p = StrFTimeFmt((format as object) == null ? "%c" : format, t, s, s.add((int)maxsize));
            if (p == s + maxsize) return 0;
            p[0] = '\0';

            return (uint)Math.Abs(s.index - sIndex);
        }
Exemple #5
0
        // This strftime implementation has been made following the
        // Sanos OS open-source strftime.c implementation at
        // http://www.jbox.dk/sanos/source/lib/strftime.c.html

        private static uint strftime(CharPtr s, uint maxsize, CharPtr format, DateTime t)
        {
            int sIndex = s.index;

            CharPtr p = StrFTimeFmt((format as object) == null ? "%c" : format, t, s, s.add((int)maxsize));

            if (p == s + maxsize)
            {
                return(0);
            }
            p[0] = '\0';

            return((uint)Math.Abs(s.index - sIndex));
        }