Ejemplo n.º 1
0
Archivo: gofunction.go Proyecto: 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)
}
Ejemplo n.º 2
0
//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)
}
Ejemplo n.º 3
0
// 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)))
}
Ejemplo n.º 4
0
func (l *Long) Int64() int64 {
	return int64(C.PyLong_AsLongLong(c(l)))
}
Ejemplo n.º 5
0
Archivo: long.go Proyecto: MogeiWang/py
func (l *Long) Long() int64 {
	return int64(C.PyLong_AsLongLong(l.c()))
}