//export sumof3 func sumof3(self, args *C.PyObject) *C.PyObject { var a, b, c C.longlong if C.PyArg_ParseTuple_LLL(args, &a, &b, &c) == 0 { return nil } return C.PyLong_FromLongLong(a + b + c) }
//export sum func sum(self, args *C.PyObject) *C.PyObject { var a, b C.longlong if C.PyArg_ParseTuple_LL(args, &a, &b) == 0 { return nil } return C.PyLong_FromLongLong(a + b) }
//export generate_mosaic func generate_mosaic(self, args *C.PyObject) *C.PyObject { var inputImg, outImg, analysis *C.char if C.PyArg_ParseTuple_SSS(args, &inputImg, &outImg, &analysis) == 0 { return nil } err := mosaic.AnalyzeTarget(C.GoString(inputImg), C.GoString(analysis), C.GoString(outImg)) fmt.Println(err) return C.PyLong_FromLongLong(1) }
//export download func download(self, args *C.PyObject) *C.PyObject { // fmt.Println(args) var tag, dir, apiKey *C.char var count C.int if C.PyArg_ParseTuple_SISS(args, &tag, &count, &dir, &apiKey) == 0 { return nil } client.Download(C.GoString(tag), int(count), C.GoString(dir), C.GoString(apiKey)) return C.PyLong_FromLongLong(1) }
func (closure *Closure) NewFunction(name string, nin int, doc string) *Base { d := &closure.methodDef d.ml_name = C.CString(name) defer C.free(unsafe.Pointer(d.ml_name)) if C.setMethod(d, C.int(nin)) != 0 { panic("Invalid arguments: nin") } if doc != "" { d.ml_doc = C.CString(doc) defer C.free(unsafe.Pointer(d.ml_doc)) } ctx := uintptr(unsafe.Pointer(closure)) self := C.PyLong_FromLongLong(C.longlong(ctx)) defer C.decref(self) f := C.PyCFunction_NewEx(d, self, nil) return (*Base)(unsafe.Pointer(f)) }
// PyObject* PyLong_FromLongLong(PY_LONG_LONG v) // Return value: New reference. // Return a new PyLongObject object from a C long long, or NULL on failure. func PyLong_FromLongLong(v int64) *PyObject { return togo(C.PyLong_FromLongLong(C.PY_LONG_LONG(v))) }
func NewLong(i int64) *Long { return newLong(C.PyLong_FromLongLong(C.longlong(i))) }
func NewLong(i int64) *Long { return newLong(C.PyLong_FromLongLong(C.PY_LONG_LONG(i))) }