(name string, doc string, self interface{})
| 13 | } |
| 14 | |
| 15 | func NewGoModule(name string, doc string, self interface{}) (mod GoModule, err error) { |
| 16 | |
| 17 | cName := C.CString(name) |
| 18 | defer C.free(unsafe.Pointer(cName)) |
| 19 | |
| 20 | var mdoc *C.char |
| 21 | if doc != "" { |
| 22 | mdoc = C.CString(doc) |
| 23 | defer C.free(unsafe.Pointer(mdoc)) |
| 24 | } |
| 25 | |
| 26 | m := C.Py_InitModule4(cName, nil, mdoc, nil, C.PYTHON_API_VERSION) |
| 27 | if m == nil { |
| 28 | err = exception() |
| 29 | return |
| 30 | } |
| 31 | |
| 32 | mod.Module = (*Module)(unsafe.Pointer(m)) |
| 33 | mod.Ctx = Register(mod.Module.Dict(), name + ".", self) |
| 34 | return |
| 35 | } |
| 36 | |
| 37 | // ------------------------------------------------------------------------------------------ |
| 38 |
searching dependent graphs…