no more submodule

This commit is contained in:
2024-09-15 22:40:48 +02:00
parent df3b8a3135
commit 0234b33671
5804 changed files with 943618 additions and 1 deletions

View File

@@ -0,0 +1,117 @@
using System;
using System.Runtime.InteropServices;
class FuncLoader
{
private class Windows
{
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr LoadLibraryW(string lpszLib);
}
private class Linux
{
[DllImport("libdl.so.2")]
public static extern IntPtr dlopen(string path, int flags);
[DllImport("libdl.so.2")]
public static extern IntPtr dlsym(IntPtr handle, string symbol);
}
private class OSX
{
[DllImport("/usr/lib/libSystem.dylib")]
public static extern IntPtr dlopen(string path, int flags);
[DllImport("/usr/lib/libSystem.dylib")]
public static extern IntPtr dlsym(IntPtr handle, string symbol);
}
private class Unix
{
[DllImport("libc")]
public static extern IntPtr dlopen(string path, int flags);
[DllImport("libc")]
public static extern IntPtr dlsym(IntPtr handle, string symbol);
}
[DllImport("libc")]
private static extern int uname(IntPtr buf);
private const int RTLD_LAZY = 0x0001;
private const int RTLD_GLOBAL = 0x0100;
public static bool IsWindows, IsOSX, IsLinux;
static FuncLoader()
{
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
IsWindows = true;
break;
case PlatformID.MacOSX:
IsOSX = true;
break;
case PlatformID.Unix:
try
{
var buf = Marshal.AllocHGlobal(8192);
if (uname(buf) == 0 && Marshal.PtrToStringAnsi(buf) == "Darwin")
IsOSX = true;
if (uname(buf) == 0 && Marshal.PtrToStringAnsi(buf) == "Linux")
IsLinux = true;
Marshal.FreeHGlobal(buf);
}
catch { }
break;
}
}
public static IntPtr LoadLibrary(string libname)
{
if (IsWindows)
return Windows.LoadLibraryW(libname);
if (IsOSX)
return OSX.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY);
if (IsLinux)
return Linux.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY);
return Unix.dlopen(libname, RTLD_GLOBAL | RTLD_LAZY);
}
public static IntPtr GetProcAddress(IntPtr library, string function)
{
var ret = IntPtr.Zero;
if (IsWindows)
ret = Windows.GetProcAddress(library, function);
else if (IsOSX)
ret = OSX.dlsym(library, function);
else if (IsLinux)
ret = Linux.dlsym(library, function);
else
ret = Unix.dlsym(library, function);
return ret;
}
public static T LoadFunction<T>(IntPtr procaddress)
{
if (procaddress == IntPtr.Zero)
return default(T);
return Marshal.GetDelegateForFunctionPointer<T>(procaddress);
}
}

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
class GLibrary
{
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetDllDirectory(string lpPathName);
private static Dictionary<Library, IntPtr> _libraries;
private static HashSet<Library> _librariesNotFound;
private static Dictionary<string, IntPtr> _customlibraries;
private static Dictionary<Library, string[]> _libraryDefinitions;
static GLibrary()
{
_customlibraries = new Dictionary<string, IntPtr>();
_librariesNotFound = new HashSet<Library>();
_libraries = new Dictionary<Library, IntPtr>();
_libraryDefinitions = new Dictionary<Library, string[]>();
_libraryDefinitions[Library.GLib] = new[] {"libglib-2.0-0.dll", "libglib-2.0.so.0", "libglib-2.0.0.dylib", "glib-2.dll"};
_libraryDefinitions[Library.GObject] = new[] {"libgobject-2.0-0.dll", "libgobject-2.0.so.0", "libgobject-2.0.0.dylib", "gobject-2.dll"};
_libraryDefinitions[Library.Cairo] = new[] {"libcairo-2.dll", "libcairo.so.2", "libcairo.2.dylib", "cairo.dll"};
_libraryDefinitions[Library.Gio] = new[] {"libgio-2.0-0.dll", "libgio-2.0.so.0", "libgio-2.0.0.dylib", "gio-2.dll"};
_libraryDefinitions[Library.Atk] = new[] {"libatk-1.0-0.dll", "libatk-1.0.so.0", "libatk-1.0.0.dylib", "atk-1.dll"};
_libraryDefinitions[Library.Pango] = new[] {"libpango-1.0-0.dll", "libpango-1.0.so.0", "libpango-1.0.0.dylib", "pango-1.dll"};
_libraryDefinitions[Library.Gdk] = new[] {"libgdk-3-0.dll", "libgdk-3.so.0", "libgdk-3.0.dylib", "gdk-3.dll"};
_libraryDefinitions[Library.GdkPixbuf] = new[] {"libgdk_pixbuf-2.0-0.dll", "libgdk_pixbuf-2.0.so.0", "libgdk_pixbuf-2.0.dylib", "gdk_pixbuf-2.dll"};
_libraryDefinitions[Library.Gtk] = new[] {"libgtk-3-0.dll", "libgtk-3.so.0", "libgtk-3.0.dylib", "gtk-3.dll"};
_libraryDefinitions[Library.PangoCairo] = new[] {"libpangocairo-1.0-0.dll", "libpangocairo-1.0.so.0", "libpangocairo-1.0.0.dylib", "pangocairo-1.dll"};
_libraryDefinitions[Library.GtkSource] = new[] {"libgtksourceview-4-0.dll", "libgtksourceview-4.so.0", "libgtksourceview-4.0.dylib", "gtksourceview-4.dll"};
_libraryDefinitions[Library.Webkit] = new[] { "libwebkit2gtk-4.0.dll", "libwebkit2gtk-4.0.so.37", "libwebkit2gtk-4.0.dylib", "libwebkit2gtk-4.0.0.dll" };
}
public static IntPtr Load(Library library)
{
if (_libraries.TryGetValue(library, out var ret))
return ret;
if (TryGet(library, out ret)) return ret;
var err = library + ": " + string.Join(", ", _libraryDefinitions[library]);
throw new DllNotFoundException(err);
}
public static bool IsSupported(Library library) => TryGet(library, out var __);
static bool TryGet(Library library, out IntPtr ret)
{
ret = IntPtr.Zero;
if (_libraries.TryGetValue(library, out ret)) {
return true;
}
if (_librariesNotFound.Contains(library)) {
return false;
}
if (FuncLoader.IsWindows) {
ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][0]);
if (ret == IntPtr.Zero) {
SetDllDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Gtk", "3.24.24"));
ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][0]);
}
} else if (FuncLoader.IsOSX) {
ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][2]);
if (ret == IntPtr.Zero) {
ret = FuncLoader.LoadLibrary("/usr/local/lib/" + _libraryDefinitions[library][2]);
if (ret == IntPtr.Zero) {
ret = FuncLoader.LoadLibrary("/opt/homebrew/lib/" + _libraryDefinitions[library][2]);
}
}
} else
ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][1]);
if (ret == IntPtr.Zero) {
for (var i = 0; i < _libraryDefinitions[library].Length; i++) {
ret = FuncLoader.LoadLibrary(_libraryDefinitions[library][i]);
if (ret != IntPtr.Zero)
break;
}
}
if (ret != IntPtr.Zero) {
_libraries[library] = ret;
} else {
_librariesNotFound.Add(library);
}
return ret != IntPtr.Zero;
}
}

