NewExportType creates a new `ExportType` with the `name` and the type provided.
(name string, ty AsExternType)
| 13 | |
| 14 | // NewExportType creates a new `ExportType` with the `name` and the type provided. |
| 15 | func NewExportType(name string, ty AsExternType) *ExportType { |
| 16 | nameVec := stringToByteVec(name) |
| 17 | |
| 18 | // Creating an export type requires taking ownership, so create a copy |
| 19 | // so we don't have to invalidate pointers here. Shouldn't be too |
| 20 | // costly in theory anyway. |
| 21 | extern := ty.AsExternType() |
| 22 | ptr := C.wasm_externtype_copy(extern.ptr()) |
| 23 | runtime.KeepAlive(extern) |
| 24 | |
| 25 | // And once we've got all that create the export type! |
| 26 | exportPtr := C.wasm_exporttype_new(&nameVec, ptr) |
| 27 | |
| 28 | return mkExportType(exportPtr, nil) |
| 29 | } |
| 30 | |
| 31 | func mkExportType(ptr *C.wasm_exporttype_t, owner interface{}) *ExportType { |
| 32 | exporttype := &ExportType{_ptr: ptr, _owner: owner} |
searching dependent graphs…