per page, with , order by , clip by
Results of 0 - 1 of about 0 (0.000 sec.)
Extension Mechanism Outline (The GNU Awk User’s Guide)
@digest: 4b19ccdd7fdfb580e3e42c16d2ff0b43
@id: 363616
@mdate: 2023-11-02T13:10:01Z
@size: 7341
@type: text/html
content-type: text/html; charset=utf-8
description: Extension Mechanism Outline (The GNU Awk User’s Guide)
distribution: global
generator: makeinfo
keywords: Extension Mechanism Outline (The GNU Awk User’s Guide)
resource-type: document
viewport: width=device-width,initial-scale=1
#keywords: testext (6721), filefuncs (5742), pointers (1970), extension (1849), gawk (1759), reflecting (1626), registering (1601), understandable (1574), figure (971), informational (914), profiling (781), associates (728), needing (694), attempting (668), straightforward (600), outline (484), function (481), registers (451), shown (438), calling (436), updating (406), licensing (357), somewhat (351), complicated (348), convention (328), extensions (318), passing (278), produces (266), convenience (260), runtime (255), direction (248), loaded (246)
Next: API Description , Previous: Extension Licensing , Up: Writing Extensions for gawk [ Contents ][ Index ] 17.3 How It Works at a High Level ¶ Communication between gawk and an extension is two-way. First, when an extension is loaded, gawk passes it a pointer to a struct whose fields are function pointers. This is shown in Figure 17.1 . Figure 17.1: Loading the extension The extension can call functions inside gawk through these function pointers, at runtime, without needing (link-time) access to gawk 's symbols. One of these function pointers is to a function for “registering” new functions. This is shown in Figure 17.2 . Figure 17.2: Registering a new function In the other direction, the extension registers its new functions with gawk by passing function pointers to the functions that provide the new feature ( do_chdir() , for example). gawk associates the function pointer with a name and can then call it, using a defined calling convention. This is shown in Figure 17.3 . Figure 17.3: Calling the new function The do_ xxx () function, in turn, then uses the function pointers in the API struct to do its work, such as updating variables or arrays, printing messages, setting ERRNO , and so on. Convenience macros make calling through the function pointers look like regular function calls so that extension code is quite readable and understandable. Although all of this sounds somewhat complicated, the result is that extension code is quite straightforward to write and to read. You can see this in the sample extension filefuncs.c (see Example: Some File Functions ) and also in the testext.c code for testing the APIs. Some other bits and pieces: The API provides access to gawk 's do_ xxx values, reflecting command-line options, like do_lint , do_profiling , and so on (see API Variables ). These are informational: an extension cannot affect their values inside gawk . In addition, attempting to assign to them produces a compile-time error. The API also provides major and minor version numbers, so that an extension can check if the gawk it is loaded with supports the facilities it was compiled with. (Version mismatches “shouldn't” happen, but we all know how that goes.) See API Version Constants and Variables for details. Next: API Description , Previous: Extension Licensing , Up: Writing Extensions for gawk [ Contents ][ Index ] ...
http://www.gnu.org/savannah-checkouts/gnu/gawk/manual/html_node/Extension-Mechanism-Outline.html - [detail] - [similar]
PREV NEXT
Powered by Hyper Estraier 1.4.13, with 213332 documents and 1081151 words.