def maybe_create_dqti(self, type_mgr, cpp_type_expr): undq_cpp_type_expr, dq = cpp_type_expr.get_undq() if dq.is_pointer: spec = self.cpp_type_expr_to_spec.get(undq_cpp_type_expr) if spec: kl_type_name = spec.kl_type_name kl_type_name_for_derivatives = spec.kl_type_name_for_derivatives undq_cpp_type_expr = PointerTo(spec.cpp_type_expr) extends = spec.extends record = spec.record forbid_copy = spec.forbid_copy simplifier = spec.simplifier type_info_cache_key = kl_type_name + '_ptr' type_info = self.type_info_cache.get(type_info_cache_key) if not type_info: type_info = ManagedTypeInfo( self.jinjenv, kl_type_name, kl_type_name_for_derivatives, undq_cpp_type_expr, extends=extends, record=record, forbid_copy=forbid_copy, simplifier=simplifier, ) self.type_info_cache.setdefault(type_info_cache_key, type_info) self.ext.add_decl(ManagedBuiltinDecl(self.ext, type_info)) return DirQualTypeInfo(dir_qual.direct, type_info) if dq.is_reference: spec = self.cpp_type_expr_to_spec.get(undq_cpp_type_expr) if spec: kl_type_name = spec.kl_type_name kl_type_name_for_derivatives = spec.kl_type_name_for_derivatives undq_cpp_type_expr = ReferenceTo(spec.cpp_type_expr) extends = spec.extends record = spec.record forbid_copy = spec.forbid_copy simplifier = spec.simplifier type_info_cache_key = kl_type_name + '_ref' type_info = self.type_info_cache.get(type_info_cache_key) if not type_info: type_info = ManagedTypeInfo( self.jinjenv, kl_type_name, kl_type_name_for_derivatives, undq_cpp_type_expr, extends=extends, record=record, forbid_copy=forbid_copy, simplifier=simplifier, ) self.type_info_cache.setdefault(type_info_cache_key, type_info) return DirQualTypeInfo(dir_qual.direct, type_info)
def maybe_create_dqti(self, type_mgr, cpp_type_expr): if cpp_type_expr == const_cpp_type_expr: dqti = DirQualTypeInfo(dir_qual.direct, ConstVoidPtrTypeInfo(self.jinjenv)) if not self.have_decl: self.ext.add_decl(VoidPtrDecl(self.ext)) self.have_decl = True return dqti if cpp_type_expr == mutable_cpp_type_expr: dqti = DirQualTypeInfo(dir_qual.direct, MutableVoidPtrTypeInfo(self.jinjenv)) if not self.have_decl: self.ext.add_decl(VoidPtrDecl(self.ext)) self.have_decl = True return dqti
def maybe_create_dqti(self, type_mgr, cpp_type_expr): undq_cpp_type_expr, dq = cpp_type_expr.get_undq() if dq.is_direct: spec = self.cpp_type_expr_to_spec.get(undq_cpp_type_expr) if spec: kl_type_name = spec.kl_type_name kl_type_name_for_derivatives = spec.kl_type_name_for_derivatives undq_cpp_type_expr = spec.cpp_type_expr is_simple = spec.is_simple extends = spec.extends record = spec.record forbid_copy = spec.forbid_copy type_info_cache_key = kl_type_name type_info = self.type_info_cache.get(type_info_cache_key) if not type_info: type_info = InPlaceTypeInfo( self.jinjenv, kl_type_name, kl_type_name_for_derivatives, undq_cpp_type_expr, extends=extends, record=record, is_simple=is_simple, forbid_copy=forbid_copy, ) self.type_info_cache.setdefault(type_info_cache_key, type_info) self.ext.add_decl(InPlaceBuiltinDecl(self.ext, is_simple, type_info)) return DirQualTypeInfo(dq, type_info)
def maybe_create_dqti(self, type_mgr, cpp_type_expr): undq_cpp_type_expr, dq = cpp_type_expr.get_undq() if not dq.is_direct: undq_dqti = type_mgr.maybe_get_dqti(undq_cpp_type_expr) if undq_dqti: undq_type_info = undq_dqti.type_info kl_type_name = undq_type_info.kl.name.compound ti_set_cache_key = kl_type_name ti_set = self.ti_set_cache.get(ti_set_cache_key) if not ti_set: ti_set = PtrRefTypeInfoSet( self.jinjenv, undq_type_info, ) self.ti_set_cache.setdefault(ti_set_cache_key, ti_set) self.ext.add_decl( PtrRefBuiltinDecl( self.ext, ti_set, is_kludge_ext=self.is_kludge_ext_cpp_type_expr( cpp_type_expr), )) ti = getattr(ti_set, dq.get_desc()) return DirQualTypeInfo( DirQual(directions.Direct, qualifiers.Unqualified), ti)
def maybe_create_dqti(self, type_mgr, cpp_type_expr): undq_cpp_type_expr, dq = cpp_type_expr.get_undq() if dq.is_direct: spec = self.cpp_global_expr_to_spec.get(undq_cpp_type_expr) if spec: kl_global_name = spec.kl_global_name cpp_global_expr = spec.cpp_global_expr existing_kl_global_name = spec.existing_kl_global_name existing_kl_ext_name = spec.existing_kl_ext_name namespace = spec.namespace type_info_cache_key = kl_global_name type_info = self.type_info_cache.get(type_info_cache_key) if not type_info: type_info = MirrorTypeInfo( self.jinjenv, kl_global_name, cpp_global_expr, existing_kl_global_name, existing_kl_ext_name, Record( namespace, include_empty_ctor=False, include_copy_ctor=False, include_simple_ass_op=False, include_getters_setters=False, include_dtor=False, )) self.type_info_cache.setdefault(type_info_cache_key, type_info) self.ext.add_decl(MirrorBuiltinDecl(self.ext, type_info)) return DirQualTypeInfo(dq, type_info)
def maybe_create_dqti(self, type_mgr, cpp_type_expr): undq_cpp_type_expr, dq = cpp_type_expr.get_undq() if dq.is_pointer: spec = self.cpp_type_expr_to_spec.get(undq_cpp_type_expr) if spec: kl_type_name = spec.kl_type_name kl_type_name_for_derivatives = spec.kl_type_name_for_derivatives undq_cpp_type_expr = PointerTo(spec.cpp_type_expr) extends = spec.extends record = spec.record forbid_copy = spec.forbid_copy type_info_cache_key = kl_type_name type_info = self.type_info_cache.get(type_info_cache_key) if not type_info: type_info = OpaqueTypeInfo( self.jinjenv, kl_type_name, kl_type_name_for_derivatives, undq_cpp_type_expr, extends=extends, record=record, forbid_copy=forbid_copy, ) self.type_info_cache.setdefault(type_info_cache_key, type_info) self.ext.add_decl(OpaqueBuiltinDecl(self.ext, type_info)) return DirQualTypeInfo(dir_qual.direct, type_info)
def maybe_create_dqti(self, type_mgr, cpp_type_expr): undq_cpp_type_expr, dq = cpp_type_expr.get_undq() if dq.is_direct: spec = self.cpp_type_expr_to_spec.get(undq_cpp_type_expr) if spec: kl_type_name = spec.kl_type_name kl_type_name_for_derivatives = spec.kl_type_name_for_derivatives undq_cpp_type_expr = spec.cpp_type_expr extends = spec.extends record = spec.record forbid_copy = spec.forbid_copy dont_delete = spec.dont_delete type_info_cache_key = kl_type_name type_info = self.type_info_cache.get(type_info_cache_key) if not type_info: type_info = OwnedTypeInfo( self.jinjenv, kl_type_name, kl_type_name_for_derivatives, undq_cpp_type_expr, extends=extends, record=record, forbid_copy=forbid_copy, dont_delete=dont_delete, simplifier=spec.simplifier, ) self.type_info_cache.setdefault(type_info_cache_key, type_info) self.ext.add_decl(OwnedBuiltinDecl( self.ext, type_info, is_kludge_ext=spec.is_kludge_ext, )) return DirQualTypeInfo(dq, type_info)
def get_param(self, type_info): return ParamCodec( DirQualTypeInfo( DirQual(directions.Direct, qualifiers.Unqualified), type_info, ), "that" )
def maybe_create_dqti(self, type_mgr, cpp_type_expr): undq_cpp_type_expr, dq = cpp_type_expr.get_undq() if undq_cpp_type_expr == self.cpp_type_expr: return DirQualTypeInfo( dq, EnumTypeInfo( self.jinjenv, self.kl_type_name, undq_cpp_type_expr, ))
def maybe_create_dqti(self, type_mgr, cpp_type_expr): if isinstance(cpp_type_expr, FixedArrayOf): element_dqti = type_mgr.get_dqti(cpp_type_expr.element) return DirQualTypeInfo( dir_qual.direct, FixedArrayTypeInfo( self.jinjenv, cpp_type_expr.make_unqualified(), element_dqti, )) if isinstance(cpp_type_expr, ReferenceTo) \ and isinstance(cpp_type_expr.pointee, FixedArrayOf) \ and cpp_type_expr.pointee.is_const: element_dqti = type_mgr.get_dqti(cpp_type_expr.pointee.element) return DirQualTypeInfo( dir_qual.const_ref, FixedArrayTypeInfo( self.jinjenv, cpp_type_expr.pointee.make_unqualified(), element_dqti, ))
def maybe_create_dqti(self, type_mgr, cpp_type_expr): undq_cpp_type_expr, dq = cpp_type_expr.get_undq() if dq.is_direct: spec = self.cpp_type_expr_to_spec.get(undq_cpp_type_expr) if spec: kl_type_name = spec.kl_type_name kl_type_name_for_derivatives = spec.kl_type_name_for_derivatives undq_cpp_type_expr = spec.cpp_type_expr is_simple = spec.is_simple extends = spec.extends record = spec.record forbid_copy = spec.forbid_copy simplifier = spec.simplifier type_info_cache_key = str(undq_cpp_type_expr) type_info = self.type_info_cache.get(type_info_cache_key) if not type_info: if not self.instantiated_kl_types_names.get(kl_type_name): self.instantiated_kl_types_names.setdefault(kl_type_name, True) is_initial_kl_type_inst = True else: is_initial_kl_type_inst = False type_info = InPlaceTypeInfo( self.jinjenv, kl_type_name, kl_type_name_for_derivatives, undq_cpp_type_expr, extends=extends, record=record, is_simple=is_simple, forbid_copy=forbid_copy, simplifier=simplifier, ) self.type_info_cache.setdefault(type_info_cache_key, type_info) self.ext.add_decl( InPlaceBuiltinDecl( self.ext, is_simple=is_simple, is_initial_kl_type_inst=is_initial_kl_type_inst, type_info=type_info, ) ) return DirQualTypeInfo(dq, type_info)
def maybe_create_dqti(self, type_mgr, cpp_type_expr): undq_cpp_type_expr, dq = cpp_type_expr.get_undq() if dq.is_direct: spec = self.cpp_type_expr_to_spec.get(undq_cpp_type_expr) if spec: assert isinstance(undq_cpp_type_expr, Named) \ and len(undq_cpp_type_expr.components) == 1 \ and isinstance(undq_cpp_type_expr.components[0], Template) \ and len(undq_cpp_type_expr.components[0].params) == 1 \ and isinstance(undq_cpp_type_expr.components[0].params[0], Named) \ and len(undq_cpp_type_expr.components[0].params[0].components) >= 1 \ and isinstance(undq_cpp_type_expr.components[0].params[0].components[-1], Simple) kl_type_name = spec.kl_type_name kl_type_name_for_derivatives = spec.kl_type_name_for_derivatives undq_cpp_type_expr = spec.cpp_type_expr extends = spec.extends record = spec.record forbid_copy = spec.forbid_copy simplifier = spec.simplifier type_info_cache_key = kl_type_name type_info = self.type_info_cache.get(type_info_cache_key) if not type_info: type_info = WrappedTypeInfo( self.jinjenv, kl_type_name, kl_type_name_for_derivatives, undq_cpp_type_expr, extends=extends, record=record, forbid_copy=forbid_copy, simplifier=simplifier, ) self.type_info_cache.setdefault(type_info_cache_key, type_info) self.ext.add_decl(WrappedBuiltinDecl(self.ext, type_info)) return DirQualTypeInfo(dq, type_info)
def maybe_create_dqti(self, type_mgr, cpp_type_expr): if isinstance(cpp_type_expr, Void): return DirQualTypeInfo(dir_qual.direct, VoidTypeInfo(self.jinjenv))