blob: 0b7fc67d41fc6931deed4785fe4d73659e54a63d [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 # variable length arrays do not need special handling in requests,
214 # because the length of Java array is known:
215 field_length = t[2][0]
216
Marek Gradzkid85036f2016-04-26 12:09:05 +0200217 java_field_name = util.underscore_to_camelcase(c_name)
218
219 struct_setter_template = struct_setter_templates[c_type]
220
221 struct_setters += struct_setter_template.substitute(
222 c_name=c_name,
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200223 java_name=java_field_name,
224 field_length=field_length)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200225
226 jni_impl.append(jni_impl_template.substitute(
227 inputfile=inputfile,
228 api_data=util.api_message_to_javadoc(f),
229 java_name=camel_case_function_name,
230 c_name_uppercase=f_name_uppercase,
231 c_name=f_name,
232 request_class=request_class,
233 field_identifiers=field_identifiers,
234 struct_setters=struct_setters,
235 args=arguments))
236
237 return "\n".join(jni_impl)
238
239
240dto_field_id_template = Template("""
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200241 jfieldID ${java_name}FieldId = (*env)->GetFieldID(env, ${class_ref_name}Class, "${java_name}", "${jni_signature}");""")
Marek Gradzkid85036f2016-04-26 12:09:05 +0200242
243default_dto_field_setter_template = Template("""
244 (*env)->Set${jni_setter}(env, dto, ${java_name}FieldId, mp->${c_name});
245""")
246
Marek Gradzkifa42e252016-06-15 16:38:33 +0200247variable_length_array_value_template = Template("""mp->${length_var_name}""")
248variable_length_array_template = Template("""clib_net_to_host_${length_field_type}(${value})""")
249
Marek Gradzki34e77722016-05-30 21:52:37 +0200250u16_dto_field_setter_template = Template("""
251 (*env)->Set${jni_setter}(env, dto, ${java_name}FieldId, clib_net_to_host_u16(mp->${c_name}));
252""")
253
Marek Gradzkid85036f2016-04-26 12:09:05 +0200254u32_dto_field_setter_template = Template("""
255 (*env)->Set${jni_setter}(env, dto, ${java_name}FieldId, clib_net_to_host_u32(mp->${c_name}));
256""")
257
258u64_dto_field_setter_template = Template("""
259 (*env)->Set${jni_setter}(env, dto, ${java_name}FieldId, clib_net_to_host_u64(mp->${c_name}));
260""")
261
262u8_array_dto_field_setter_template = Template("""
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200263 jbyteArray ${java_name} = (*env)->NewByteArray(env, ${field_length});
264 (*env)->SetByteArrayRegion(env, ${java_name}, 0, ${field_length}, (const jbyte*)mp->${c_name});
Marek Gradzkid85036f2016-04-26 12:09:05 +0200265 (*env)->SetObjectField(env, dto, ${java_name}FieldId, ${java_name});
266""")
267
Marek Gradzki97d99512016-06-06 12:36:09 +0200268u32_array_dto_field_setter_template = Template("""
269 {
270 jintArray ${java_name} = (*env)->NewIntArray(env, ${field_length});
271 jint * ${java_name}ArrayElements = (*env)->GetIntArrayElements(env, ${java_name}, NULL);
272 unsigned int _i;
273 for (_i = 0; _i < ${field_length}; _i++) {
274 ${java_name}ArrayElements[_i] = clib_net_to_host_u32(mp->${c_name}[_i]);
275 }
Marek Gradzkifa42e252016-06-15 16:38:33 +0200276
277 (*env)->ReleaseIntArrayElements(env, ${java_name}, ${java_name}ArrayElements, 0);
Marek Gradzki97d99512016-06-06 12:36:09 +0200278 (*env)->SetObjectField(env, dto, ${java_name}FieldId, ${java_name});
279 }
280""")
281
Marek Gradzkid85036f2016-04-26 12:09:05 +0200282# For each u64 array we get its elements. Then we convert values to host byte order.
Marek Gradzki97d99512016-06-06 12:36:09 +0200283# All changes to jlong* buffer are written to jlongArray (isCopy is set to NULL)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200284u64_array_dto_field_setter_template = Template("""
Marek Gradzkid85036f2016-04-26 12:09:05 +0200285 {
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200286 jlongArray ${java_name} = (*env)->NewLongArray(env, ${field_length});
Marek Gradzkid85036f2016-04-26 12:09:05 +0200287 jlong * ${java_name}ArrayElements = (*env)->GetLongArrayElements(env, ${java_name}, NULL);
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200288 unsigned int _i;
289 for (_i = 0; _i < ${field_length}; _i++) {
Marek Gradzkid85036f2016-04-26 12:09:05 +0200290 ${java_name}ArrayElements[_i] = clib_net_to_host_u64(mp->${c_name}[_i]);
291 }
Marek Gradzkifa42e252016-06-15 16:38:33 +0200292
293 (*env)->ReleaseLongArrayElements(env, ${java_name}, ${java_name}ArrayElements, 0);
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200294 (*env)->SetObjectField(env, dto, ${java_name}FieldId, ${java_name});
Marek Gradzkid85036f2016-04-26 12:09:05 +0200295 }
Marek Gradzkid85036f2016-04-26 12:09:05 +0200296""")
297
298dto_field_setter_templates = {'u8': default_dto_field_setter_template,
Marek Gradzki34e77722016-05-30 21:52:37 +0200299 'u16': u16_dto_field_setter_template,
Marek Gradzkid85036f2016-04-26 12:09:05 +0200300 'u32': u32_dto_field_setter_template,
301 'i32': u32_dto_field_setter_template,
302 'u64': u64_dto_field_setter_template,
Marek Gradzki34e77722016-05-30 21:52:37 +0200303 'f64': default_dto_field_setter_template, #fixme
Marek Gradzki97d99512016-06-06 12:36:09 +0200304 'u8[]': u8_array_dto_field_setter_template,
305 'u32[]': u32_array_dto_field_setter_template,
306 'u64[]': u64_array_dto_field_setter_template
Marek Gradzkid85036f2016-04-26 12:09:05 +0200307 }
308
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200309# code fragment for checking result of the operation before sending request reply
310callback_err_handler_template = Template("""
311 // for negative result don't send callback message but send error callback
312 if (mp->retval<0) {
313 CallOnError("${handler_name}",mp->context,mp->retval);
314 return;
315 }
316 if (mp->retval == VNET_API_ERROR_IN_PROGRESS) {
317 clib_warning("Result in progress");
318 return;
319 }
320""")
321
Marek Gradzkid85036f2016-04-26 12:09:05 +0200322msg_handler_template = Template("""
323/**
324 * Handler for ${handler_name} vpe.api message.
325 * Generated based on $inputfile preparsed data:
326$api_data
327 */
328static void vl_api_${handler_name}_t_handler (vl_api_${handler_name}_t * mp)
329{
330 vppjni_main_t * jm = &vppjni_main;
331 JNIEnv *env = jm->jenv;
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200332 $err_handler
Marek Gradzkid85036f2016-04-26 12:09:05 +0200333
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200334 jmethodID constructor = (*env)->GetMethodID(env, ${class_ref_name}Class, "<init>", "()V");
Marek Gradzkid85036f2016-04-26 12:09:05 +0200335 jmethodID callbackMethod = (*env)->GetMethodID(env, jm->callbackClass, "on${dto_name}", "(Lorg/openvpp/jvpp/dto/${dto_name};)V");
336
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200337 jobject dto = (*env)->NewObject(env, ${class_ref_name}Class, constructor);
Marek Gradzkid85036f2016-04-26 12:09:05 +0200338 $dto_setters
339 (*env)->CallVoidMethod(env, jm->callback, callbackMethod, dto);
340}""")
341
342def generate_msg_handlers(func_list, inputfile):
343 handlers = []
344 for f in func_list:
345 handler_name = f['name']
346 dto_name = util.underscore_to_camelcase_upper(handler_name)
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200347 ref_name = util.underscore_to_camelcase(handler_name)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200348
Maros Marsalek7becd082016-05-31 17:45:16 +0200349 if is_manually_generated(handler_name) or util.is_ignored(handler_name):
Marek Gradzkid85036f2016-04-26 12:09:05 +0200350 continue
351
Maros Marsalek7becd082016-05-31 17:45:16 +0200352 if not util.is_reply(dto_name) and not util.is_notification(handler_name):
353 continue
354
355 if util.is_notification(handler_name):
356 dto_name = util.add_notification_suffix(dto_name)
357 ref_name = util.add_notification_suffix(ref_name)
358
Marek Gradzkid85036f2016-04-26 12:09:05 +0200359 dto_setters = ''
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200360 err_handler = ''
Marek Gradzkid85036f2016-04-26 12:09:05 +0200361 # dto setters
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200362 for t in zip(f['c_types'], f['types'], f['args'], f['lengths']):
Marek Gradzkid85036f2016-04-26 12:09:05 +0200363 c_type = t[0]
364 jni_type = t[1]
365 c_name = t[2]
Marek Gradzkifa42e252016-06-15 16:38:33 +0200366 field_length = t[3][0]
367
368 # check if we are processing variable length array
369 if t[3][1]:
370 length_var_name = t[3][0]
371 length_field_type = f['c_types'][f['args'].index(length_var_name)]
372 field_length = variable_length_array_value_template.substitute(length_var_name=length_var_name)
373 if length_field_type != 'u8': # we need net to host conversion:
374 field_length = variable_length_array_template.substitute(
375 length_field_type=length_field_type, value=field_length)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200376
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200377 # for retval don't generate setters and generate retval check
378 if util.is_retval_field(c_name):
379 err_handler = callback_err_handler_template.substitute(
380 handler_name=handler_name
381 )
382 continue
383
Marek Gradzkid85036f2016-04-26 12:09:05 +0200384 java_field_name = util.underscore_to_camelcase(c_name)
385 jni_signature = util.jni_2_signature_mapping[jni_type]
386 jni_setter = util.jni_field_accessors[jni_type]
387
388 dto_setters += dto_field_id_template.substitute(
389 java_name=java_field_name,
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200390 class_ref_name=ref_name,
Marek Gradzkid85036f2016-04-26 12:09:05 +0200391 jni_signature=jni_signature)
392
393 dto_setter_template = dto_field_setter_templates[c_type]
394
395 dto_setters += dto_setter_template.substitute(
396 java_name=java_field_name,
397 jni_signature=jni_signature,
398 c_name=c_name,
Marek Gradzkic4cb44c2016-05-24 13:32:26 +0200399 jni_setter=jni_setter,
400 field_length=field_length)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200401
402 handlers.append(msg_handler_template.substitute(
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200403 inputfile=inputfile,
404 api_data=util.api_message_to_javadoc(f),
405 handler_name=handler_name,
406 dto_name=dto_name,
407 class_ref_name=ref_name,
408 dto_setters=dto_setters,
409 err_handler=err_handler))
Marek Gradzkid85036f2016-04-26 12:09:05 +0200410
411 return "\n".join(handlers)
412
413
414handler_registration_template = Template("""_(${upercase_name}, ${name}) \\
415""")
416
417
418def generate_handler_registration(func_list):
419 handler_registration = ["#define foreach_vpe_api_msg \\\n"]
420 for f in func_list:
421 name = f['name']
422 camelcase_name = util.underscore_to_camelcase(f['name'])
423
Maros Marsalek7becd082016-05-31 17:45:16 +0200424 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 +0200425 continue
426
427 handler_registration.append(handler_registration_template.substitute(
Maros Marsalek7becd082016-05-31 17:45:16 +0200428 name=name,
429 upercase_name=name.upper()))
Marek Gradzkid85036f2016-04-26 12:09:05 +0200430
431 return "".join(handler_registration)
432
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200433
434jvpp_c_template = Template("""/**
Marek Gradzkid85036f2016-04-26 12:09:05 +0200435 * This file contains JNI bindings for jvpp Java API.
436 * It was generated by jvpp_c_gen.py based on $inputfile
437 * (python representation of vpe.api generated by vppapigen).
438 */
439
Tibor Sirovatka42bb61f2016-05-18 14:54:50 +0200440void CallOnError(const char* call, int context, int retval);
441
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200442// JAVA class reference cache
443$class_cache
444
Marek Gradzkid85036f2016-04-26 12:09:05 +0200445// JNI bindings
446$jni_implementations
447
448// Message handlers
449$msg_handlers
450
451// Registration of message handlers in vlib
452$handler_registration
453""")
454
455def generate_jvpp(func_list, inputfile):
456 """ Generates jvpp C file """
457 print "Generating jvpp C"
458
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200459 class_cache = generate_class_cache(func_list)
Marek Gradzkid85036f2016-04-26 12:09:05 +0200460 jni_impl = generate_jni_impl(func_list, inputfile)
461 msg_handlers = generate_msg_handlers(func_list, inputfile)
462 handler_registration = generate_handler_registration(func_list)
463
464 jvpp_c_file = open("jvpp_gen.h", 'w')
465 jvpp_c_file.write(jvpp_c_template.substitute(
466 inputfile=inputfile,
Marek Gradzki0aaf92f2016-05-03 17:05:27 +0200467 class_cache=class_cache,
Marek Gradzkid85036f2016-04-26 12:09:05 +0200468 jni_implementations=jni_impl,
469 msg_handlers=msg_handlers,
470 handler_registration=handler_registration))
471 jvpp_c_file.flush()
472 jvpp_c_file.close()
473