blob: c1169863282aad739399a7435e03863b609df9b1 [file] [log] [blame]
Marek Gradzkid85036f2016-04-26 12:09:05 +02001#!/usr/bin/env python
2#
3# Copyright (c) 2016 Cisco and/or its affiliates.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at:
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9# l
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17import os, util
18from string import Template
19
20def is_manually_generated(f_name):
21 return f_name in {'control_ping_reply'}
22
Marek Gradzki0aaf92f2016-05-03 17:05:27 +020023
24class_reference_template = Template("""jclass ${ref_name}Class;
25""")
26
27find_class_invocation_template = Template("""
28 ${ref_name}Class = (jclass)(*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/openvpp/jvpp/dto/${class_name}"));
29 if ((*env)->ExceptionCheck(env)) {
30 (*env)->ExceptionDescribe(env);
31 return JNI_ERR;
32 }""")
33
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +020034find_class_template = Template("""
35 ${ref_name}Class = (jclass)(*env)->NewGlobalRef(env, (*env)->FindClass(env, "${class_name}"));
36 if ((*env)->ExceptionCheck(env)) {
37 (*env)->ExceptionDescribe(env);
38 return JNI_ERR;
39 }""")
40
Marek Gradzki0aaf92f2016-05-03 17:05:27 +020041class_cache_template = Template("""
42$class_references
43static int cache_class_references(JNIEnv* env) {
44 $find_class_invocations
45 return 0;
46}""")
47
48def generate_class_cache(func_list):
49 class_references = []
50 find_class_invocations = []
51 for f in func_list:
52 c_name = f['name']
53 class_name = util.underscore_to_camelcase_upper(c_name)
54 ref_name = util.underscore_to_camelcase(c_name)
55
Maros Marsalek7becd082016-05-31 17:45:16 +020056 if util.is_ignored(c_name):
Marek Gradzki0aaf92f2016-05-03 17:05:27 +020057 continue
58
Maros Marsalek7becd082016-05-31 17:45:16 +020059 if util.is_reply(class_name):
60 class_references.append(class_reference_template.substitute(
Marek Gradzki0aaf92f2016-05-03 17:05:27 +020061 ref_name=ref_name))
Maros Marsalek7becd082016-05-31 17:45:16 +020062 find_class_invocations.append(find_class_invocation_template.substitute(
Marek Gradzki0aaf92f2016-05-03 17:05:27 +020063 ref_name=ref_name,
64 class_name=class_name))
Maros Marsalek7becd082016-05-31 17:45:16 +020065 elif util.is_notification(c_name):
66 class_references.append(class_reference_template.substitute(
67 ref_name=util.add_notification_suffix(ref_name)))
68 find_class_invocations.append(find_class_invocation_template.substitute(
69 ref_name=util.add_notification_suffix(ref_name),
70 class_name=util.add_notification_suffix(class_name)))
Marek Gradzki0aaf92f2016-05-03 17:05:27 +020071
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +020072 # add exception class to class cache
73 ref_name = 'callbackException'
74 class_name = 'org/openvpp/jvpp/VppCallbackException'
75 class_references.append(class_reference_template.substitute(
76 ref_name=ref_name))
77 find_class_invocations.append(find_class_template.substitute(
78 ref_name=ref_name,
79 class_name=class_name))
Marek Gradzki0aaf92f2016-05-03 17:05:27 +020080 return class_cache_template.substitute(
Maros Marsalek7becd082016-05-31 17:45:16 +020081 class_references="".join(class_references), find_class_invocations="".join(find_class_invocations))
Marek Gradzki0aaf92f2016-05-03 17:05:27 +020082
83
84# TODO: cache method and field identifiers to achieve better performance
Marek Gradzkid85036f2016-04-26 12:09:05 +020085# https://jira.fd.io/browse/HONEYCOMB-42
86request_class_template = Template("""
87 jclass requestClass = (*env)->FindClass(env, "org/openvpp/jvpp/dto/${java_name_upper}");""")
88
89request_field_identifier_template = Template("""
90 jfieldID ${java_name}FieldId = (*env)->GetFieldID(env, requestClass, "${java_name}", "${jni_signature}");
91 ${jni_type} ${java_name} = (*env)->Get${jni_getter}(env, request, ${java_name}FieldId);
92 """)
93
94u8_struct_setter_template = Template("""
95 mp->${c_name} = ${java_name};""")
96
97u16_struct_setter_template = Template("""
98 mp->${c_name} = clib_host_to_net_u16(${java_name});""")
99
100u32_struct_setter_template = Template("""
101 mp->${c_name} = clib_host_to_net_u32(${java_name});""")
102
103i32_struct_setter_template = Template("""
104 mp->${c_name} = clib_host_to_net_i32(${java_name});!""")
105
106u64_struct_setter_template = Template("""
107 mp->${c_name} = clib_host_to_net_u64(${java_name});""")
108
109u8_array_struct_setter_template = Template("""
110 {
111 jsize cnt = (*env)->GetArrayLength (env, ${java_name});
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200112 size_t max_size = ${field_length};
113 if (max_size != 0 && cnt > max_size) cnt = max_size;
Marek Gradzkid85036f2016-04-26 12:09:05 +0200114 (*env)->GetByteArrayRegion(env, ${java_name}, 0, cnt, (jbyte *)mp->${c_name});
115 }
116""")
117
118u32_array_struct_setter_template = Template("""
119 jint * ${java_name}ArrayElements = (*env)->GetIntArrayElements(env, ${java_name}, NULL);
120 {
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200121 size_t _i;
122 jsize cnt = (*env)->GetArrayLength (env, ${java_name});
123 size_t max_size = ${field_length};
124 if (max_size != 0 && cnt > max_size) cnt = max_size;
125 for (_i = 0; _i < cnt; _i++) {
Marek Gradzkid85036f2016-04-26 12:09:05 +0200126 mp->${c_name}[_i] = clib_host_to_net_u32(${java_name}ArrayElements[_i]);
127 }
128 }
129 (*env)->ReleaseIntArrayElements (env, ${java_name}, ${java_name}ArrayElements, 0);
130 """)
131
132vl_api_ip4_fib_counter_t_array_struct_setter_template = Template("""
133 // vl_api_ip4_fib_counter_t_array_field_setter_template FIXME""")
134
135vl_api_ip6_fib_counter_t_array_struct_setter_template = Template("""
136 // vl_api_ip6_fib_counter_t_array_field_setter_template FIXME""")
137
138struct_setter_templates = {'u8': u8_struct_setter_template,
Marek Gradzki34e77722016-05-30 21:52:37 +0200139 'u16': u16_struct_setter_template,
Marek Gradzkid85036f2016-04-26 12:09:05 +0200140 'u32': u32_struct_setter_template,
141 'i32': u32_struct_setter_template,
142 'u64': u64_struct_setter_template,
143 'u8[]': u8_array_struct_setter_template,
144 'u32[]': u32_array_struct_setter_template,
145 'vl_api_ip4_fib_counter_t[]': vl_api_ip4_fib_counter_t_array_struct_setter_template,
146 'vl_api_ip6_fib_counter_t[]': vl_api_ip6_fib_counter_t_array_struct_setter_template
147 }
148
149jni_impl_template = Template("""
150/**
151 * JNI binding for sending ${c_name} vpe.api message.
152 * Generated based on $inputfile preparsed data:
153$api_data
154 */
155JNIEXPORT jint JNICALL Java_org_openvpp_jvpp_JVppImpl_${java_name}0
156(JNIEnv * env, jclass clazz$args) {
157 vppjni_main_t *jm = &vppjni_main;
158 vl_api_${c_name}_t * mp;
159 u32 my_context_id;
160 int rv;
161 rv = vppjni_sanity_check (jm);
162 if (rv) return rv;
163 my_context_id = vppjni_get_context_id (jm);
164 $request_class
165 $field_identifiers
166 M(${c_name_uppercase}, ${c_name});
167 mp->context = clib_host_to_net_u32 (my_context_id);
168 $struct_setters
169 S;
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200170 if ((*env)->ExceptionCheck(env)) {
171 return JNI_ERR;
172 }
Marek Gradzkid85036f2016-04-26 12:09:05 +0200173 return my_context_id;
174}""")
175
176def generate_jni_impl(func_list, inputfile):
177 jni_impl = []
178 for f in func_list:
179 f_name = f['name']
180 camel_case_function_name = util.underscore_to_camelcase(f_name)
181 if is_manually_generated(f_name) or util.is_reply(camel_case_function_name) \
Maros Marsalek7becd082016-05-31 17:45:16 +0200182 or util.is_ignored(f_name) or util.is_just_notification(f_name):
Marek Gradzkid85036f2016-04-26 12:09:05 +0200183 continue
184
185 arguments = ''
186 request_class = ''
187 field_identifiers = ''
188 struct_setters = ''
189 f_name_uppercase = f_name.upper()
190
191 if f['args']:
192 arguments = ', jobject request'
193 camel_case_function_name_upper = util.underscore_to_camelcase_upper(f_name)
194
195 request_class = request_class_template.substitute(java_name_upper=camel_case_function_name_upper)
196
197 # field identifiers
198 for t in zip(f['types'], f['args']):
199 jni_type = t[0]
200 java_field_name = util.underscore_to_camelcase(t[1])
201 jni_signature = util.jni_2_signature_mapping[jni_type]
202 jni_getter = util.jni_field_accessors[jni_type]
203 field_identifiers += request_field_identifier_template.substitute(
204 jni_type=jni_type,
205 java_name=java_field_name,
206 jni_signature=jni_signature,
207 jni_getter=jni_getter)
208
209 # field setters
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200210 for t in zip(f['c_types'], f['args'], f['lengths']):
Marek Gradzkid85036f2016-04-26 12:09:05 +0200211 c_type = t[0]
212 c_name = t[1]
Marek Gradzkifa42e252016-06-15 16:38:33 +0200213 field_length = t[2][0]
214
Marek Gradzki3659a5a2016-07-11 08:35:32 +0200215 # check if we are processing variable length array:
216 if t[2][1]:
217 field_length = util.underscore_to_camelcase(t[2][0])
218
Marek Gradzkid85036f2016-04-26 12:09:05 +0200219 java_field_name = util.underscore_to_camelcase(c_name)
220
221 struct_setter_template = struct_setter_templates[c_type]
222
223 struct_setters += struct_setter_template.substitute(
224 c_name=c_name,
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200225 java_name=java_field_name,
226 field_length=field_length)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200227
228 jni_impl.append(jni_impl_template.substitute(
229 inputfile=inputfile,
230 api_data=util.api_message_to_javadoc(f),
231 java_name=camel_case_function_name,
232 c_name_uppercase=f_name_uppercase,
233 c_name=f_name,
234 request_class=request_class,
235 field_identifiers=field_identifiers,
236 struct_setters=struct_setters,
237 args=arguments))
238
239 return "\n".join(jni_impl)
240
241
242dto_field_id_template = Template("""
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200243 jfieldID ${java_name}FieldId = (*env)->GetFieldID(env, ${class_ref_name}Class, "${java_name}", "${jni_signature}");""")
Marek Gradzkid85036f2016-04-26 12:09:05 +0200244
245default_dto_field_setter_template = Template("""
246 (*env)->Set${jni_setter}(env, dto, ${java_name}FieldId, mp->${c_name});
247""")
248
Marek Gradzkifa42e252016-06-15 16:38:33 +0200249variable_length_array_value_template = Template("""mp->${length_var_name}""")
250variable_length_array_template = Template("""clib_net_to_host_${length_field_type}(${value})""")
251
Marek Gradzki34e77722016-05-30 21:52:37 +0200252u16_dto_field_setter_template = Template("""
253 (*env)->Set${jni_setter}(env, dto, ${java_name}FieldId, clib_net_to_host_u16(mp->${c_name}));
254""")
255
Marek Gradzkid85036f2016-04-26 12:09:05 +0200256u32_dto_field_setter_template = Template("""
257 (*env)->Set${jni_setter}(env, dto, ${java_name}FieldId, clib_net_to_host_u32(mp->${c_name}));
258""")
259
260u64_dto_field_setter_template = Template("""
261 (*env)->Set${jni_setter}(env, dto, ${java_name}FieldId, clib_net_to_host_u64(mp->${c_name}));
262""")
263
264u8_array_dto_field_setter_template = Template("""
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200265 jbyteArray ${java_name} = (*env)->NewByteArray(env, ${field_length});
266 (*env)->SetByteArrayRegion(env, ${java_name}, 0, ${field_length}, (const jbyte*)mp->${c_name});
Marek Gradzkid85036f2016-04-26 12:09:05 +0200267 (*env)->SetObjectField(env, dto, ${java_name}FieldId, ${java_name});
268""")
269
Marek Gradzki97d99512016-06-06 12:36:09 +0200270u32_array_dto_field_setter_template = Template("""
271 {
272 jintArray ${java_name} = (*env)->NewIntArray(env, ${field_length});
273 jint * ${java_name}ArrayElements = (*env)->GetIntArrayElements(env, ${java_name}, NULL);
274 unsigned int _i;
275 for (_i = 0; _i < ${field_length}; _i++) {
276 ${java_name}ArrayElements[_i] = clib_net_to_host_u32(mp->${c_name}[_i]);
277 }
Marek Gradzkifa42e252016-06-15 16:38:33 +0200278
279 (*env)->ReleaseIntArrayElements(env, ${java_name}, ${java_name}ArrayElements, 0);
Marek Gradzki97d99512016-06-06 12:36:09 +0200280 (*env)->SetObjectField(env, dto, ${java_name}FieldId, ${java_name});
281 }
282""")
283
Marek Gradzkid85036f2016-04-26 12:09:05 +0200284# For each u64 array we get its elements. Then we convert values to host byte order.
Marek Gradzki97d99512016-06-06 12:36:09 +0200285# All changes to jlong* buffer are written to jlongArray (isCopy is set to NULL)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200286u64_array_dto_field_setter_template = Template("""
Marek Gradzkid85036f2016-04-26 12:09:05 +0200287 {
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200288 jlongArray ${java_name} = (*env)->NewLongArray(env, ${field_length});
Marek Gradzkid85036f2016-04-26 12:09:05 +0200289 jlong * ${java_name}ArrayElements = (*env)->GetLongArrayElements(env, ${java_name}, NULL);
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200290 unsigned int _i;
291 for (_i = 0; _i < ${field_length}; _i++) {
Marek Gradzkid85036f2016-04-26 12:09:05 +0200292 ${java_name}ArrayElements[_i] = clib_net_to_host_u64(mp->${c_name}[_i]);
293 }
Marek Gradzkifa42e252016-06-15 16:38:33 +0200294
295 (*env)->ReleaseLongArrayElements(env, ${java_name}, ${java_name}ArrayElements, 0);
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200296 (*env)->SetObjectField(env, dto, ${java_name}FieldId, ${java_name});
Marek Gradzkid85036f2016-04-26 12:09:05 +0200297 }
Marek Gradzkid85036f2016-04-26 12:09:05 +0200298""")
299
300dto_field_setter_templates = {'u8': default_dto_field_setter_template,
Marek Gradzki34e77722016-05-30 21:52:37 +0200301 'u16': u16_dto_field_setter_template,
Marek Gradzkid85036f2016-04-26 12:09:05 +0200302 'u32': u32_dto_field_setter_template,
303 'i32': u32_dto_field_setter_template,
304 'u64': u64_dto_field_setter_template,
Marek Gradzki34e77722016-05-30 21:52:37 +0200305 'f64': default_dto_field_setter_template, #fixme
Marek Gradzki97d99512016-06-06 12:36:09 +0200306 'u8[]': u8_array_dto_field_setter_template,
307 'u32[]': u32_array_dto_field_setter_template,
308 'u64[]': u64_array_dto_field_setter_template
Marek Gradzkid85036f2016-04-26 12:09:05 +0200309 }
310
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200311# code fragment for checking result of the operation before sending request reply
312callback_err_handler_template = Template("""
313 // for negative result don't send callback message but send error callback
314 if (mp->retval<0) {
315 CallOnError("${handler_name}",mp->context,mp->retval);
316 return;
317 }
318 if (mp->retval == VNET_API_ERROR_IN_PROGRESS) {
319 clib_warning("Result in progress");
320 return;
321 }
322""")
323
Marek Gradzkid85036f2016-04-26 12:09:05 +0200324msg_handler_template = Template("""
325/**
326 * Handler for ${handler_name} vpe.api message.
327 * Generated based on $inputfile preparsed data:
328$api_data
329 */
330static void vl_api_${handler_name}_t_handler (vl_api_${handler_name}_t * mp)
331{
332 vppjni_main_t * jm = &vppjni_main;
333 JNIEnv *env = jm->jenv;
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200334 $err_handler
Marek Gradzkid85036f2016-04-26 12:09:05 +0200335
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200336 jmethodID constructor = (*env)->GetMethodID(env, ${class_ref_name}Class, "<init>", "()V");
Marek Gradzkid85036f2016-04-26 12:09:05 +0200337 jmethodID callbackMethod = (*env)->GetMethodID(env, jm->callbackClass, "on${dto_name}", "(Lorg/openvpp/jvpp/dto/${dto_name};)V");
338
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200339 jobject dto = (*env)->NewObject(env, ${class_ref_name}Class, constructor);
Marek Gradzkid85036f2016-04-26 12:09:05 +0200340 $dto_setters
341 (*env)->CallVoidMethod(env, jm->callback, callbackMethod, dto);
342}""")
343
344def generate_msg_handlers(func_list, inputfile):
345 handlers = []
346 for f in func_list:
347 handler_name = f['name']
348 dto_name = util.underscore_to_camelcase_upper(handler_name)
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200349 ref_name = util.underscore_to_camelcase(handler_name)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200350
Maros Marsalek7becd082016-05-31 17:45:16 +0200351 if is_manually_generated(handler_name) or util.is_ignored(handler_name):
Marek Gradzkid85036f2016-04-26 12:09:05 +0200352 continue
353
Maros Marsalek7becd082016-05-31 17:45:16 +0200354 if not util.is_reply(dto_name) and not util.is_notification(handler_name):
355 continue
356
357 if util.is_notification(handler_name):
358 dto_name = util.add_notification_suffix(dto_name)
359 ref_name = util.add_notification_suffix(ref_name)
360
Marek Gradzkid85036f2016-04-26 12:09:05 +0200361 dto_setters = ''
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200362 err_handler = ''
Marek Gradzkid85036f2016-04-26 12:09:05 +0200363 # dto setters
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200364 for t in zip(f['c_types'], f['types'], f['args'], f['lengths']):
Marek Gradzkid85036f2016-04-26 12:09:05 +0200365 c_type = t[0]
366 jni_type = t[1]
367 c_name = t[2]
Marek Gradzkifa42e252016-06-15 16:38:33 +0200368 field_length = t[3][0]
369
370 # check if we are processing variable length array
371 if t[3][1]:
372 length_var_name = t[3][0]
373 length_field_type = f['c_types'][f['args'].index(length_var_name)]
374 field_length = variable_length_array_value_template.substitute(length_var_name=length_var_name)
375 if length_field_type != 'u8': # we need net to host conversion:
376 field_length = variable_length_array_template.substitute(
377 length_field_type=length_field_type, value=field_length)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200378
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200379 # for retval don't generate setters and generate retval check
380 if util.is_retval_field(c_name):
381 err_handler = callback_err_handler_template.substitute(
382 handler_name=handler_name
383 )
384 continue
385
Marek Gradzkid85036f2016-04-26 12:09:05 +0200386 java_field_name = util.underscore_to_camelcase(c_name)
387 jni_signature = util.jni_2_signature_mapping[jni_type]
388 jni_setter = util.jni_field_accessors[jni_type]
389
390 dto_setters += dto_field_id_template.substitute(
391 java_name=java_field_name,
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200392 class_ref_name=ref_name,
Marek Gradzkid85036f2016-04-26 12:09:05 +0200393 jni_signature=jni_signature)
394
395 dto_setter_template = dto_field_setter_templates[c_type]
396
397 dto_setters += dto_setter_template.substitute(
398 java_name=java_field_name,
399 jni_signature=jni_signature,
400 c_name=c_name,
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200401 jni_setter=jni_setter,
402 field_length=field_length)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200403
404 handlers.append(msg_handler_template.substitute(
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200405 inputfile=inputfile,
406 api_data=util.api_message_to_javadoc(f),
407 handler_name=handler_name,
408 dto_name=dto_name,
409 class_ref_name=ref_name,
410 dto_setters=dto_setters,
411 err_handler=err_handler))
Marek Gradzkid85036f2016-04-26 12:09:05 +0200412
413 return "\n".join(handlers)
414
415
416handler_registration_template = Template("""_(${upercase_name}, ${name}) \\
417""")
418
419
420def generate_handler_registration(func_list):
421 handler_registration = ["#define foreach_vpe_api_msg \\\n"]
422 for f in func_list:
423 name = f['name']
424 camelcase_name = util.underscore_to_camelcase(f['name'])
425
Maros Marsalek7becd082016-05-31 17:45:16 +0200426 if (not util.is_reply(camelcase_name) and not util.is_notification(name)) or util.is_ignored(name):
Marek Gradzkid85036f2016-04-26 12:09:05 +0200427 continue
428
429 handler_registration.append(handler_registration_template.substitute(
Maros Marsalek7becd082016-05-31 17:45:16 +0200430 name=name,
431 upercase_name=name.upper()))
Marek Gradzkid85036f2016-04-26 12:09:05 +0200432
433 return "".join(handler_registration)
434
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200435
436jvpp_c_template = Template("""/**
Marek Gradzkid85036f2016-04-26 12:09:05 +0200437 * This file contains JNI bindings for jvpp Java API.
438 * It was generated by jvpp_c_gen.py based on $inputfile
439 * (python representation of vpe.api generated by vppapigen).
440 */
441
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200442void CallOnError(const char* call, int context, int retval);
443
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200444// JAVA class reference cache
445$class_cache
446
Marek Gradzkid85036f2016-04-26 12:09:05 +0200447// JNI bindings
448$jni_implementations
449
450// Message handlers
451$msg_handlers
452
453// Registration of message handlers in vlib
454$handler_registration
455""")
456
457def generate_jvpp(func_list, inputfile):
458 """ Generates jvpp C file """
459 print "Generating jvpp C"
460
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200461 class_cache = generate_class_cache(func_list)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200462 jni_impl = generate_jni_impl(func_list, inputfile)
463 msg_handlers = generate_msg_handlers(func_list, inputfile)
464 handler_registration = generate_handler_registration(func_list)
465
466 jvpp_c_file = open("jvpp_gen.h", 'w')
467 jvpp_c_file.write(jvpp_c_template.substitute(
468 inputfile=inputfile,
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200469 class_cache=class_cache,
Marek Gradzkid85036f2016-04-26 12:09:05 +0200470 jni_implementations=jni_impl,
471 msg_handlers=msg_handlers,
472 handler_registration=handler_registration))
473 jvpp_c_file.flush()
474 jvpp_c_file.close()
475