Zesstra | 19d4cd4 | 2021-05-07 09:49:10 +0200 | [diff] [blame] | 1 | SYNOPSIS |
| 2 | #include <sys/driver_hooks.h> |
| 3 | |
| 4 | set_driver_hook(H_CREATE_LWOBJECT, value) |
| 5 | |
| 6 | <value> being: |
| 7 | |
| 8 | void <name> (...) |
| 9 | void <closure> () |
| 10 | void <closure> (lwobject obj_to_init, ...) |
| 11 | |
| 12 | DESCRIPTION |
| 13 | Optional hooks to initialize a lightweight object after creation. |
Zesstra | daf2c67 | 2025-08-02 15:59:17 +0200 | [diff] [blame] | 14 | Hook setting can be any closure, or the name of the function |
| 15 | (static or public) to call in the object. |
Zesstra | 19d4cd4 | 2021-05-07 09:49:10 +0200 | [diff] [blame] | 16 | |
Zesstra | daf2c67 | 2025-08-02 15:59:17 +0200 | [diff] [blame] | 17 | If the hook is an unbound lambda closure expecting arguments, |
| 18 | it is bound to the current object and called with the created |
| 19 | object as the first argument and any further arguments from the |
| 20 | new_lwobject() call. If the hook is an unbound lambda closure |
| 21 | without arguments, it is bound to the object to be initalized and |
| 22 | called. If the hook is any other type of closure, it is called |
| 23 | with the created object as the first argument and any further |
| 24 | arguments from the new_lwobject() call. |
Zesstra | 19d4cd4 | 2021-05-07 09:49:10 +0200 | [diff] [blame] | 25 | |
| 26 | If the hook is defined as the name of an lfun in the lightweight |
| 27 | object, it is called in the new lwobject with any further arguments |
| 28 | from the new_lwobject() call. |
| 29 | |
| 30 | HISTORY |
| 31 | LDMud 3.6.5 introduced lightweight objects. |
| 32 | |
| 33 | SEE ALSO |
Zesstra | daf2c67 | 2025-08-02 15:59:17 +0200 | [diff] [blame] | 34 | hooks(C), create_lwobject_copy(H), create_lwobject_restore(H), |
| 35 | create_ob(H), create_super(H), create_clone(H) |