コード例 #1
0
ファイル: NativeApiLibrary.cs プロジェクト: lintest/OneScript
        public NativeApiLibrary(String filepath, String identifier)
        {
            if (!File.Exists(filepath))
            {
                return;
            }

            using (var stream = File.OpenRead(filepath))
            {
                if (NativeApiPackage.IsZip(stream))
                {
                    _tempfile = Path.GetTempFileName();
                    NativeApiPackage.Extract(stream, _tempfile);
                    Module = NativeApiKernel.LoadLibrary(_tempfile);
                }
                else
                {
                    Module = NativeApiKernel.LoadLibrary(filepath);
                }
            }
            if (Loaded)
            {
                RegisterComponents(identifier);
            }
        }
コード例 #2
0
ファイル: NativeApiLibrary.cs プロジェクト: lintest/OneScript
 public void Dispose()
 {
     foreach (var component in _components)
     {
         component.Dispose();
     }
     if (Loaded && NativeApiKernel.FreeLibrary(Module))
     {
         if (!String.IsNullOrEmpty(_tempfile))
         {
             try { File.Delete(_tempfile); } catch (Exception) { }
         }
     }
 }
コード例 #3
0
ファイル: NativeApiProxy.cs プロジェクト: lintest/OneScript
        static NativeApiProxy()
        {
            string location = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string filename = System.IO.Path.GetDirectoryName(location)
                              + System.IO.Path.DirectorySeparatorChar + "ScriptEngine.NativeApi"
                              + (IntPtr.Size == 8 ? "64" : "32")
                              + (NativeApiKernel.IsLinux ? ".so" : ".dll");
            IntPtr module = NativeApiKernel.LoadLibrary(filename);

            GetClassObject   = Marshal.GetDelegateForFunctionPointer <TGetClassObject>(NativeApiKernel.GetProcAddress(module, "GetClassObject"));
            DestroyObject    = Marshal.GetDelegateForFunctionPointer <TDestroyObject>(NativeApiKernel.GetProcAddress(module, "DestroyObject"));
            CreateVariant    = Marshal.GetDelegateForFunctionPointer <TCreateVariant>(NativeApiKernel.GetProcAddress(module, "CreateVariant"));
            FreeVariant      = Marshal.GetDelegateForFunctionPointer <TFreeVariant>(NativeApiKernel.GetProcAddress(module, "FreeVariant"));
            GetNProps        = Marshal.GetDelegateForFunctionPointer <TGetNProps>(NativeApiKernel.GetProcAddress(module, "GetNProps"));
            FindProp         = Marshal.GetDelegateForFunctionPointer <TFindProp>(NativeApiKernel.GetProcAddress(module, "FindProp"));
            IsPropReadable   = Marshal.GetDelegateForFunctionPointer <TIsPropReadable>(NativeApiKernel.GetProcAddress(module, "IsPropReadable"));
            IsPropWritable   = Marshal.GetDelegateForFunctionPointer <TIsPropWritable>(NativeApiKernel.GetProcAddress(module, "IsPropWritable"));
            GetPropName      = Marshal.GetDelegateForFunctionPointer <TGetPropName>(NativeApiKernel.GetProcAddress(module, "GetPropName"));
            GetPropVal       = Marshal.GetDelegateForFunctionPointer <TGetPropVal>(NativeApiKernel.GetProcAddress(module, "GetPropVal"));
            SetPropVal       = Marshal.GetDelegateForFunctionPointer <TSetPropVal>(NativeApiKernel.GetProcAddress(module, "SetPropVal"));
            SetVariantEmpty  = Marshal.GetDelegateForFunctionPointer <TSetVariantEmpty>(NativeApiKernel.GetProcAddress(module, "SetVariantEmpty"));
            SetVariantBool   = Marshal.GetDelegateForFunctionPointer <TSetVariantBool>(NativeApiKernel.GetProcAddress(module, "SetVariantBool"));
            SetVariantReal   = Marshal.GetDelegateForFunctionPointer <TSetVariantReal>(NativeApiKernel.GetProcAddress(module, "SetVariantReal"));
            SetVariantBlob   = Marshal.GetDelegateForFunctionPointer <TSetVariantBlob>(NativeApiKernel.GetProcAddress(module, "SetVariantBlob"));
            SetVariantInt    = Marshal.GetDelegateForFunctionPointer <TSetVariantInt>(NativeApiKernel.GetProcAddress(module, "SetVariantInt"));
            SetVariantStr    = Marshal.GetDelegateForFunctionPointer <TSetVariantStr>(NativeApiKernel.GetProcAddress(module, "SetVariantStr"));
            GetVariant       = Marshal.GetDelegateForFunctionPointer <TGetVariant>(NativeApiKernel.GetProcAddress(module, "GetVariant"));
            GetPropVal       = Marshal.GetDelegateForFunctionPointer <TGetPropVal>(NativeApiKernel.GetProcAddress(module, "GetPropVal"));
            GetNMethods      = Marshal.GetDelegateForFunctionPointer <TGetNMethods>(NativeApiKernel.GetProcAddress(module, "GetNMethods"));
            FindMethod       = Marshal.GetDelegateForFunctionPointer <TFindMethod>(NativeApiKernel.GetProcAddress(module, "FindMethod"));
            GetMethodName    = Marshal.GetDelegateForFunctionPointer <TGetMethodName>(NativeApiKernel.GetProcAddress(module, "GetMethodName"));
            GetNParams       = Marshal.GetDelegateForFunctionPointer <TGetNParams>(NativeApiKernel.GetProcAddress(module, "GetNParams"));
            HasParamDefValue = Marshal.GetDelegateForFunctionPointer <THasParamDefValue>(NativeApiKernel.GetProcAddress(module, "HasParamDefValue"));
            GetParamDefValue = Marshal.GetDelegateForFunctionPointer <TGetParamDefValue>(NativeApiKernel.GetProcAddress(module, "GetParamDefValue"));
            HasRetVal        = Marshal.GetDelegateForFunctionPointer <THasRetVal>(NativeApiKernel.GetProcAddress(module, "HasRetVal"));
            CallAsProc       = Marshal.GetDelegateForFunctionPointer <TCallAsProc>(NativeApiKernel.GetProcAddress(module, "CallAsProc"));
            CallAsFunc       = Marshal.GetDelegateForFunctionPointer <TCallAsFunc>(NativeApiKernel.GetProcAddress(module, "CallAsFunc"));
        }