Exemplo n.º 1
0
    def setUp(self):
        super(TestReferencingToSelfDefinedType, self).setUp()
        name = type(self).__name__

        hdr = Header(name.lower() + ".h")
        m = Macro("M_OTHER_TYPE", text="int")
        hdr.add_type(m)

        ht = Header("macro_types.h")
        ht.add_type(Macro("M_TYPE", text="M_OTHER_TYPE"))
        ht.add_reference(m)

        hdr.add_global_variable(Type["M_TYPE"]("var"))

        hdr_content = """\
/* {path} */
#ifndef INCLUDE_{fname_upper}_H
#define INCLUDE_{fname_upper}_H

#define M_OTHER_TYPE int

#include "macro_types.h"

extern M_TYPE var;
#endif /* INCLUDE_{fname_upper}_H */
""".format(path=hdr.path, fname_upper=name.upper())

        self.files = [(hdr, hdr_content)]
Exemplo n.º 2
0
    def setUp(self):
        super(TestReferencingToTypeInAnotherHeader, self).setUp()
        name = type(self).__name__

        hdr = Header(name.lower() + ".h")

        h1 = Header("some_types.h")
        h2 = Header("another_some_types.h")

        h1.add_type(Type("f1", incomplete=False))
        h2.add_type(Type("f2", incomplete=False))

        # Without reference headers `another_some_types` and `some_types` would
        # be in alphabetical order.
        h2.add_reference(Type["f1"])

        s = Structure("S", Type["f1"]("field1"), Type["f2"]("field2"))
        hdr.add_type(s)

        hdr_content = """\
/* {path} */
#ifndef INCLUDE_{fname_upper}_H
#define INCLUDE_{fname_upper}_H

#include "some_types.h"
#include "another_some_types.h"

typedef struct S {{
    f1 field1;
    f2 field2;
}} S;

#endif /* INCLUDE_{fname_upper}_H */
""".format(path=hdr.path, fname_upper=name.upper())

        self.files = [(hdr, hdr_content)]