示例#1
0
        public Context(string address)
        {
        #if STATIC_BIND
            if (address == null || address.Length == 0)
            {
                this.handler = Native.ffi_context_create_embedded();
            }
            else
            {
                this.handler = Native.ffi_context_connect(address);
            }
        #else
            // load library
            var libName  = "libffi_domain.so";
            var dataPath = Application.dataPath + "/Plugins/" + libName;
            libraryHandle = LoadLibrary(dataPath);

            // load methods
            this.nativeCloseContext = GetLibraryFunction <CloseContext>(libraryHandle, "ffi_context_close");
            this.nativeContextPush  = GetLibraryFunction <ContextPush>(libraryHandle, "ffi_context_push");
            this.nativeContextTake  = GetLibraryFunction <ContextTake>(libraryHandle, "ffi_context_take");

            // start ffi context
            CreateContext createContext = GetLibraryFunction <CreateContext>(libraryHandle, "ffi_context_create_embedded");
            contextHandle = createContext.Invoke();
#endif
        }
示例#2
0
        public Core(string args, EventHandler eventHandler)
        {
            this.eventHandler = eventHandler;

            #if STATIC_BIND
            this.coreHandler = Native.space_domain_init_context(args);
            #else
            var libName  = "libffi_space.so";
            var dataPath = Application.dataPath + "/Plugins/" + libName;
            libraryHandle = LoadLibrary(dataPath);

            // load methods
            this.nativeContextClose = GetLibraryFunction <ContextClose>(libraryHandle, "space_domain_close_context");
            this.nativeContextPush  = GetLibraryFunction <ContextPush>(libraryHandle, "space_domain_set_data");
            this.nativeContextTake  = GetLibraryFunction <ContextTake>(libraryHandle, "space_domain_get_data");
            this.nativeContextTick  = GetLibraryFunction <ContextTick>(libraryHandle, "space_domain_run_tick");

            // start ffi context
            CreateContext createContext = GetLibraryFunction <CreateContext>(libraryHandle, "space_domain_init_context");
            contextHandle = createContext.Invoke(args);
            #endif
            Debug.Log("core initialize");
        }