| 1 | // adapters keep canonical wrapper identity when queries cross handles. |
| 2 | module engine |
| 3 | |
| 4 | pub fn (mut handle Handle) bind_context(context voidptr) ! { |
| 5 | handle.require_live()! |
| 6 | if context == unsafe { nil } || handle.binding_data != unsafe { nil } { |
| 7 | return handle.fail(.wrong_args, 'binding context is null or already set') |
| 8 | } |
| 9 | handle.binding_data = context |
| 10 | } |
| 11 | |
| 12 | pub fn (handle &Handle) binding_context() voidptr { |
| 13 | if handle == unsafe { nil } { return unsafe { nil } } |
| 14 | return handle.binding_data |
| 15 | } |
| 16 | |
| 17 | pub fn (pkg &Package) binding_context() voidptr { |
| 18 | if pkg == unsafe { nil } { return unsafe { nil } } |
| 19 | return pkg.owner.binding_context() |
| 20 | } |
| 21 | |
| 22 | pub fn (db &Database) binding_context() voidptr { |
| 23 | if db == unsafe { nil } { return unsafe { nil } } |
| 24 | return db.owner.binding_context() |
| 25 | } |
| 26 | |