Debian Codegraph @

c/src/encodings.h.py

raw
1 #!/usr/bin/python
2 #
3 # Licensed to the Apache Software Foundation (ASF) under one
4 # or more contributor license agreements. See the NOTICE file
5 # distributed with this work for additional information
6 # regarding copyright ownership. The ASF licenses this file
7 # to you under the Apache License, Version 2.0 (the
8 # "License"); you may not use this file except in compliance
9 # with the License. You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing,
14 # software distributed under the License is distributed on an
15 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 # KIND, either express or implied. See the License for the
17 # specific language governing permissions and limitations
18 # under the License.
19 #
20
21 from __future__ import print_function
22 import mllib
23 import optparse
24 import os
25 import sys
26
27 xml = os.path.join(os.path.dirname(__file__), "types.xml")
28 doc = mllib.xml_parse(xml)
29
30 print("/* generated from %s */" % xml)
31 print("#ifndef _PROTON_ENCODINGS_H")
32 print("#define _PROTON_ENCODINGS_H 1")
33 print()
34 print("#define PNE_DESCRIPTOR (0x00)")
35
36 for enc in doc.query["amqp/section/type/encoding"]:
37 name = enc["@name"] or enc.parent["@name"]
38 # XXX: a bit hacky
39 if name == "ieee-754":
40 name = enc.parent["@name"]
41 cname = "PNE_" + name.replace("-", "_").upper()
42 print("#define %s%s(%s)" % (cname, " " * (20 - len(cname)), enc["@code"]))
43
44 print()
45 print("#endif /* encodings.h */")