mirror of https://github.com/go-python/gopy.git
all: add hi.Concat(str1, str2)
This commit is contained in:
parent
0cd946cc9f
commit
4144ba4d58
|
@ -89,6 +89,8 @@ hi from go
|
|||
>>> hi.Hello("you")
|
||||
hello you from go
|
||||
|
||||
>>> hi.Concat("hello ","gopy-gen")
|
||||
'hello gopy-gen'
|
||||
```
|
||||
|
||||
## Limitations
|
||||
|
|
|
@ -19,6 +19,11 @@ func Hello(s string) {
|
|||
fmt.Printf("hello %s from go\n", s)
|
||||
}
|
||||
|
||||
// Concat concatenates two strings together and returns the resulting string.
|
||||
func Concat(s1, s2 string) string {
|
||||
return s1 + s2
|
||||
}
|
||||
|
||||
// Add returns the sum of its arguments.
|
||||
func Add(i, j int) int {
|
||||
return i + j
|
||||
|
|
|
@ -88,6 +88,29 @@ gopy_Add(PyObject *self, PyObject *args) {
|
|||
}
|
||||
|
||||
|
||||
/* pythonization of: hi.Concat */
|
||||
static PyObject*
|
||||
gopy_Concat(PyObject *self, PyObject *args) {
|
||||
const char* cgopy_s1;
|
||||
GoString c_s1;
|
||||
const char* cgopy_s2;
|
||||
GoString c_s2;
|
||||
const char* cgopy_gopy_ret;
|
||||
GoString c_gopy_ret;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ss", (GoString*)(&cgopy_s1), (GoString*)(&cgopy_s2))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
c_s1 = _cgopy_makegostring(cgopy_s1);
|
||||
c_s2 = _cgopy_makegostring(cgopy_s2);
|
||||
|
||||
c_gopy_ret = GoPy_Concat(c_s1, c_s2);
|
||||
|
||||
return Py_BuildValue("s", c_gopy_ret);
|
||||
}
|
||||
|
||||
|
||||
/* pythonization of: hi.Hello */
|
||||
static PyObject*
|
||||
gopy_Hello(PyObject *self, PyObject *args) {
|
||||
|
@ -119,6 +142,7 @@ gopy_Hi(PyObject *self, PyObject *args) {
|
|||
|
||||
static PyMethodDef GoPy_hi_Methods[] = {
|
||||
{"Add", gopy_Add, METH_VARARGS, "doc for: hi.Add"},
|
||||
{"Concat", gopy_Concat, METH_VARARGS, "doc for: hi.Concat"},
|
||||
{"Hello", gopy_Hello, METH_VARARGS, "doc for: hi.Hello"},
|
||||
{"Hi", gopy_Hi, METH_VARARGS, "doc for: hi.Hi"},
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
|
|
|
@ -13,33 +13,28 @@ import (
|
|||
|
||||
|
||||
//export GoPy_Add
|
||||
// GoPy_Add wraps hi.Add
|
||||
// github.com/go-python/gopy-gen/_examples/hi.Add
|
||||
// func(i int, j int) int
|
||||
// (i int, j int)
|
||||
// (int)
|
||||
// GoPy_Add wraps github.com/go-python/gopy-gen/_examples/hi.Add
|
||||
func GoPy_Add(i int, j int) int {
|
||||
return hi.Add(i, j)
|
||||
}
|
||||
|
||||
|
||||
//export GoPy_Concat
|
||||
// GoPy_Concat wraps github.com/go-python/gopy-gen/_examples/hi.Concat
|
||||
func GoPy_Concat(s1 string, s2 string) string {
|
||||
return hi.Concat(s1, s2)
|
||||
}
|
||||
|
||||
|
||||
//export GoPy_Hello
|
||||
// GoPy_Hello wraps hi.Hello
|
||||
// github.com/go-python/gopy-gen/_examples/hi.Hello
|
||||
// func(s string)
|
||||
// (s string)
|
||||
// ()
|
||||
// GoPy_Hello wraps github.com/go-python/gopy-gen/_examples/hi.Hello
|
||||
func GoPy_Hello(s string) {
|
||||
hi.Hello(s)
|
||||
}
|
||||
|
||||
|
||||
//export GoPy_Hi
|
||||
// GoPy_Hi wraps hi.Hi
|
||||
// github.com/go-python/gopy-gen/_examples/hi.Hi
|
||||
// func()
|
||||
// ()
|
||||
// ()
|
||||
// GoPy_Hi wraps github.com/go-python/gopy-gen/_examples/hi.Hi
|
||||
func GoPy_Hi() {
|
||||
hi.Hi()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue