//export Tick func Tick(self, args *C.PyObject) *C.PyObject { go func() { for range time.NewTicker(time.Second).C { log.Println("tick") } }() return C.PyLong_FromLong(0) }
//export goClassNatGet func goClassNatGet(obj unsafe.Pointer, idx int) unsafe.Pointer { field := getField(idx) item := unsafe.Pointer(uintptr(obj) + field.Offset) switch field.Type.Kind() { case reflect.Int: i := (*int)(item) return unsafe.Pointer(C.PyLong_FromLong(C.long(*i))) } raise(NotImplementedError.ErrV(None)) return nil }
//export gil func gil(self, args *C.PyObject) *C.PyObject { var res *C.PyObject tState := C.PyEval_SaveThread() var mu sync.Mutex mu.Lock() go func() { C.PyEval_RestoreThread(tState) res = C.PyLong_FromLong(1) mu.Unlock() }() mu.Lock() return res }
// PyObject* PyLong_FromLong(long v) // Return value: New reference. // Return a new PyLongObject object from v, or NULL on failure. func PyLong_FromLong(v int) *PyObject { return togo(C.PyLong_FromLong(C.long(v))) }