/
GModule-2.0.d.ts
176 lines (164 loc) · 5.94 KB
/
GModule-2.0.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// @ts-nocheck
/*
* Type Definitions for node-gtk (https://github.com/romgrk/node-gtk)
*
* These type definitions are automatically generated, do not edit them by hand.
* If you found a bug fix it in ts-for-gir itself or create a bug report on https://github.com/sammydre/ts-for-gjs
*/
/**
* GModule-2.0
*/
import type GLib from './GLib-2.0';
import type GObject from './GObject-2.0';
export namespace GModule {
/**
* Errors returned by g_module_open_full().
*/
enum ModuleError {
/**
* there was an error loading or opening a module file
*/
FAILED,
/**
* a module returned an error from its `g_module_check_init()` function
*/
CHECK_FAILED,
}
/**
* Flags passed to g_module_open().
* Note that these flags are not supported on all platforms.
* @bitfield
*/
enum ModuleFlags {
/**
* specifies that symbols are only resolved when
* needed. The default action is to bind all symbols when the module
* is loaded.
*/
LAZY,
/**
* specifies that symbols in the module should
* not be added to the global name space. The default action on most
* platforms is to place symbols in the module in the global name space,
* which may cause conflicts with existing symbols.
*/
LOCAL,
/**
* mask for all flags.
*/
MASK,
}
/**
* A portable way to build the filename of a module. The platform-specific
* prefix and suffix are added to the filename, if needed, and the result
* is added to the directory, using the correct separator character.
*
* The directory should specify the directory where the module can be found.
* It can be %NULL or an empty string to indicate that the module is in a
* standard platform-specific directory, though this is not recommended
* since the wrong module may be found.
*
* For example, calling g_module_build_path() on a Linux system with a
* `directory` of `/lib` and a `module_name` of "mylibrary" will return
* `/lib/libmylibrary.so`. On a Windows system, using `\Windows` as the
* directory it will return `\Windows\mylibrary.dll`.
* @param directory the directory where the module is. This can be %NULL or the empty string to indicate that the standard platform-specific directories will be used, though that is not recommended
* @param moduleName the name of the module
*/
function moduleBuildPath(directory: string | null, moduleName: string): string
/**
* Gets a string describing the last module error.
*/
function moduleError(): string
function moduleErrorQuark(): GLib.Quark
/**
* Checks if modules are supported on the current platform.
*/
function moduleSupported(): boolean
/**
* Specifies the type of the module initialization function.
* If a module contains a function named g_module_check_init() it is called
* automatically when the module is loaded. It is passed the #GModule structure
* and should return %NULL on success or a string describing the initialization
* error.
* @callback
* @param module the #GModule corresponding to the module which has just been loaded
*/
interface ModuleCheckInit {
(module: Module): string
}
/**
* Specifies the type of the module function called when it is unloaded.
* If a module contains a function named g_module_unload() it is called
* automatically when the module is unloaded.
* It is passed the #GModule structure.
* @callback
* @param module the #GModule about to be unloaded
*/
interface ModuleUnload {
(module: Module): void
}
interface Module {
// Owm methods of GModule-2.0.GModule.Module
/**
* Closes a module.
*/
close(): boolean
/**
* Ensures that a module will never be unloaded.
* Any future g_module_close() calls on the module will be ignored.
*/
makeResident(): void
/**
* Returns the filename that the module was opened with.
*
* If `module` refers to the application itself, "main" is returned.
*/
name(): string
/**
* Gets a symbol pointer from a module, such as one exported
* by %G_MODULE_EXPORT. Note that a valid symbol can be %NULL.
* @param symbolName the name of the symbol to find
*/
symbol(symbolName: string): [ /* returnType */ boolean, /* symbol */ object | null ]
}
/**
* The #GModule struct is an opaque data structure to represent a
* [dynamically-loaded module][glib-Dynamic-Loading-of-Modules].
* It should only be accessed via the following functions.
* @record
*/
class Module {
// Own properties of GModule-2.0.GModule.Module
static name: string
// Constructors of GModule-2.0.GModule.Module
/**
* A portable way to build the filename of a module. The platform-specific
* prefix and suffix are added to the filename, if needed, and the result
* is added to the directory, using the correct separator character.
*
* The directory should specify the directory where the module can be found.
* It can be %NULL or an empty string to indicate that the module is in a
* standard platform-specific directory, though this is not recommended
* since the wrong module may be found.
*
* For example, calling g_module_build_path() on a Linux system with a
* `directory` of `/lib` and a `module_name` of "mylibrary" will return
* `/lib/libmylibrary.so`. On a Windows system, using `\Windows` as the
* directory it will return `\Windows\mylibrary.dll`.
* @param directory the directory where the module is. This can be %NULL or the empty string to indicate that the standard platform-specific directories will be used, though that is not recommended
* @param moduleName the name of the module
*/
static buildPath(directory: string | null, moduleName: string): string
/**
* Gets a string describing the last module error.
*/
static error(): string
static errorQuark(): GLib.Quark
/**
* Checks if modules are supported on the current platform.
*/
static supported(): boolean
}
}
export default GModule;