コード例 #1
0
ファイル: gofunction.go プロジェクト: bxd/py
//export goClassCallMethodArgs
func goClassCallMethodArgs(obj, args unsafe.Pointer) unsafe.Pointer {

	// Unpack context and self pointer from obj
	t := (*C.PyObject)(obj)
	closure := (*Closure)(unsafe.Pointer(uintptr(C.PyLong_AsLongLong(t))))

	// Get args ready to use, by turning it into a pointer of the appropriate
	// type
	a := (*Tuple)(args)

	in := []reflect.Value{closure[0], reflect.ValueOf(a)}
	out := closure[1].Call(in)

	err := out[1].Interface()
	if err != nil {
		Raise(err.(error))
		return nil
	}

	ret := out[0].Interface().(*Base)
	return unsafe.Pointer(ret)
}
コード例 #2
0
ファイル: gofunction.go プロジェクト: MogeiWang/py
//export goClassCallMethodKwds
func goClassCallMethodKwds(obj, args, kwds unsafe.Pointer) unsafe.Pointer {

	// Unpack context and self pointer from obj
	t := (*C.PyObject)(obj)
	closure := (*Closure)(unsafe.Pointer(uintptr(C.PyLong_AsLongLong(t))))

	// Get args and kwds ready to use, by turning them into pointers of the
	// appropriate type
	a := (*Tuple)(args)
	k := (*Dict)(kwds)

	in := []reflect.Value{closure.Self, reflect.ValueOf(a), reflect.ValueOf(k)}
	out := closure.Method.Call(in)

	err := out[1].Interface()
	if err != nil {
		Raise(err.(error))
		return nil
	}

	ret := out[0].Interface().(*Base)
	return unsafe.Pointer(ret)
}
コード例 #3
0
ファイル: numeric.go プロジェクト: remh/go-python
// PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong)
// Return a C long long from a Python long integer. If pylong cannot be represented as a long long, an OverflowError is raised and -1 is returned.
//
// New in version 2.2.
func PyLong_AsLongLong(self *PyObject) int64 {
	return int64(C.PyLong_AsLongLong(topy(self)))
}
コード例 #4
0
ファイル: long.go プロジェクト: ericsnowcurrently/qur-gopy
func (l *Long) Int64() int64 {
	return int64(C.PyLong_AsLongLong(c(l)))
}
コード例 #5
0
ファイル: long.go プロジェクト: MogeiWang/py
func (l *Long) Long() int64 {
	return int64(C.PyLong_AsLongLong(l.c()))
}