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
def resolveInterfacePath(self, decl_or_type): if isinstance(decl_or_type, bc.BuiltinType): return BuiltinInterface, jpath.JPath(( "__builtins__", getJavaBuiltinType(self.target_info, decl_or_type), )) if (isinstance(decl_or_type, bc.LValueReferenceType) and isinstance(decl_or_type.pointeeType, bc.BuiltinType) and decl_or_type.pointeeType.isConstQualified): return BuiltinInterface, jpath.JPath(( "__builtins__", getJavaBuiltinType(self.target_info, decl_or_type.pointeeType), ))
def resolveClassPath(self, decl_or_type): if isinstance(decl_or_type, bc.ElaboratedType): decl_or_type = decl_or_type.namedType if isinstance(decl_or_type, bc.EnumType): decl_or_type = decl_or_type.decl n = decl_or_type.path.split('::') jpt = jpath.JPath(tuple(n)) self.classes[jpt] = decl_or_type return EnumClass, jpt
def resolveInterfacePath(self, decl_or_type): d = getDepth(decl_or_type) t, is_const = parseType(decl_or_type) klass, jp = self.creator.resolveInterfacePath(t) if not jp.path: return klass = jclass.Class njp = jpath.JPath(jp.path + ('Ptr%d' % d, )) self.classes[njp] = decl_or_type return klass, njp
def resolveInterfacePath(self, decl_or_type): t, is_const = parseType(decl_or_type) # print self.creator.resolveInterfacePath(t) # print "resolveInterface >>>>>", hash(t), t klass, jp = self.creator.resolveInterfacePath(t) # print "resolveInterface <<<<<", hash(t), t klass = jclass.Class njp = jpath.JPath(jp.path + ('Ref', )) self.classes[njp] = decl_or_type return klass, njp
def importsSys(self): jtype = builtin_plugin.getJavaBuiltinType(self.creator.target_info, self.arg.type.pointeeType) Jtype = jtype[0].upper() + jtype[1:] bb = jpath.JPath(( 'java', 'nio', '%sBuffer' % Jtype, ), True, ('java', 'nio'), ('%sBuffer' % Jtype, )) return [bb, jpath.ByteOrder]
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
def resolveInterfacePath(self, decl_or_type): decl, is_const = parseType(decl_or_type) c = '' if is_const: c = 'Const' n = decl.cname().split('::') n[-1] = n[-1].replace('<', '_lt_').replace('>', '_gt_') if n[-1] == 'Object': n[-1] = '_' + n[-1] + '_' # package = self.class_names[tuple(n)] # if package: # ns = package # n = n[len(package):] # else: # ns = () n[-1] = c + n[-1] self.__addClassDecl(decl) # return jclass.Interface, jpath.JPath(tuple(ns) + tuple(n)) return jclass.Interface, jpath.JPath(tuple(n))
def resolveClassPath(self, decl_or_type): decl, is_const = parseType(decl_or_type) f, jp = self.creator.resolveInterfacePath(decl) self.__addClassDecl(decl) return jclass.Class, jpath.JPath(jp.path + ('Impl', ))
def link(self, default_package): super(Class, self).link(default_package) jp = jpath.JPath(self.jpt.path, self.jpt.is_sys, self.jpt.package_path, self.jpt.class_path) for idx, i in enumerate(self.funcs): i.setPrivName(jp, 'f%d' % idx)
def resolveClassPath(self, decl_or_type): # return self.creator.resolveInterfacePath(decl_or_type) res = self.creator.resolveInterfacePath(decl_or_type) if res: return BuiltinClass, jpath.JPath(res[1].path + ('Impl', ))
def getBaseClassKey(self): return jpath.JPath(('BBObject', ))
def getBaseInterfaceKey(self): return jpath.JPath(('BBInterface', ))
def resolveFunctionClassPath(self, function_decl): l = function_decl.path.split('::')[:-1] return jclass.Class, jpath.JPath(tuple(l) + ('Global', ))
def resolveClassPath(self, decl_or_type): print decl_or_type, "resolveClassPath skipped..." return DummyClass, jpath.JPath((), ())
def getJClass(self): return jpath.JPath((self.prim, ))
def getJInterface(self): return jpath.JPath((self.prim, ))
# coding: utf-8 from blueboss import common as bc import plugin import string_plugin import jpath import jclass import builtin_reference_plugin STRING_REF_CLASS_PATH = jpath.JPath(("primitives", "StringRef")) STRING_TYPE = bc.TemplateSpecializationType() STRING_TYPE.sugar = bc.RecordType(bc.RecordDecl('std::basic_string')) STRING_TYPE.args = [ bc.TemplateArgument() ] STRING_TYPE.args[0].type = bc.BuiltinType("char") class StringRefGetDecl(bc.CXXMethodDecl): pass class StringRefSetDecl(bc.CXXMethodDecl): pass class InstanceArgConverter(builtin_reference_plugin.InstanceArgConverter): def getCTypeName(self): return "std::string"