コード例 #1
0
        internal static void OnStart(GlobalRef interopProc, IBinaryStream stream)
        {
            try
            {
                // 1. Read data and leave critical state ASAP.
                BinaryReader reader = BinaryUtils.Marshaller.StartUnmarshal(stream);

                // ReSharper disable once PossibleInvalidOperationException
                var name = reader.ReadString();

                // 2. Set ID and name so that Start() method can use them later.
                _startup.Name = name;

                if (Nodes.ContainsKey(new NodeKey(name)))
                {
                    throw new IgniteException("Ignite with the same name already started: " + name);
                }

                _startup.Ignite = new Ignite(_startup.Configuration, _startup.Name,
                                             new PlatformJniTarget(interopProc, _startup.Marshaller), _startup.Marshaller,
                                             _startup.LifecycleHandlers, _startup.Callbacks);
            }
            catch (Exception e)
            {
                // 5. Preserve exception to throw it later in the "Start" method and throw it further
                //    to abort startup in Java.
                _startup.Error = e;

                throw;
            }
        }
コード例 #2
0
        static HasherProxy()
        {
            JniEnvWrapper env = JvmManager.INSTANCE.GetEnv();

            classRef  = env.FindClass("ru/gnkoshelev/j4net/sample/hash/lib/Hasher");
            methodRef = env.GetStaticMethodId(classRef.Ptr, "compute", "(Ljava/lang/String;[B)Ljava/lang/String;");
        }
コード例 #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="target">Target.</param>
        /// <param name="marsh">Marshaller.</param>
        public PlatformJniTarget(GlobalRef target, Marshaller marsh)
        {
            Debug.Assert(target != null);
            Debug.Assert(marsh != null);

            _target = target;
            _marsh  = marsh;
        }
コード例 #4
0
        internal static GlobalRef TargetOutObject(GlobalRef target, int opType)
        {
            var jvm = target.Jvm;

            long opType0 = opType;

            return(jvm.AttachCurrentThread().CallObjectMethod(
                       target, jvm.MethodId.TargetOutObject, &opType0));
        }
コード例 #5
0
        internal static void TargetInStreamAsync(GlobalRef target, int opType, long memPtr)
        {
            var jvm = target.Jvm;

            long *args = stackalloc long[4];

            args[0] = opType;
            args[1] = memPtr;

            jvm.AttachCurrentThread().CallVoidMethod(target, jvm.MethodId.TargetInStreamAsync, args);
        }
コード例 #6
0
    void Start()
    {
        if (!GlobalRef.Init())
        {
            return;
        }

        CreateCommonUI();

        StartCoroutine(GlobalRef.AssetMgr.GetAB(AppConst.AB_MAIN, CreateMainUI));
    }
コード例 #7
0
        internal static long TargetInStreamOutLong(GlobalRef target, int opType, long memPtr)
        {
            var jvm = target.Jvm;

            long *args = stackalloc long[2];

            args[0] = opType;
            args[1] = memPtr;

            return(jvm.AttachCurrentThread().CallLongMethod(target, jvm.MethodId.TargetInStreamOutLong, args));
        }
コード例 #8
0
        internal static GlobalRef TargetInStreamOutObjectAsync(GlobalRef target, int opType, long memPtr)
        {
            var jvm = target.Jvm;

            long *args = stackalloc long[4];

            args[0] = opType;
            args[1] = memPtr;

            return(jvm.AttachCurrentThread().CallObjectMethod(
                       target, jvm.MethodId.TargetInStreamOutObjectAsync, args));
        }
コード例 #9
0
    void Start()
    {
        AppConst.PrintPath();

        if (!GlobalRef.Init())
        {
            Utility.LogError("Globalref init failed");
            return;
        }

        StartCoroutine(GlobalRef.AssetMgr.GetAB(AppConst.AB_COMMON, CreateCommonUI));
    }
コード例 #10
0
    void Start()
    {
        if (!GlobalRef.Init())
        {
            return;
        }

        CreateCommonUI();

        // string[] abList = new string[]{"sprite_battle", AppConst.AB_BATTLE };
        string[] abList = { "sprite_battle", AppConst.AB_BATTLE };
        StartCoroutine(GlobalRef.AssetMgr.GetABList(abList, CreateBattleUI));
    }
コード例 #11
0
        internal static void TargetInStreamOutStream(GlobalRef target, int opType, long inMemPtr,
                                                     long outMemPtr)
        {
            var jvm = target.Jvm;

            long *args = stackalloc long[3];

            args[0] = opType;
            args[1] = inMemPtr;
            args[2] = outMemPtr;

            jvm.AttachCurrentThread().CallVoidMethod(target, jvm.MethodId.TargetInStreamOutStream, args);
        }
コード例 #12
0
        internal static GlobalRef TargetInObjectStreamOutObjectStream(GlobalRef target, int opType,
                                                                      GlobalRef arg, long inMemPtr, long outMemPtr)
        {
            var jvm = target.Jvm;

            long *args = stackalloc long[4];

            args[0] = opType;
            args[1] = (long)arg.Target;
            args[2] = inMemPtr;
            args[3] = outMemPtr;

            return(jvm.AttachCurrentThread().CallObjectMethod(
                       target, jvm.MethodId.TargetInObjectStreamOutObjectStream, args));
        }
コード例 #13
0
    /*public static RoleInfo s_ri = new RoleInfo();
     */
    void Start()
    {
        GameObject NetLogic = GameObject.Find("NetLogic");

        if (NetLogic)
        {
            s_gr = NetLogic.GetComponent <GlobalRef>();
            //Object.DontDestroyOnLoad(NetLogic);
        }
        else
        {
            Debug.Log("There is no NetLogic object, please check!");
            Application.Quit();
        }

        //InitRoleData();
    }
