diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2018-02-09 13:42:12 +0100 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2018-03-02 15:22:34 +0000 |
commit | a51ccb5bb56fad29f68f9acafd458fada69bd825 (patch) | |
tree | c155c143fc1289ab33d48abbe4d7fba8f88add1b /src/vpp-api/java/jvpp/gen/jvppgen/enum_gen.py | |
parent | 371ca50a74a9c4f1b74c4c1b65c6fdec610fcfc3 (diff) |
jvpp: object model for jvpp generator (VPP-1184)
Introduces JSON parser which builds object model of Java API.
Also rewrites JNI translation of typedefs
to use per type translation functions
instead of code inlining.
Not covered:
- integrate with vappigen plugin (VPP-1154) or vapi parser (VPP-1155)
- use better templating engine (VPP-480)
- improvements of generator structure (e.g. VPP-1186)
Change-Id: I9e12d76c2f3c6ee041669f58e8a37917f656aa90
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'src/vpp-api/java/jvpp/gen/jvppgen/enum_gen.py')
-rw-r--r-- | src/vpp-api/java/jvpp/gen/jvppgen/enum_gen.py | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/enum_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/enum_gen.py deleted file mode 100644 index 51a74e678e2..00000000000 --- a/src/vpp-api/java/jvpp/gen/jvppgen/enum_gen.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2018 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import util -import jni_gen - - -def generate_enums(enum_list, inputfile, logger): - """ - Generates Java representation of enum types defined in the provided JSON file. - """ - - if not enum_list: - logger.debug("Skipping enum generation (%s does not define enum types)." % inputfile) - return - - logger.debug("Generating enums for %s" % inputfile) - - for enum in enum_list: - enum_name = None - enum_type = None - for e in enum: - if isinstance(e, basestring): - enum_name = e - elif type(e) is dict and 'enumtype' in e: - enum_type = e['enumtype'] - - if not enum_name: - logger.warn("%s enum is missing name. Skipping" % enum) - continue - - if not enum_type: - logger.warn("%s enum is missing value type. Skipping" % enum) - continue - - # TODO(VPP-1153): add real enum support. - # But first refactor java api generation - # (either VPP-1154 or VPP-1155, see also VPP-480). - - # As a workaround we just update all the mappings - # used for VPP API definitions to JAVA and C/JNI translation. - enum_array_type = enum_type + "[]" - type_name = "vl_api_" + enum_name + "_t" - array_type_name = type_name + "[]" - util.vpp_2_jni_type_mapping[type_name] = util.vpp_2_jni_type_mapping[enum_type] - util.vpp_2_jni_type_mapping[array_type_name] = util.vpp_2_jni_type_mapping[enum_array_type] - util.jni_2_java_type_mapping[type_name] = util.jni_2_java_type_mapping[enum_type] - util.jni_2_java_type_mapping[array_type_name] = util.jni_2_java_type_mapping[enum_array_type] - util.jni_2_signature_mapping[type_name] = util.jni_2_signature_mapping[enum_type] - util.jni_2_signature_mapping[array_type_name] = util.jni_2_signature_mapping[enum_array_type] - util.jni_field_accessors[type_name] = util.jni_field_accessors[enum_type] - util.jni_field_accessors[array_type_name] = util.jni_field_accessors[enum_array_type] - jni_gen.struct_setter_templates[type_name] = jni_gen.struct_setter_templates[enum_type] - jni_gen.struct_setter_templates[array_type_name] = jni_gen.struct_setter_templates[enum_array_type] - jni_gen.dto_field_setter_templates[type_name] = jni_gen.dto_field_setter_templates[enum_type] - jni_gen.dto_field_setter_templates[array_type_name] = jni_gen.dto_field_setter_templates[enum_array_type] |