polar-objc 5.44
An Objective-C runtime library
Loading...
Searching...
No Matches
polar-method-tree-iterator.c
1/* Internal API: method tree iterator type for polar-objc.
2 Copyright (C) 2022-2025 Michael Malicoat <[email protected]>
3
4 This file is part of polar-objc.
5
6 polar-objc is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
8
9 polar-objc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 details.
12
13 You should have received a copy of the GNU General Public License along with this program; see the file LICENSE. If
14 not, see <http://www.gnu.org/licenses/>.
15*/
16
17// polar_method_tree_iterator ******************************************************************************************
18// Private =============================================================================================================
19
20// This variable is initialized in polar_method_tree_iterator_get_type()
21static polar_method_tree_iterator_class class_polar_method_tree_iterator;
22
23// This variable is initialized in _polar_method_tree_iterator_class_init()
24static polar_runtime_object_class *superclass_polar_method_tree_iterator = NULL;
25
26// ---------------------------------------------------------------------------------------------------------------------
27
28POLAR_FUNCTION_INTERNAL BOOL
29_polar_method_tree_iterator_get_next( polar_method_tree_iterator *self, void **out_next_element )
30{
31 assert( out_next_element != NULL );
32 assert( ((polar_btree_iterator *)self)->tree_target != NULL );
33
34 // Chain up
35 if( POLAR_ITERATOR_CLASS(superclass_polar_method_tree_iterator)->get_next((polar_iterator *)self, out_next_element) )
36 return YES;
37
38 if( (self->tree_next != NULL) && (self->tree_next != OBJC_CLASS_METHOD_TREE_LIST_END) )
39 {
40 ( (polar_btree_iterator *)self )->tree_target = (polar_btree *)(self->tree_next);
41 ( (polar_btree_iterator *)self )->node_current = NULL;
42 ( (polar_btree_iterator *)self )->idx_current = 0;
43
44 self->tree_next = (polar_method_tree *)( ((polar_list_node *)(self->tree_next))->node_next );
45
46 return
47 POLAR_ITERATOR_CLASS(superclass_polar_method_tree_iterator)->get_next( (polar_iterator *)self, out_next_element );
48 }
49
50 return NO;
51}
52
53POLAR_FUNCTION_INTERNAL void
54_polar_method_tree_iterator_class_init( polar_method_tree_iterator_class *self )
55{
56 // Acquire our superclass
57 superclass_polar_method_tree_iterator = POLAR_RUNTIME_OBJECT_CLASS(self)->class_superclass;
58
59 // Establish our virtual methods
60 ( (polar_iterator_class *)self )->get_next = (void *)_polar_method_tree_iterator_get_next;
61}
62
63static struct polar_internal_type_info pti_polar_method_tree_iterator =
64{
65 .name_type = "polar_method_tree_iterator",
66 .size_type_instance = sizeof(polar_method_tree_iterator),
67 .size_type_class = sizeof(polar_method_tree_iterator_class),
68 .type_class_init = (polar_func_runtime_object_class_lifecycle)_polar_method_tree_iterator_class_init
69};
70
71// Public ==============================================================================================================
72
73POLAR_FUNCTION_INTERNAL OBJC_FUNCTION_CONSTANT polar_internal_type
74polar_method_tree_iterator_get_type( void )
75{
76 static polar_internal_type pt_polar_method_tree_iterator = POLAR_INTERNAL_TYPE_INVALID;
77
78 if( pt_polar_method_tree_iterator != POLAR_INTERNAL_TYPE_INVALID )
79 return pt_polar_method_tree_iterator;
80
81 pt_polar_method_tree_iterator = polar_internal_type_init( POLAR_TYPE_BTREE_ITERATOR,
82 &class_polar_method_tree_iterator,
83 &pti_polar_method_tree_iterator );
84
85 return pt_polar_method_tree_iterator;
86}
Definition polar-btree-iterator.h:25
Definition polar-btree.h:25
Definition polar-internal-type.h:34
Definition polar-iterator.h:30
Definition polar-iterator.h:25
Definition polar-list-node.h:25
Definition polar-method-tree-iterator.h:30
Definition polar-method-tree-iterator.h:24
Definition polar-method-tree.h:24
Definition polar-runtime-object.h:36