コード例 #14
0
ファイル: BytecodeCompiler.cs プロジェクト: edmundmk/apollua
        // Statement visitors.

        public void Visit(Assign s)
        {
            if (s.Target is GlobalRef)
            {
                // Assign to global.
                GlobalRef  global   = (GlobalRef)s.Target;
                int        constant = function.Constant(global.Name);
                Allocation value    = R(s.Value);
                function.InstructionABx(s.SourceSpan, Opcode.SetGlobal, value, constant);
                value.Release();
            }
            else if (s.Target is Index)
            {
                // Assign to table index.
                Index      index = (Index)s.Target;
                Allocation table = R(index.Table);
                Allocation key   = RK(index.Key);
                Allocation value = RK(s.Value);
                function.InstructionABC(s.SourceSpan, Opcode.SetTable, table, key, value);
                value.Release();
                key.Release();
                table.Release();
            }
            else if (s.Target is LocalRef)
            {
                // Assign to local.
                LocalRef   local  = (LocalRef)s.Target;
                Allocation target = function.Local(local.Variable);
                Move(target, s.Value);
                target.Release();
            }
            else if (s.Target is UpValRef)
            {
                // Assign to upval.
                UpValRef   upval = (UpValRef)s.Target;
                int        index = function.UpVal(upval.Variable);
                Allocation value = R(s.Value);
                function.InstructionABC(s.SourceSpan, Opcode.SetUpVal, value, index, 0);
                value.Release();
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
コード例 #15
0
        public Sample(int x, int y, string str)
        {
            using (var strUtf = Env.NewStringUtf(str))
            {
                jObject = Env.NewObject(ClassPtr.Ptr, Constructor.Ptr,
                                        new JValue {
                    IntegerValue = x
                },
                                        new JValue {
                    IntegerValue = y
                },
                                        new JValue {
                    PointerValue = strUtf.Ptr
                }
                                        );

                HandleException();
            }
        }
コード例 #16
0
 public void Visit(GlobalRef e)
 {
     o.Write(e.Name);
 }
コード例 #17
0
ファイル: BytecodeCompiler.cs プロジェクト: edmundmk/apollua
 public void Visit(GlobalRef e)
 {
     function.InstructionABx(e.SourceSpan, Opcode.GetGlobal, target, function.Constant(e.Name));
 }
コード例 #18
0
ファイル: BytecodeCompiler.cs プロジェクト: edmundmk/apollua
        public void Visit(AssignList s)
        {
            // Evaluate subexpressions for index targets.
            Allocation allocTargets = function.Top();

            Expression[] targets = new Expression[s.Targets.Count];
            for (int target = 0; target < s.Targets.Count; ++target)
            {
                Expression e     = s.Targets[target];
                Index      index = e as Index;
                if (index != null)
                {
                    Allocation table = R(index.Table);
                    Allocation key   = RK(index.Key);

                    targets[target] = new IndexRef(index.SourceSpan, table, key);

                    key.Release();
                    table.Release();
                    allocTargets.Allocate(2);
                }
                else
                {
                    targets[target] = e;
                }
            }

            // Evaluate all values.
            Allocation allocValues = function.Top();

            for (int value = 0; value < s.Values.Count; ++value)
            {
                Allocation allocValue = Push(s.Values[value]);
                allocValue.Release();
                allocValues.Allocate();
            }
            if (s.ValueList != null)
            {
                if (s.Targets.Count <= s.Values.Count)
                {
                    throw new ArgumentException();
                }

                Allocation allocValueList = PushList(s.ValueList, s.Targets.Count - s.Values.Count);
                allocValueList.Release();
                allocValues.Allocate(s.Targets.Count - s.Values.Count);
            }

            // Assign each value.
            for (int target = 0; target < targets.Length; ++target)
            {
                if (targets[target] is GlobalRef)
                {
                    GlobalRef global = (GlobalRef)targets[target];
                    function.InstructionABx(s.SourceSpan, Opcode.SetGlobal,
                                            allocValues + target, function.Constant(global.Name));
                }
                else if (targets[target] is IndexRef)
                {
                    IndexRef index = (IndexRef)targets[target];
                    function.InstructionABC(s.SourceSpan, Opcode.SetTable,
                                            index.Table, index.Key, allocValues + target);
                }
                else if (targets[target] is LocalRef)
                {
                    LocalRef local = (LocalRef)targets[target];
                    function.InstructionABC(s.SourceSpan, Opcode.Move,
                                            function.Local(local.Variable), allocValues + target, 0);
                }
                else if (targets[target] is UpValRef)
                {
                    UpValRef upval = (UpValRef)targets[target];
                    function.InstructionABC(s.SourceSpan, Opcode.SetUpVal,
                                            allocValues + target, function.UpVal(upval.Variable), 0);
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }

            // Release.
            allocValues.Release();
            allocTargets.Release();
        }
コード例 #19
0
 public Sample(GlobalRef jObject)
 {
     this.jObject = jObject;
 }
コード例 #20
0
 /// <summary>
 /// Gets the platform target.
 /// </summary>
 private IPlatformTargetInternal GetPlatformTarget(GlobalRef target)
 {
     return(target == null ? null : new PlatformJniTarget(target, _marsh));
 }
コード例 #21
0
ファイル: FunctionTransform.cs プロジェクト: edmundmk/apollua
 public virtual void Visit(GlobalRef e)
 {
     result = e;
 }