Пример #1
0
        Application(Context context, ApplicationOptions options = null) : base(UrhoObjectFlag.Empty)
        {
            //Workbooks specific:
            CancelActiveActionsOnStop = this is SimpleApplication;
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            //keep references to callbacks (supposed to be passed to native code) as long as the App is alive
            setupCallback = ProxySetup;
            startCallback = ProxyStart;
            stopCallback  = ProxyStop;

#if !ANDROID
            if (context.Refs() < 1)
            {
                context.AddRef();
            }
#endif

            Options = options ?? new ApplicationOptions(assetsFolder: null);
            handle  = ApplicationProxy_ApplicationProxy(context.Handle, setupCallback, startCallback, stopCallback, Options.ToString(), Options.ExternalWindow);
            Runtime.RegisterObject(this);
        }
Пример #2
0
        public PythonAPI(PythonVersion pyVer)
        {
            string dllName = pyVer.ToString().ToLower();
            _pythonLibrary = new UnmanagedLibrary(dllName);

            Py_Initialize = _pythonLibrary.GetUnmanagedFunction<Action>("Py_Initialize");
            Py_IsInitialized = _pythonLibrary.GetUnmanagedFunction<FuncInt>("Py_IsInitialized");
            Py_Finalize = _pythonLibrary.GetUnmanagedFunction<Action>("Py_Finalize");
            PyEval_InitThreads = _pythonLibrary.GetUnmanagedFunction<Action>("PyEval_InitThreads");
            PyGILState_Ensure = _pythonLibrary.GetUnmanagedFunction<FuncIntPtr>("PyGILState_Ensure");
            PyGILState_Release = _pythonLibrary.GetUnmanagedFunction<ActionIntPtr>("PyGILState_Release");
            PyThreadState_Get = _pythonLibrary.GetUnmanagedFunction<FuncIntPtr>("PyThreadState_Get");

            PyRun_String = _pythonLibrary.GetUnmanagedFunction<FuncStringIntIntPtrIntPtrIntPtr>("PyRun_String");

            PyErr_Print = _pythonLibrary.GetUnmanagedFunction<Action>("PyErr_Print");
            PyErr_Occurred = _pythonLibrary.GetUnmanagedFunction<FuncIntPtr>("PyErr_Occurred");
            PyErr_Clear = _pythonLibrary.GetUnmanagedFunction<Action>("PyErr_Clear");
            PyErr_Fetch = _pythonLibrary.GetUnmanagedFunction<ActionRIntPtrRIntPtrRIntPtr>("PyErr_Fetch");

            PyImport_AddModule = _pythonLibrary.GetUnmanagedFunction<FuncStringIntPtr>("PyImport_AddModule");
            PyModule_GetDict = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrIntPtr>("PyModule_GetDict");

            Py_IncRef = _pythonLibrary.GetUnmanagedFunction<ActionIntPtr>("Py_IncRef");
            Py_DecRef = _pythonLibrary.GetUnmanagedFunction<ActionIntPtr>("Py_DecRef");

            PyObject_HasAttrString = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrStringInt>("PyObject_HasAttrString");
            PyObject_GetAttrString = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrStringIntPtr>("PyObject_GetAttrString");
            PyObject_SetAttrString = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrStringIntPtrInt>("PyObject_SetAttrString");
            PyObject_Str = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrIntPtr>("PyObject_Str");
            PyObject_Compare = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrIntPtrInt>("PyObject_Compare");
            PyCallable_Check = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrInt>("PyCallable_Check");
            PyObject_CallObject = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrIntPtrIntPtr>("PyObject_CallObject");
            PyObject_Length = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrInt>("PyObject_Length");
            PyObject_Dir = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrIntPtr>("PyObject_Dir");
            PyObject_Type = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrIntPtr>("PyObject_Type");
            PyObject_IsInstance = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrIntPtrInt>("PyObject_IsInstance");

            PyString_FromString = _pythonLibrary.GetUnmanagedFunction<FuncStringIntPtr>("PyString_FromString");
            PyString_AsString = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrIntPtr>("PyString_AsString");

            PySys_GetObject = _pythonLibrary.GetUnmanagedFunction<FuncStringIntPtr>("PySys_GetObject");

            PyInt_AsLong = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrInt>("PyInt_AsLong");
            PyLong_AsLongLong = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrLong>("PyLong_AsLongLong");

            PyFloat_AsDouble = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrDouble>("PyFloat_AsDouble");

            PyTuple_New = _pythonLibrary.GetUnmanagedFunction<FuncIntIntPtr>("PyTuple_New");
            PyTuple_SetItem = _pythonLibrary.GetUnmanagedFunction<FuncIntPtrIntIntPtrInt>("PyTuple_SetItem");

            PyType_Type = _pythonLibrary.GetGlobalVar("PyType_Type");
            PyBaseObject_Type = _pythonLibrary.GetGlobalVar("PyBaseObject_Type");
            PyString_Type = _pythonLibrary.GetGlobalVar("PyString_Type");
            PyUnicode_Type = _pythonLibrary.GetGlobalVar("PyUnicode_Type");
            PyInt_Type = _pythonLibrary.GetGlobalVar("PyInt_Type");
            PyLong_Type = _pythonLibrary.GetGlobalVar("PyLong_Type");
            PyBool_Type = _pythonLibrary.GetGlobalVar("PyBool_Type");
            PyFloat_Type = _pythonLibrary.GetGlobalVar("PyFloat_Type");
        }
Пример #3
0
        protected Application()
        {
            // Keep references to callbacks (supposed to be passed to native code) as long as the App is alive
            _setupCallback = ProxySetup;
            _startCallback = ProxyStart;
            _stopCallback  = ProxyStop;

            _handle  = Application_new(_setupCallback, _startCallback, _stopCallback);
            _current = this;
        }
Пример #4
0
        static Application()
        {
            _initializeCallback = new ActionIntPtr(InitializeInternal);
            _exitingCallback    = new ActionIntPtr(ExitingInternal);

            alimer_app_set_delegates(
                Marshal.GetFunctionPointerForDelegate(_initializeCallback),
                Marshal.GetFunctionPointerForDelegate(_exitingCallback)
                );
        }
Пример #5
0
        /// <summary>
        /// Supports the simple style with callbacks
        /// </summary>
        Application(Context context, ApplicationOptions options = null) : base(UrhoObjectFlag.Empty)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (context.Refs() < 1)
            {
                context.AddRef();
            }

            //keep references to callbacks (supposed to be passed to native code) as long as the App is alive
            setupCallback = ProxySetup;
            startCallback = ProxyStart;
            stopCallback  = ProxyStop;

            Options = options ?? new ApplicationOptions(assetsFolder: null);
            handle  = ApplicationProxy_ApplicationProxy(context.Handle, setupCallback, startCallback, stopCallback, Options.ToString(), Options.ExternalWindow);
            Runtime.RegisterObject(this);

            Engine.SubscribeToUpdate(HandleUpdate);
        }
Пример #6
0
 static extern IntPtr ApplicationProxy_ApplicationProxy(IntPtr contextHandle, ActionIntPtr setup, ActionIntPtr start, ActionIntPtr stop, string args, IntPtr externalWindow);
Пример #7
0
 public extern static IntPtr Application_new(ActionIntPtr setup, ActionIntPtr start, ActionIntPtr stop);