def resolveInterfacePath(self, decl_or_type):
     name = builtin_plugin.getJavaBuiltinType(self.target_info,
                                              decl_or_type.pointeeType)
     cname = 'Const' + name[0].upper() + name[1:]
     vname = 'C' + name[0].upper() + name[1:]
     cpath = jpath.JPath(("primitives", cname, 'Ptr'))
     vpath = jpath.JPath(("primitives", vname, 'Ptr'))
     if decl_or_type.pointeeType.isConstQualified:
         name = cname
         klass = jclass.Interface
         self.creator.setNamespace(jclass.Class, vpath)
     else:
         name = vname
         klass = jclass.Class
         self.creator.setNamespace(jclass.Interface,
                                   jpath.JPath((
                                       "primitives",
                                       cname,
                                   )))
         self.creator.setNamespace(jclass.Interface, cpath)
     if decl_or_type.pointeeType.spelling != "void":
         self.creator.getClass(
             bc.LValueReferenceType(
                 bc.BuiltinType(decl_or_type.pointeeType.spelling)))
         self.creator.resolveInterfacePath(
             bc.PointerType(bc.BuiltinType("void")))
         self.creator.getClass(bc.PointerType(bc.BuiltinType("void")))
     self.creator.setNamespace(jclass.Interface,
                               jpath.JPath((
                                   "primitives",
                                   name,
                               )))
     pjp = jpath.JPath(("primitives", name, 'Ptr'))
     self.classes[decl_or_type.pointeeType.spelling] = cpath, vpath
     return klass, pjp
Beispiel #2
0
 def resolveInterfacePath(self, decl_or_type):
     decl, is_const = parseType(decl_or_type)
     klass, jp = self.creator.resolveInterfacePath(decl_or_type.pointeeType)
     klass = jclass.Class
     if not is_const:
         self.creator.getClass(
             bc.PointerType(bc.RecordType(decl, isConstQualified=True)))
         klass = PointerClass
     njp = jpath.JPath(jp.path + ('Ptr', ))
     self.classes[jp.path] = decl_or_type
     return klass, njp
Beispiel #3
0
 def linkEnd(self):
     for i in self.classes:
         decl = self.classes[i].pointeeType.decl
         isConstQualified = self.classes[i].pointeeType.isConstQualified
         c = self.creator.getClass(self.classes[i])
         intf = self.creator.getInterface(self.classes[i].pointeeType)
         intf2 = self.creator.getClass(self.classes[i].pointeeType)
         # print ">>", i, self.classes[i]
         fn = 'at'
         if isConstQualified:
             fn = 'cAt'
         f = PointerAtDecl(
             decl.name + "::" + fn,
             None,
             bc.LValueReferenceType(
                 bc.RecordType(decl, isConstQualified=isConstQualified)),
             [bc.ParmVarDecl(
                 "index",
                 bc.BuiltinType("int"),
             )],
             decl,
             isConstQualified=isConstQualified)
         conv = self.creator.getFunctionConverter(f)
         c.addFunction(conv)
         fn = 'ref'
         if isConstQualified:
             fn = 'cref'
         f = getPointerFunctionDecl(
             decl.name + "::" + fn, None,
             bc.PointerType(
                 bc.RecordType(decl, isConstQualified=isConstQualified)),
             [], decl)
         conv = self.creator.getFunctionConverter(f)
         # print intf, intf2, conv
         intf.addFunction(conv)
         intf2.addFunction(conv)
         if not isConstQualified:
             d = self.creator.getClass(
                 bc.PointerType(bc.RecordType(decl, isConstQualified=True)))
             c.setBaseClass(d)
    def linkEnd(self):
        for spelling, (cpath, vpath) in self.classes.items():
            if spelling == 'void':
                void_ptr = cpath, vpath

        for spelling, (cpath, vpath) in self.classes.items():
            # print spelling, cpath, vpath
            cklass = self.creator.getInterface(cpath)
            klass = self.creator.getClass(vpath)
            klass.addBase(cklass)

            if spelling == 'void':
                t = builtin_reference_plugin.builtin_class_wrapper[spelling]
                f = WrapVoidPtrDecl(
                    "wrap",
                    None,
                    bc.PointerType(bc.BuiltinType("void")),
                    [WrapVoidPtrArg(
                        "ptr",
                        bc.BuiltinType("void"),
                    )],
                    t,
                    isStatic=True)
                conv = self.creator.getFunctionConverter(f)
                klass.addFunction(conv)
            else:
                klass.setBaseClass(self.creator.getClass(void_ptr[1]))
                t = builtin_reference_plugin.builtin_class_wrapper[spelling]
                f = PointerAtDecl(
                    "at", None,
                    bc.LValueReferenceType(bc.BuiltinType(spelling)),
                    [bc.ParmVarDecl(
                        "index",
                        bc.BuiltinType("int"),
                    )], t)
                conv = self.creator.getFunctionConverter(f)
                klass.addFunction(conv)

                f = PointerCAtDecl(
                    "cAt",
                    None,
                    bc.LValueReferenceType(
                        bc.BuiltinType(spelling, isConstQualified=True)),
                    [bc.ParmVarDecl("index", bc.BuiltinType("int"))],
                    t,
                    isConstQualified=True)
                conv = self.creator.getFunctionConverter(f)
                cklass.addFunction(conv)
                klass.addFunction(conv)

                f = WrapArrayDecl(
                    "wrap",
                    None,
                    bc.PointerType(bc.BuiltinType(spelling)),
                    # f = WrapArrayDecl(t, bc.BuiltinType("void"),
                    [
                        WrapArrayArg(
                            "arg",
                            bc.PointerType(bc.BuiltinType(spelling)),
                        )
                    ],
                    t,
                    isStatic=True)
                conv = self.creator.getFunctionConverter(f)
                klass.addFunction(conv)
 def resolveClassPath(self, decl_or_type):
     if decl_or_type.pointeeType.isConstQualified:
         decl_or_type = bc.PointerType(
             bc.BuiltinType(decl_or_type.pointeeType.spelling))
     return self.resolveInterfacePath(decl_or_type)
 def __init__(self, creator, decl, func_conv):
     arg = bc.ParmVarDecl("_this",
                          bc.PointerType(bc.BuiltinType(decl.name)))
     super(InstanceArgConverter, self).__init__(creator, arg, func_conv)