| 120 | #[pyclass] |
| 121 | impl PyExpatLikeXmlParser { |
| 122 | fn new( |
| 123 | namespace_separator: Option<String>, |
| 124 | intern: Option<PyObjectRef>, |
| 125 | vm: &VirtualMachine, |
| 126 | ) -> PyResult<PyExpatLikeXmlParserRef> { |
| 127 | let intern_dict = intern.unwrap_or_else(|| vm.ctx.new_dict().into()); |
| 128 | Ok(Self { |
| 129 | namespace_separator, |
| 130 | start_element: MutableObject::new(vm.ctx.none()), |
| 131 | end_element: MutableObject::new(vm.ctx.none()), |
| 132 | character_data: MutableObject::new(vm.ctx.none()), |
| 133 | entity_decl: MutableObject::new(vm.ctx.none()), |
| 134 | buffer_text: MutableObject::new(vm.ctx.new_bool(false).into()), |
| 135 | namespace_prefixes: MutableObject::new(vm.ctx.new_bool(false).into()), |
| 136 | ordered_attributes: MutableObject::new(vm.ctx.new_bool(false).into()), |
| 137 | specified_attributes: MutableObject::new(vm.ctx.new_bool(false).into()), |
| 138 | intern: MutableObject::new(intern_dict), |
| 139 | // Additional handlers (stubs for compatibility) |
| 140 | processing_instruction: MutableObject::new(vm.ctx.none()), |
| 141 | unparsed_entity_decl: MutableObject::new(vm.ctx.none()), |
| 142 | notation_decl: MutableObject::new(vm.ctx.none()), |
| 143 | start_namespace_decl: MutableObject::new(vm.ctx.none()), |
| 144 | end_namespace_decl: MutableObject::new(vm.ctx.none()), |
| 145 | comment: MutableObject::new(vm.ctx.none()), |
| 146 | start_cdata_section: MutableObject::new(vm.ctx.none()), |
| 147 | end_cdata_section: MutableObject::new(vm.ctx.none()), |
| 148 | default: MutableObject::new(vm.ctx.none()), |
| 149 | default_expand: MutableObject::new(vm.ctx.none()), |
| 150 | not_standalone: MutableObject::new(vm.ctx.none()), |
| 151 | external_entity_ref: MutableObject::new(vm.ctx.none()), |
| 152 | start_doctype_decl: MutableObject::new(vm.ctx.none()), |
| 153 | end_doctype_decl: MutableObject::new(vm.ctx.none()), |
| 154 | xml_decl: MutableObject::new(vm.ctx.none()), |
| 155 | element_decl: MutableObject::new(vm.ctx.none()), |
| 156 | attlist_decl: MutableObject::new(vm.ctx.none()), |
| 157 | skipped_entity: MutableObject::new(vm.ctx.none()), |
| 158 | } |
| 159 | .into_ref(&vm.ctx)) |
| 160 | } |
| 161 | |
| 162 | #[extend_class] |
| 163 | fn extend_class_with_fields(ctx: &Context, class: &'static Py<PyType>) { |