From: W. Trevor King Date: Mon, 7 Mar 2011 14:43:51 +0000 (-0500) Subject: Consolidate Binding.CSource into Binding.CBinding. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f307668538cc7bdc8cbabf1adc6e8c503e6f3dff;p=cython.git Consolidate Binding.CSource into Binding.CBinding. --- diff --git a/Cython/Compiler/Binding.py b/Cython/Compiler/Binding.py index 0097c326..faa738e0 100644 --- a/Cython/Compiler/Binding.py +++ b/Cython/Compiler/Binding.py @@ -44,42 +44,32 @@ class _BindingAttributes(object): self.__dict__[key] = value -class CSource(_BindingAttributes): - """Configure the location of an object's C source. - - * source_name (string): Source symbol name (if the symbol is - external) - * source_namespace (string): C++ namespace (`None` for C objects, - set if the symbol is external) - * cdef_flag (boolean): Symbol (data) has a C definition. - * extern (boolean): Symbol is defined elsewhere (otherwise a local - defition is created). - """ - source_name = None - source_namespace = None - cdef_flag = 0 - extern = 0 - - class CBinding(_BindingAttributes): """Configure the presence and behaviour of an object's C bindings. * cname (string): Generated symbol name (or source name, is the symbol is external. - * cnamespace (string): C++ namespace (`None` for C objects) - * api (boolean): Add to generated header file - * visibility ('private'|'public'): + * namespace (string): C++ namespace of the source (`None` for C + objects, set if the symbol is external) + * cdef_flag (boolean): Symbol (data) has a C definition. + * extern (boolean): Symbol is defined elsewhere (otherwise a local + defition is created). + * visibility ('private'|'public'|'ignore'): * private: Symbol is not accessible to external C code * public: Symbol is accessible to external C code + * ignore: ? something about symbol re-definition? * const (boolean): Symbol data is readonly. + * api (boolean): Add to generated header file """ cname = None namespace = None - api = 0 + cdef_flag = 0 + extern = 0 c_visibility = 'private' const = 0 + api = 0 class PythonBinding(_BindingAttributes): @@ -98,11 +88,11 @@ class PythonBinding(_BindingAttributes): class methods. """ name = None - visibility = 'public' #private' + visibility = 'public' overridable = 0 -class Binding(CSource, CBinding, PythonBinding): +class Binding(CBinding, PythonBinding): "Combine all binding attributes in a single, flat namespace." def visibility_string(self): "Summarize binding visibility in a single string" diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 7f982a88..8c777900 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -2323,8 +2323,8 @@ def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag, error(s.position(), "Empty declarator") name = "" cname = None - if cname is None and ctx.source_namespace is not None and nonempty: - cname = ctx.source_namespace + "::" + name + if cname is None and ctx.namespace is not None and nonempty: + cname = ctx.namespace + "::" + name if name == 'operator' and ctx.extern and nonempty: op = s.sy if [1 for c in op if c in '+-*/<=>!%&|([^~,']: @@ -2492,14 +2492,14 @@ def p_cdef_extern_block(s, pos, ctx): ctx.extern = 1 if s.systring == "namespace": s.next() - ctx.source_namespace = p_string_literal(s, 'u')[2] + ctx.namespace = p_string_literal(s, 'u')[2] if p_nogil(s): ctx.nogil = 1 body = p_suite(s, ctx) return Nodes.CDefExternNode(pos, include_file = include_file, body = body, - namespace = ctx.source_namespace) + namespace = ctx.namespace) def p_c_enum_definition(s, pos, ctx): # s.sy == ident 'enum' @@ -2509,8 +2509,8 @@ def p_c_enum_definition(s, pos, ctx): name = s.systring s.next() cname = p_opt_cname(s) - if cname is None and ctx.source_namespace is not None: - cname = ctx.source_namespace + "::" + name + if cname is None and ctx.namespace is not None: + cname = ctx.namespace + "::" + name else: name = None cname = None @@ -2558,8 +2558,8 @@ def p_c_enum_item(s, ctx, items): ctx = p_binding(s, ctx) name = p_ident(s) cname = p_opt_cname(s) - if cname is None and ctx.source_namespace is not None: - cname = ctx.source_namespace + "::" + name + if cname is None and ctx.namespace is not None: + cname = ctx.namespace + "::" + name value = None if s.sy == '=': s.next() @@ -2584,8 +2584,8 @@ def p_c_struct_or_union_definition(s, pos, ctx): s.next() name = p_ident(s) cname = p_opt_cname(s) - if cname is None and ctx.source_namespace is not None: - cname = ctx.source_namespace + "::" + name + if cname is None and ctx.namespace is not None: + cname = ctx.namespace + "::" + name attributes = None if s.sy == ':': s.next() @@ -3019,8 +3019,8 @@ def p_cpp_class_definition(s, pos, ctx): module_path = [] class_name = p_ident(s) cname = p_opt_cname(s) - if cname is None and ctx.source_namespace is not None: - cname = ctx.source_namespace + "::" + class_name + if cname is None and ctx.namespace is not None: + cname = ctx.namespace + "::" + class_name if s.sy == '.': error(pos, "Qualified class name not allowed C++ class") if s.sy == '[':