예제 #1
0
//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)
}
예제 #2
0
//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)
}
예제 #3
0
//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)
}
예제 #4
0
//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)
}
예제 #5
0
파일: gofunction.go 프로젝트: MogeiWang/py
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))
}
예제 #6
0
파일: numeric.go 프로젝트: remh/go-python
// 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)))
}
예제 #7
0
func NewLong(i int64) *Long {
	return newLong(C.PyLong_FromLongLong(C.longlong(i)))
}
예제 #8
0
파일: long.go 프로젝트: gbbr/textmate
func NewLong(i int64) *Long {
	return newLong(C.PyLong_FromLongLong(C.PY_LONG_LONG(i)))
}