nspkg / engine / binding.v
25 lines · 21 sloc · 775 bytes · c01b0795d1db56c7bce2539b2c46b110637fdc1a
Raw
1// adapters keep canonical wrapper identity when queries cross handles.
2module engine
3
4pub 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
12pub fn (handle &Handle) binding_context() voidptr {
13 if handle == unsafe { nil } { return unsafe { nil } }
14 return handle.binding_data
15}
16
17pub fn (pkg &Package) binding_context() voidptr {
18 if pkg == unsafe { nil } { return unsafe { nil } }
19 return pkg.owner.binding_context()
20}
21
22pub fn (db &Database) binding_context() voidptr {
23 if db == unsafe { nil } { return unsafe { nil } }
24 return db.owner.binding_context()
25}
26