@@ -940,37 +940,6 @@ class {ListClass}_iterator {{
940
940
"sequence.index(x): x not in sequence");
941
941
}}
942
942
return idx;""" .format (** locals ())))
943
- c .addItem (extractors .CppMethodDef_cffi (
944
- '_new' , isStatic = True ,
945
- pyArgs = extractors .ArgsString ('(WL_Object elements)' ),
946
- pyBody = """\
947
- wrapper_lib.check_args_types(
948
- ({0}._pyobject_mapping_, elements, "elements"))
949
-
950
- keepalive = []
951
- ptrs = []
952
- for item in elements:
953
- if not isinstance(item, {1}):
954
- item = {1}._pyobject_mapping_.convert(item)
955
- keepalive.append(item)
956
- ptrs.append(wrapper_lib.get_ptr(item))
957
-
958
- ptr = call(len(ptrs), ffi.new('void*[]', ptrs))
959
- return wrapper_lib.obj_from_ptr(ptr, {0}, True)
960
- """ .format (ListClass_pyName , ItemClass_pyName ),
961
- cReturnType = 'void *' ,
962
- cArgsString = '(size_t count, void **elements)' ,
963
- # Don't send data to the constructor! This calls virtual methods,
964
- # which are not yet defined in the base C++ class... wx is broken.
965
- cBody = '''
966
- {ListClass} *list = new {ListClass};
967
- list->DeleteContents(true); // tell the list to take ownership of the items
968
- for (Py_ssize_t i = 0; i < count; i++) {{
969
- list->Append(new {ItemClass}(*({ItemClass}*)elements[i]));
970
- }}
971
- return list;
972
- ''' .format (** locals ()),
973
- ))
974
943
# TODO: add support for index(value, [start, [stop]])
975
944
c .addPyMethod (
976
945
'__repr__' , '(self)' ,
@@ -1034,6 +1003,37 @@ class {ListClass}_iterator {{
1034
1003
*sipCppPtr = list;
1035
1004
return SIP_TEMPORARY;
1036
1005
''' .format (** locals ())
1006
+ c .addItem (extractors .CppMethodDef_cffi (
1007
+ '_new' , isStatic = True ,
1008
+ pyArgs = extractors .ArgsString ('(WL_Object elements)' ),
1009
+ pyBody = """\
1010
+ wrapper_lib.check_args_types(
1011
+ ({0}._pyobject_mapping_, elements, "elements"))
1012
+
1013
+ keepalive = []
1014
+ ptrs = []
1015
+ for item in elements:
1016
+ if not isinstance(item, {1}):
1017
+ item = {1}._pyobject_mapping_.convert(item)
1018
+ keepalive.append(item)
1019
+ ptrs.append(wrapper_lib.get_ptr(item))
1020
+
1021
+ ptr = call(len(ptrs), ffi.new('void*[]', ptrs))
1022
+ return wrapper_lib.obj_from_ptr(ptr, {0}, True)
1023
+ """ .format (ListClass_pyName , ItemClass_pyName ),
1024
+ cReturnType = 'void *' ,
1025
+ cArgsString = '(size_t count, void **elements)' ,
1026
+ # Don't send data to the constructor! This calls virtual methods,
1027
+ # which are not yet defined in the base C++ class... wx is broken.
1028
+ cBody = '''
1029
+ {ListClass} *list = new {ListClass};
1030
+ list->DeleteContents(true); // tell the list to take ownership of the items
1031
+ for (Py_ssize_t i = 0; i < count; i++) {{
1032
+ list->Append(new {ItemClass}(*({ItemClass}*)elements[i]));
1033
+ }}
1034
+ return list;
1035
+ ''' .format (** locals ()),
1036
+ ))
1037
1037
1038
1038
c .instanceCheck_cffi = """\
1039
1039
if (not isinstance(py_obj, collections.Sequence) or
0 commit comments