Beispiel #1
0
 static public int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 1)
         {
             SLua.ByteArray o;
             o = new SLua.ByteArray();
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc == 2)
         {
             SLua.ByteArray o;
             System.Byte[]  a1;
             checkArray(l, 2, out a1);
             o = new SLua.ByteArray(a1);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #2
0
 static public int WriteUInt(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             SLua.ByteArray self = (SLua.ByteArray)checkSelf(l);
             System.UInt32  a1;
             checkType(l, 2, out a1);
             self.WriteUInt(a1);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             SLua.ByteArray self = (SLua.ByteArray)checkSelf(l);
             System.UInt32  a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             self.WriteUInt(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #3
0
 static public int Clear(IntPtr l)
 {
     try {
         SLua.ByteArray self = (SLua.ByteArray)checkSelf(l);
         self.Clear();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #4
0
 static public int get_Position(IntPtr l)
 {
     try {
         SLua.ByteArray self = (SLua.ByteArray)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.Position);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #5
0
 static public int GetData(IntPtr l)
 {
     try {
         SLua.ByteArray self = (SLua.ByteArray)checkSelf(l);
         var            ret  = self.GetData();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #6
0
    public static SLua.ByteArray LoadLuaAsset(string name)
    {
        string file = LuaFile.FindFile(name);

        if (string.IsNullOrEmpty(file) == false)
        {
            byte[]         bytes = LuaFile.ReadBytes(file);
            SLua.ByteArray array = new SLua.ByteArray();
            array.Write(bytes);

            return(array);
        }
        return(null);
    }
Beispiel #7
0
 static public int set_Position(IntPtr l)
 {
     try {
         SLua.ByteArray self = (SLua.ByteArray)checkSelf(l);
         int            v;
         checkType(l, 2, out v);
         self.Position = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #8
0
 static public int WriteVarInt(IntPtr l)
 {
     try {
         SLua.ByteArray self = (SLua.ByteArray)checkSelf(l);
         System.Int64   a1;
         checkType(l, 2, out a1);
         self.WriteVarInt(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #9
0
 static public int Read(IntPtr l)
 {
     try {
         SLua.ByteArray self = (SLua.ByteArray)checkSelf(l);
         System.Byte[]  a1;
         checkType(l, 2, out a1);
         self.Read(ref a1);
         pushValue(l, true);
         pushValue(l, a1);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #10
0
    public static void ProtobufString(SLua.ByteArray data)
    {
        System.IO.MemoryStream ms = new System.IO.MemoryStream(data.GetData(), 0, data.Position);

        PBMessage.Person person = ProtoTransfer.DeserializeProtoBuf <PBMessage.Person>(ms);
        Debug.Log("age=" + person.age);
        Debug.Log("email=" + person.email);
        Debug.Log("name=" + person.name);
        Debug.Log("id=" + person.id);
        var table = SLua.LuaSvr.mainState.getFunction("TestParseProtobuf");

        if (table != null)
        {
            table.call(data);
        }
    }
	static public int constructor(IntPtr l) {
		try {
			int argc = LuaDLL.lua_gettop(l);
			SLua.ByteArray o;
			if(argc==1){
				o=new SLua.ByteArray();
				pushValue(l,true);
				pushValue(l,o);
				return 2;
			}
			else if(argc==2){
				System.Byte[] a1;
				checkArray(l,2,out a1);
				o=new SLua.ByteArray(a1);
				pushValue(l,true);
				pushValue(l,o);
				return 2;
			}
			return error(l,"New object failed.");
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
Beispiel #12
0
 public void Write(ByteArray v)
 {
     WriteByteArray(v);
 }