MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / string_c_wrap

Function string_c_wrap

tools/api.py:994–1017  ·  view source on GitHub ↗
(p: Parameter)

Source from the content-addressed store, hash-verified

992
993@cwrap('std::string', 'char*')
994def string_c_wrap(p: Parameter) -> None:
995 t = Type('char*')
996 if p.returns:
997 if p.type.is_reference():
998 p.add_param(t.add_pointer())
999 p.bad_param('${name} == nullptr', 'Null pointer')
1000 else:
1001 p.add_param(t)
1002 p.add_param('size_t', p.name + '_size')
1003 p.bad_param('${name} == nullptr', 'Null pointer')
1004 else:
1005 p.add_param(t)
1006 p.bad_param('${name} == nullptr', 'Null pointer')
1007
1008 p.read = '${type}(${name})'
1009 p.cpp_write = '${type}(${name})'
1010 p.virtual_read = ['${name}.c_str()']
1011 if p.type.is_reference():
1012 p.write = ['*${name} = ${result}.c_str()']
1013 else:
1014 p.write = [
1015 'auto* it = std::copy_n(${result}.begin(), std::min(${result}.size(), ${name}_size - 1), ${name});'
1016 '*it = \'\\0\''
1017 ]
1018
1019
1020class Handle:

Callers

nothing calls this directly

Calls 5

add_pointerMethod · 0.95
TypeClass · 0.85
is_referenceMethod · 0.80
bad_paramMethod · 0.80
add_paramMethod · 0.45

Tested by

no test coverage detected