MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / GetStringSlice

Method GetStringSlice

pkg/filament/cpython/object.go:59–78  ·  view source on GitHub ↗

GetStringSlice returns the nth argument as a slice of string values.

(n uint8)

Source from the content-addressed store, hash-verified

57
58// GetStringSlice returns the nth argument as a slice of string values.
59func (args PyArgs) GetStringSlice(n uint8) ([]string, error) {
60 ob := C.PyArg_ParseList((*C.PyObject)(unsafe.Pointer(args)), C.int(n))
61 if ob == nil {
62 return nil, errTypeNotList
63 }
64 l := int(C.PyList_Size(ob))
65 s := make([]string, l)
66 for i := 0; i < l; i++ {
67 item := C.PyList_GetItem(ob, C.longlong(i))
68 if item == nil {
69 continue
70 }
71 isUnicode := bool(C.Py_IsUnicode(item))
72 if !isUnicode {
73 continue
74 }
75 s[i] = fromRawOb(item).String()
76 }
77 return s, nil
78}
79
80// GetSlice returns the nth argument as a slice of generic values.
81func (args PyArgs) GetSlice(n uint8) ([]interface{}, error) {

Callers 1

columnsFnMethod · 0.45

Calls 2

fromRawObFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected