(p: Parameter)
| 948 | |
| 949 | @cwrap('std::vector') |
| 950 | def vector_c_wrap(p: Parameter) -> None: |
| 951 | inner = p.type.inner_type() |
| 952 | # Not a generic type |
| 953 | if not inner: |
| 954 | return |
| 955 | if inner.str() in c_type_map: |
| 956 | inner = c_type_map[inner.str()] |
| 957 | |
| 958 | t = inner.add_pointer() |
| 959 | if p.type.is_reference(): |
| 960 | if p.type.is_const(): |
| 961 | t = t.add_const() |
| 962 | if p.returns: |
| 963 | if p.type.is_reference(): |
| 964 | p.add_param(t.add_pointer()) |
| 965 | p.add_size_param() |
| 966 | p.bad_param('${name} == nullptr or ${size} == nullptr', |
| 967 | 'Null pointer') |
| 968 | elif p.virtual: |
| 969 | p.add_param(t) |
| 970 | p.add_size_param() |
| 971 | p.bad_param('${name} == nullptr or ${size} == nullptr', |
| 972 | 'Null pointer') |
| 973 | p.virtual_write = '{${name}.begin(), ${name}.begin()+${size}}; // cppcheck-suppress returnDanglingLifetime' |
| 974 | else: |
| 975 | p.add_param(t) |
| 976 | p.bad_param('${name} == nullptr', 'Null pointer') |
| 977 | else: |
| 978 | p.add_param(t) |
| 979 | p.add_size_param() |
| 980 | p.bad_param('${name} == nullptr and ${size} != 0', 'Null pointer') |
| 981 | |
| 982 | p.read = '${type}(${name}, ${name}+${size})' |
| 983 | p.cpp_write = '${type}(${name}, ${name}+${size})' |
| 984 | p.virtual_read = ['${name}.data()', '${name}.size()'] |
| 985 | if p.type.is_reference(): |
| 986 | p.write = [ |
| 987 | '*${name} = ${result}.data()', '*${size} = ${result}.size()' |
| 988 | ] |
| 989 | else: |
| 990 | p.write = ['std::copy(${result}.begin(), ${result}.end(), ${name})'] |
| 991 | |
| 992 | |
| 993 | @cwrap('std::string', 'char*') |
nothing calls this directly
no test coverage detected