View File

@@ -0,0 +1,368 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation xml:lang="en">
GAPI XML schema.
Copyright 2013 Bertrand Lorentz.
This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the Lesser GNU General
Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
</xs:documentation>
</xs:annotation>
<!-- Top-level tag-->
<xs:element name="api">
<xs:complexType>
<xs:sequence>
<xs:element name="namespace" type="namespaceType" maxOccurs="unbounded"/>
<xs:element name="symbol" type="symbolType" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="parser_version" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
<xs:complexType name="namespaceType">
<xs:choice maxOccurs="unbounded">
<xs:element name="enum" type="enumType"/>
<xs:element name="callback" type="callbackType"/>
<xs:element name="interface" type="interfaceType"/>
<xs:element name="object" type="objectType"/>
<xs:element name="struct" type="structType"/>
<xs:element name="boxed" type="boxedType"/>
<xs:element name="alias" type="aliasType"/>
<xs:element name="class" type="classType"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="library" type="xs:string"/>
</xs:complexType>
<xs:complexType name="symbolType">
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="default_value" type="xs:string" use="optional"/>
<xs:attribute name="marshal_type" type="xs:string" use="optional"/>
<xs:attribute name="call_fmt" type="xs:string" use="optional"/>
<xs:attribute name="from_fmt" type="xs:string" use="optional"/>
</xs:complexType>
<!-- Definitions for Generatables -->
<xs:complexType name="aliasType">
<xs:sequence>
<xs:element name="field" type="fieldType" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="type" type="xs:string"/>
</xs:complexType>
<xs:complexType name="boxedType">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="method" type="methodType"/>
<xs:element name="constructor" type="constructorType"/>
<xs:element name="field" type="fieldType"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="opaque" type="xs:boolean" use="optional"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
<xs:attribute name="noequals" type="xs:boolean" use="optional"/>
<xs:attribute name="nohash" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="callbackType">
<xs:sequence>
<xs:element name="return-type" type="return-typeType"/>
<xs:element name="parameters" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="parameter" type="method-parameterType" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="classType">
<xs:sequence>
<xs:element name="method" type="methodType" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
<xs:attribute name="internal" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="enumType">
<xs:sequence>
<xs:element name="member" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="gtype" type="xs:string" use="optional"/>
<xs:attribute name="type" type="xs:string" use="optional"/>
<xs:attribute name="deprecated" type="xs:boolean" use="optional"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="interfaceType">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="class_struct" type="class_structType"/>
<xs:element name="constructor" type="constructorType"/>
<xs:element name="property" type="propertyType"/>
<xs:element name="method" type="methodType"/>
<xs:element name="virtual_method" type="virtual_methodType"/>
<xs:element name="signal" type="signalType"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="consume_only" type="xs:boolean" use="optional"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="objectType">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="class_struct" type="class_structType"/>
<xs:element name="implements" type="implementsType"/>
<xs:element name="constructor" type="constructorType"/>
<xs:element name="field" type="fieldType"/>
<xs:element name="property" type="propertyType"/>
<xs:element name="childprop" type="propertyType"/>
<xs:element name="method" type="methodType"/>
<xs:element name="virtual_method" type="virtual_methodType"/>
<xs:element name="signal" type="signalType"/>
<xs:element name="static-string" type="static-stringType"/>
<xs:element name="custom-attribute" type="xs:string"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
<xs:attribute name="parent" type="xs:string" use="optional"/>
<xs:attribute name="disable_void_ctor" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="structType">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="method" type="methodType"/>
<xs:element name="constructor" type="constructorType"/>
<xs:element name="field" type="fieldType"/>
<xs:element name="callback" type="callbackType"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="deprecated" type="xs:boolean" use="optional"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
<xs:attribute name="opaque" type="xs:boolean" use="optional"/>
</xs:complexType>
<!-- Definitions for the elements in Generatables -->
<xs:complexType name="class_structType">
<xs:choice maxOccurs="unbounded">
<xs:element name="field" type="fieldType" maxOccurs="unbounded"/>
<xs:element name="method" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:attribute name="vm" type="xs:string" use="optional"/>
<xs:attribute name="padding" type="xs:string" use="optional"/>
<xs:attribute name="signal_vm" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="private" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="constructorType">
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="parameters">
<xs:complexType>
<xs:sequence>
<xs:element name="parameter" type="constructor-parameterType" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="return-type" type="return-typeType"/>
</xs:choice>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="deprecated" type="xs:boolean" use="optional"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
<xs:attribute name="preferred" type="xs:boolean" use="optional"/>
<xs:attribute name="shared" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="fieldType">
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="padding" type="xs:boolean" use="optional"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="array" type="xs:boolean" use="optional"/>
<xs:attribute name="array_len" type="xs:positiveInteger" use="optional"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
<xs:attribute name="access" type="xs:string" use="optional"/>
<xs:attribute name="writeable" type="xs:boolean" use="optional"/>
<xs:attribute name="bits" type="xs:positiveInteger" use="optional"/>
</xs:complexType>
<xs:complexType name="implementsType">
<xs:sequence>
<xs:element name="interface" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="methodType">
<xs:sequence>
<xs:element name="return-type" type="return-typeType"/>
<xs:element name="parameters" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="parameter" type="method-parameterType" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="shared" type="xs:boolean" use="optional"/>
<xs:attribute name="new_flag" type="xs:boolean" use="optional"/>
<xs:attribute name="library" type="xs:string" use="optional"/>
<xs:attribute name="deprecated" type="xs:boolean" use="optional"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="propertyType">
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="construct" type="xs:boolean" use="optional"/>
<xs:attribute name="construct-only" type="xs:boolean" use="optional"/>
<xs:attribute name="new_flag" type="xs:boolean" use="optional"/>
<xs:attribute name="hidden" type="xs:boolean" use="optional"/>
<xs:attribute name="readable" type="xs:boolean" use="optional"/>
<xs:attribute name="writeable" type="xs:boolean" use="optional"/>
<xs:attribute name="deprecated" type="xs:boolean" use="optional"/>
<xs:attribute name="style" type="xs:boolean" use="optional"/>
</xs:complexType>
<xs:complexType name="signalType">
<xs:complexContent>
<xs:extension base="methodType">
<xs:attribute name="when" type="whenType" use="optional"/>
<xs:attribute name="field_name" type="xs:string" use="optional"/>
<xs:attribute name="block_glue" type="xs:boolean" use="optional"/>
<xs:attribute name="manual" type="xs:boolean" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="static-stringType">
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="cname" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>
<xs:complexType name="virtual_methodType">
<xs:complexContent>
<xs:extension base="methodType">
<xs:attribute name="override_in" type="override_inType" use="optional"/>
<xs:attribute name="padding" type="xs:boolean" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- Definitions for lower-level elements -->
<xs:complexType name="parameterType">
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="array" type="xs:boolean" use="optional"/>
<xs:attribute name="array_len" type="xs:positiveInteger" use="optional"/>
<xs:attribute name="null_term_array" type="xs:boolean" use="optional"/>
<xs:attribute name="ellipsis" type="xs:boolean" use="optional"/>
<xs:attribute name="owned" type="xs:boolean" use="optional"/>
<xs:attribute name="printf_format" type="xs:boolean" use="optional"/>
<xs:attribute name="printf_format_args" type="xs:boolean" use="optional"/>
<xs:attribute name="scope" type="scopeType" use="optional"/>
</xs:complexType>
<xs:complexType name="constructor-parameterType">
<xs:complexContent>
<xs:extension base="parameterType">
<xs:attribute name="property_name" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="method-parameterType">
<xs:complexContent>
<xs:extension base="parameterType">
<xs:attribute name="pass_as" type="pass_asType" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="return-typeType">
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="element_type" type="xs:string" use="optional"/>
<xs:attribute name="owned" type="xs:boolean" use="optional"/>
<xs:attribute name="elements_owned" type="xs:boolean" use="optional"/>
<xs:attribute name="null_term_array" type="xs:boolean" use="optional"/>
<xs:attribute name="array_length_param" type="xs:string" use="optional"/>
</xs:complexType>
<!-- Definitions for allowed values -->
<xs:simpleType name="pass_asType">
<xs:restriction base="xs:string">
<xs:enumeration value="out"/>
<xs:enumeration value="ref"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="override_inType">
<xs:restriction base="xs:string">
<xs:enumeration value="declaring_class"/>
<xs:enumeration value="implementing_class"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="scopeType">
<xs:restriction base="xs:string">
<xs:enumeration value="call"/>
<xs:enumeration value="async"/>
<xs:enumeration value="notify"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="whenType">
<xs:restriction base="xs:string">
<xs:enumeration value="CLEANUP"/>
<xs:enumeration value="FIRST"/>
<xs:enumeration value="LAST"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@@ -0,0 +1,16 @@
enum Library
{
GLib,
GObject,
Cairo,
Gio,
Atk,
Pango,
PangoCairo,
Gdk,
GdkPixbuf,
Gtk,
GtkSource,
Webkit
}