PyArgsParseKeywords parses tuple and keywords arguments.
(args PyArgs, kwargs PyKwargs, kwlist []string)
| 118 | |
| 119 | // PyArgsParseKeywords parses tuple and keywords arguments. |
| 120 | func PyArgsParseKeywords(args PyArgs, kwargs PyKwargs, kwlist []string) (string, string, string, []string) { |
| 121 | var ( |
| 122 | ob1 *C.PyObject |
| 123 | ob2 *C.PyObject |
| 124 | ob3 *C.PyObject |
| 125 | ob4 *C.PyObject |
| 126 | ) |
| 127 | |
| 128 | klist := make([]*C.char, len(kwlist)+1) |
| 129 | |
| 130 | for i, k := range kwlist { |
| 131 | klist[i] = C.CString(k) |
| 132 | defer C.free(unsafe.Pointer(klist[i])) |
| 133 | } |
| 134 | |
| 135 | C.PyArg_ParseKeywords( |
| 136 | (*C.PyObject)(unsafe.Pointer(args)), |
| 137 | (*C.PyObject)(unsafe.Pointer(kwargs)), |
| 138 | &klist[0], |
| 139 | (**C.PyObject)(unsafe.Pointer(&ob1)), |
| 140 | (**C.PyObject)(unsafe.Pointer(&ob2)), |
| 141 | (**C.PyObject)(unsafe.Pointer(&ob3)), |
| 142 | (**C.PyObject)(unsafe.Pointer(&ob4)), |
| 143 | ) |
| 144 | |
| 145 | return fromRawOb(ob1).String(), fromRawOb(ob2).String(), fromRawOb(ob3).String(), fromRawOb(ob4).StringSlice() |
| 146 | } |
| 147 | |
| 148 | // PyObject is the main abstraction for manipulating the native CPython objects. |
| 149 | type PyObject struct { |
no test coverage detected