(name, StructType)
| 15770 | function. |
| 15771 | */ |
| 15772 | const StructPtrMapper = function(name, StructType){ |
| 15773 | const __xWrap = __xWrapFactory(name,StructType); |
| 15774 | /** |
| 15775 | This object houses a small API for managing mappings of (`T*`) |
| 15776 | to StructType<T> objects, specifically within the lifetime |
| 15777 | requirements of sqlite3_module methods. |
| 15778 | */ |
| 15779 | return Object.assign(Object.create(null),{ |
| 15780 | /** The StructType object for this object's API. */ |
| 15781 | StructType, |
| 15782 | /** |
| 15783 | Creates a new StructType object, writes its `pointer` |
| 15784 | value to the given output pointer, and returns that |
| 15785 | object. Its intended usage depends on StructType: |
| 15786 | |
| 15787 | sqlite3_vtab: to be called from sqlite3_module::xConnect() |
| 15788 | or xCreate() implementations. |
| 15789 | |
| 15790 | sqlite3_vtab_cursor: to be called from xOpen(). |
| 15791 | |
| 15792 | This will throw if allocation of the StructType instance |
| 15793 | fails or if ppOut is not a pointer-type value. |
| 15794 | */ |
| 15795 | create: (ppOut)=>{ |
| 15796 | const rc = __xWrap(); |
| 15797 | wasm.pokePtr(ppOut, rc.pointer); |
| 15798 | return rc; |
| 15799 | }, |
| 15800 | /** |
| 15801 | Returns the StructType object previously mapped to the |
| 15802 | given pointer using create(). Its intended usage depends |
| 15803 | on StructType: |
| 15804 | |
| 15805 | sqlite3_vtab: to be called from sqlite3_module methods which |
| 15806 | take a (sqlite3_vtab*) pointer _except_ for |
| 15807 | xDestroy()/xDisconnect(), in which case unget() or dispose(). |
| 15808 | |
| 15809 | sqlite3_vtab_cursor: to be called from any sqlite3_module methods |
| 15810 | which take a `sqlite3_vtab_cursor*` argument except xClose(), |
| 15811 | in which case use unget() or dispose(). |
| 15812 | |
| 15813 | Rule to remember: _never_ call dispose() on an instance |
| 15814 | returned by this function. |
| 15815 | */ |
| 15816 | get: (pCObj)=>__xWrap(pCObj), |
| 15817 | /** |
| 15818 | Identical to get() but also disconnects the mapping between the |
| 15819 | given pointer and the returned StructType object, such that |
| 15820 | future calls to this function or get() with the same pointer |
| 15821 | will return the undefined value. Its intended usage depends |
| 15822 | on StructType: |
| 15823 | |
| 15824 | sqlite3_vtab: to be called from sqlite3_module::xDisconnect() or |
| 15825 | xDestroy() implementations or in error handling of a failed |
| 15826 | xCreate() or xConnect(). |
| 15827 | |
| 15828 | sqlite3_vtab_cursor: to be called from xClose() or during |
| 15829 | cleanup in a failed xOpen(). |
no test coverage detected