blib/lib/SPVM/Document/NativeAPI/BasicType.pm untested

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a SCAR -
1 =head1 Name
2  
3 SPVM::Document::NativeAPI::BasicType - Basic Type Native APIs
4  
5 =head1 Description
6  
7 The basic type native APIs in L<SPVM> are the APIs to get definition information for basic types.
8  
9 =head1 Usage
10  
11 int32_t error_id;
12
13 SPVM_API_BASIC_TYPE* api_basic_type = env->api->basic_type;
14
15 SPVM_NATIVE_BASIC_TYPE* basic_type = env->get_basic_type(env, stack, "Int");
16
17 const char* basic_type_name = api_basic_type->get_name(env->runtime, basic_type);
18  
19 =head1 Native APIs
20  
21 =head2 get_name
22  
23 C<const char* (*get_name)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
24  
25 Returns the name of the basic type I<basic_type>.
26  
27 =head2 get_id
28  
29 C<int32_t (*get_id)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
30  
31 Returns the ID of the basic type I<basic_type>.
32  
33 =head2 get_category
34  
35 C<int32_t (*get_category)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
36  
37 Returns the L<base type category ID|SPVM::Document::NativeAPI/"Basic Type Category IDs"> of the basic type I<basic_type>.
38  
39 =head2 get_parent
40  
41 C<SPVM_NATIVE_BASIC_TYPE* (*get_parent)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
42  
43 Returns the parent L<basic type|SPVM::Document::NativeAPI::BasicType> object of the basic type I<basic_type>.
44  
45 =head2 get_version_string
46  
47 C<const char* (*get_version_string)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
48  
49 Returns the version string of the basic type I<basic_type>.
50  
51 =head2 get_class_dir
52  
53 C<const char* (*get_class_dir)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
54  
55 Returns the class directory of the basic type I<basic_type>.
56  
57 =head2 get_class_rel_file
58  
59 C<const char* (*get_class_rel_file)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
60  
61 Returns the class relative file of the basic type I<basic_type>.
62  
63 =head2 is_pointer
64  
65 C<int32_t (*is_pointer)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
66  
67 If the basic type I<basic_type> is a pointer class, returns 1, otherwise returns 0.
68  
69 =head2 is_anon
70  
71 C<int32_t (*is_anon)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
72  
73 If the basic type I<basic_type> is an anon class, returns 1, otherwise returns 0.
74  
75 =head2 get_class_var_by_index
76  
77 C<SPVM_NATIVE_CLASS_VAR* (*get_class_var_by_index)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t class_var_index);>
78  
79 Searches a L<class variable|SPVM::Document::NativeAPI::ClassVariable> owned by the basic type I<basic_type> given the class variable index I<class_var_index>.
80  
81 If it is found, returns it. Otherwise, returns C<NULL>.
82  
83 =head2 get_class_var_by_name
84  
85 C<SPVM_NATIVE_CLASS_VAR* (*get_class_var_by_name)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, const char* class_var_name);>
86  
87 Searches a L<class variable|SPVM::Document::NativeAPI::ClassVariable> owned by the basic type I<basic_type> given the class variable name I<class_var_name>.
88  
89 If it is found, returns it. Otherwise, returns C<NULL>.
90  
91 =head2 get_class_vars_length
92  
93 C<int32_t (*get_class_vars_length)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
94  
95 Returns the length of the class variables owned by the basic type I<basic_type>.
96  
97 =head2 get_field_by_index
98  
99 C<SPVM_NATIVE_FIELD* (*get_field_by_index)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t field_index);>
100  
101 Searches a L<field|SPVM::Document::NativeAPI::Field> owned by the basic type I<basic_type> given the field index I<field_index>.
102  
103 If it is found, returns it. Otherwise, returns C<NULL>.
104  
105 =head2 get_field_by_name
106  
107 C<SPVM_NATIVE_FIELD* (*get_field_by_name)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, const char* field_name);>
108  
109 Searches a L<field|SPVM::Document::NativeAPI::Field> owned by the basic type I<basic_type> given the field name I<field_name>.
110  
111 If it is found, returns it. Otherwise, returns C<NULL>.
112  
113 =head2 get_fields_length
114  
115 C<int32_t (*get_fields_length)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
116  
117 Returns the length of the fields owned by the basic type I<basic_type>.
118  
119 =head2 get_method_by_index
120  
121 C<SPVM_NATIVE_METHOD* (*get_method_by_index)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t method_index);>
122  
123 Searches a L<method|SPVM::Document::NativeAPI::Method> owned by the basic type I<basic_type> given the method index I<method_index>.
124  
125 If it is found, returns it. Otherwise, returns C<NULL>.
126  
127 =head2 get_method_by_name
128  
129 C<SPVM_NATIVE_METHOD* (*get_method_by_name)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, const char* method_name);>
130  
131 Searches a L<method|SPVM::Document::NativeAPI::Method> owned by the basic type I<basic_type> given the method name I<method_name>.
132  
133 If it is found, returns it. Otherwise, returns C<NULL>.
134  
135 =head2 get_methods_length
136  
137 C<int32_t (*get_methods_length)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
138  
139 Returns the length of the methods owned by the basic type I<basic_type>.
140  
141 =head2 get_anon_basic_type_by_index
142  
143 C<SPVM_NATIVE_BASIC_TYPE* (*get_anon_basic_type_by_index)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t anon_basic_type_index);>
144  
145 Searches an anon L<basic type|SPVM::Document::NativeAPI::BasicType> owned by the basic type I<basic_type> given an anon basic type index I<anon_basic_type_index>.
146  
147 If it is found, returns it. Otherwise, returns C<NULL>.
148  
149 =head2 get_anon_basic_types_length
150  
151 C<int32_t (*get_anon_basic_types_length)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
152  
153 Returns the length of the anon basic types owned by the basic type I<basic_type>.
154  
155 =head2 has_interface
156  
157 C<int32_t (*has_interface)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, L<SPVM_NATIVE_BASIC_TYPE* interface_basic_type|SPVM::Document::NativeAPI::BasicType>);>
158  
159 If the basic type I<basic_type> has an interface I<interface_basic_type>, returns 1, otherwise returns 0.
160  
161 =head2 is_super_class
162  
163 C<int32_t (*is_super_class)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* dist_basic_type|SPVM::Document::NativeAPI::BasicType>, L<SPVM_NATIVE_BASIC_TYPE* src_basic_type|SPVM::Document::NativeAPI::BasicType>);>
164  
165 If I<dist_basic_type> is a super class of I<src_basic_type>, returns 1, otherwise returns 0.
166  
167 =head2 get_file
168  
169 C<const char* (*get_file)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
170  
171 Returns the file path of the basic type I<basic_type>.
172  
173 This can be changed by a file directive.
174  
175 #file /templates/foo.html.ep
176 class Foo {
177
178 }
179  
180 =head2 get_current_runtime
181  
182 C<SPVM_NATIVE_RUNTIME* (*get_current_runtime)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
183  
184 Returns the runtime that owns the basic type I<basic_type>.
185  
186 =head2 get_basic_type_in_version_from
187  
188 C<SPVM_NATIVE_BASIC_TYPE* (*get_basic_type_in_version_from)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
189  
190 Returns the L<basic type|SPVM::Document::NativeAPI::BasicType> object specified by C<version_from> statement.
191  
192 =head2 get_fields_size
193  
194 C<int32_t (*get_fields_size)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
195  
196 Returns the total byte size of the fields.
197  
198 =head2 get_monitor_var_type
199  
200 C<int32_t (*get_monitor_var_type)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>, int32_t* ret_basic_type_id, int32_t* ret_dimension, int32_t* ret_flag);>
201  
202 If the basic type I<basic_type> has the C<$^MONITOR> special variable, its basic type ID is set to I<ret_basic_type_id>, its dimension is set to I<ret_dimension>, its type flag is set to I<ret_flag>, and returns 0. Otherwise returns 1.
203  
204 I<ret_basic_type_id>, I<ret_dimension>, and I<ret_flag> must not be NULL, or the program asserts.
205  
206 =head2 has_monitor_var
207  
208 C<int32_t (*has_monitor_var)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
209  
210 If the basic type I<basic_type> has the C<$^MONITOR> special variable, returns 1. Otherwise returns 0.
211  
212 =head2 has_monitor_var
213  
214 C<int32_t (*has_monitor_var)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
215  
216 If the basic type I<basic_type> has the C<$^MONITOR> special variable, returns 1. Otherwise returns 0.
217  
218 =head2 is_generated_from_anon_method
219  
220 C<int32_t (*is_generated_from_anon_method)(L<SPVM_NATIVE_RUNTIME* runtime|SPVM::Document::NativeAPI::Runtime>, L<SPVM_NATIVE_BASIC_TYPE* basic_type|SPVM::Document::NativeAPI::BasicType>);>
221  
222 If the basic type I<basic_type> is generated from an anonymous method, returns 1. Otherwise returns 0.
223  
224 =head1 Native API IDs
225  
226 0 get_name
227 1 get_id
228 2 get_category
229 3 get_parent
230 4 get_version_string
231 5 get_class_dir
232 6 get_class_rel_file
233 7 is_pointer
234 8 is_anon
235 9 get_class_var_by_index
236 10 get_class_var_by_name
237 11 get_class_vars_length
238 12 get_field_by_index
239 13 get_field_by_name
240 14 get_fields_length
241 15 get_method_by_index
242 16 get_method_by_name
243 17 get_methods_length
244 18 get_anon_basic_type_by_index
245 19 get_anon_basic_types_length
246 20 has_interface
247 21 is_super_class
248 22 get_file
249 23 get_current_runtime
250 24 get_basic_type_in_version_from
251 25 get_fields_size
252 26 get_monitor_var_type
253 27 has_monitor_var
254 28 is_generated_from_anon_method
255
256 =head1 See Also
257  
258 =over 2
259  
260 =item * L<SPVM::Document::NativeAPI>
261  
262 =item * L<SPVM::Document::NativeAPI::Type>
263  
264 =item * L<SPVM::Document::NativeClass>
265  
266 =item * L<SPVM::Document>
267  
268 =back
269  
270 =head1 Copyright & License
271  
272 Copyright (c) 2023 Yuki Kimoto
273  
274 MIT License