Ejemplo n.º 1
0
        static CFArray()
        {
            var handle = Dlfcn.dlopen(Constants.CoreFoundationLibrary, 0);

            if (handle == IntPtr.Zero)
            {
                return;
            }
            try {
                kCFTypeArrayCallbacks_ptr = Dlfcn.GetIndirect(handle, "kCFTypeArrayCallBacks");
            }
            finally {
                Dlfcn.dlclose(handle);
            }
        }
Ejemplo n.º 2
0
        static CGPDFPageInfo()
        {
            IntPtr h = Dlfcn.dlopen(Constants.CoreGraphicsLibrary, 0);

            try
            {
                kCGPDFContextMediaBox = Dlfcn.GetIndirect(h, "kCGPDFContextMediaBox");
                kCGPDFContextCropBox  = Dlfcn.GetIndirect(h, "kCGPDFContextCropBox");
                kCGPDFContextBleedBox = Dlfcn.GetIndirect(h, "kCGPDFContextBleedBox");
                kCGPDFContextTrimBox  = Dlfcn.GetIndirect(h, "kCGPDFContextTrimBox");
                kCGPDFContextArtBox   = Dlfcn.GetIndirect(h, "kCGPDFContextArtBox");
            }
            finally
            {
                Dlfcn.dlclose(h);
            }
        }
Ejemplo n.º 3
0
        public void SymbolExists()
        {
            var failed_api = new List <string> ();

            Errors = 0;
            int c = 0, n = 0;

            foreach (MethodInfo mi in pinvokeQuery)
            {
                if (LogProgress)
                {
                    Console.WriteLine("{0}. {1}", c++, mi);
                }

                var dllimport = mi.GetCustomAttribute <DllImportAttribute> ();

                string libname = dllimport.Value;
                if (libname == "__Internal" || SkipLibrary(libname))
                {
                    continue;
                }

                string path = FindLibrary(dllimport.Value, requiresFullPath: true);

                string name = dllimport.EntryPoint ?? mi.Name;
                if (Skip(name))
                {
                    continue;
                }

                IntPtr lib = Dlfcn.dlopen(path, 0);
                if (Dlfcn.GetIndirect(lib, name) == IntPtr.Zero)
                {
                    ReportError("Could not find the field '{0}' in {1}", name, path);
                    failed_api.Add(name);
                }
                Dlfcn.dlclose(lib);
                n++;
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} functions validated: {2}", Errors, n, string.Join(", ", failed_api));
        }
Ejemplo n.º 4
0
        public void FieldExists()
        {
            var failed_fields = new List <string> ();

            Errors = 0;
            int n = 0;

            foreach (var p in AllProperties())
            {
                var f = p.GetCustomAttribute <FieldAttribute> ();
                if (f == null)
                {
                    continue;
                }

                string name = f.SymbolName;
                if (Skip(name, f.LibraryName))
                {
                    continue;
                }

                string path = FindLibrary(f.LibraryName);
                IntPtr lib  = Dlfcn.dlopen(path, 0);
                if (lib == IntPtr.Zero)
                {
                    ReportError("Could not open the library '{0}' to find the field '{1}': {2}", path, name, Dlfcn.dlerror());
                    failed_fields.Add(name);
                }
                else if (Dlfcn.GetIndirect(lib, name) == IntPtr.Zero)
                {
                    ReportError("Could not find the field '{0}' in {1}", name, path);
                    failed_fields.Add(name);
                }
                Dlfcn.dlclose(lib);
                n++;
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} fields validated: {2}", Errors, n, string.Join(", ", failed_fields));
        }
Ejemplo n.º 5
0
        public void SymbolExists()
        {
            var failed_api = new HashSet <string> ();

            Errors = 0;
            int c = 0, n = 0;

            foreach (MethodInfo mi in pinvokeQuery)
            {
                if (LogProgress)
                {
                    Console.WriteLine("{0}. {1}", c++, mi);
                }

                var dllimport = mi.GetCustomAttribute <DllImportAttribute> ();

                string libname = dllimport.Value;
                switch (libname)
                {
                case "__Internal":
                    continue;

                case "System.Native":
                case "System.Security.Cryptography.Native.Apple":
                case "System.Net.Security.Native":
                    if (MonoNativeConfig.LinkMode == MonoNativeLinkMode.None)
                    {
                        continue;
                    }
#if __IOS__
                    libname = MonoNativeConfig.GetPInvokeLibraryName(MonoNativeFlavor.Compat, MonoNativeConfig.LinkMode);
#else
                    libname = null;
#endif
                    break;
                }

                if (SkipLibrary(libname))
                {
                    continue;
                }

                string path = FindLibrary(libname, requiresFullPath: true);

                string name = dllimport.EntryPoint ?? mi.Name;
                if (Skip(name))
                {
                    continue;
                }

                IntPtr lib = Dlfcn.dlopen(path, 0);
                if (Dlfcn.GetIndirect(lib, name) == IntPtr.Zero && !failed_api.Contains(name))
                {
                    ReportError("Could not find the field '{0}' in {1}", name, path);
                    failed_api.Add(name);
                }
                Dlfcn.dlclose(lib);
                n++;
            }
            Assert.AreEqual(0, Errors, "{0} errors found in {1} functions validated: {2}", Errors, n, string.Join(", ", failed_api));
        }