[pygccxml-commit] SF.net SVN: pygccxml:[1833] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2010-04-03 09:59:47
|
Revision: 1833
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1833&view=rev
Author: roman_yakovenko
Date: 2010-04-03 09:59:41 +0000 (Sat, 03 Apr 2010)
Log Message:
-----------
rolling back protected variables changes
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/member_variable.py
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py
pyplusplus_dev/pyplusplus/messages/warnings_.py
pyplusplus_dev/unittests/test_all.py
Removed Paths:
-------------
pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp
pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp
pyplusplus_dev/unittests/member_variables_protected_tester.py
Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-03-25 21:12:47 UTC (rev 1832)
+++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-04-03 09:59:41 UTC (rev 1833)
@@ -437,39 +437,8 @@
def __init__(self, variable ):
code_creator.code_creator_t.__init__( self )
declaration_based.declaration_based_t.__init__( self, declaration=variable)
- self.__is_protected = bool( variable.access_type == declarations.ACCESS_TYPES.PROTECTED )
@property
- def public_accessor_name(self):
- return "pyplusplus_%s_accessor" % self.declaration.name
-
- def generate_public_accessor( self ):
- tmpl = os.linesep.join([
- "%(static)s%(const_item_type)s%(item_type)s* %(accessor_name)s()%(const_function)s{"
- , " return %(name)s;"
- , "}"
- ])
- constness = ''
- const_function = ''
- if declarations.is_const( self.declaration.type ):
- constness = 'const '
- const_function = ' const'
-
- static = ''
- if self.declaration.type_qualifiers.has_static:
- static = 'static '
- const_function = ''
-
- return tmpl % {
- 'static' : static
- , 'const_item_type' : constness
- , 'item_type' : declarations.array_item_type( self.declaration.type ).decl_string
- , 'accessor_name': self.public_accessor_name
- , 'name' : self.declaration.name
- , 'const_function' : const_function
- }
-
- @property
def wrapper_type( self ):
tmpl = "%(namespace)s::%(constness)sarray_1_t< %(item_type)s, %(array_size)d>"
@@ -486,10 +455,7 @@
@property
def wrapped_class_type( self ):
- if self.__is_protected:
- wrapped_cls_type = declarations.dummy_type_t( self.parent.full_name )
- else:
- wrapped_cls_type = declarations.declarated_t( self.declaration.parent )
+ wrapped_cls_type = declarations.declarated_t( self.declaration.parent )
if declarations.is_const( self.declaration.type ):
wrapped_cls_type = declarations.const_t( wrapped_cls_type )
return declarations.reference_t( wrapped_cls_type )
@@ -511,40 +477,26 @@
def wrapper_creator_full_name(self):
return '::'.join( [self.parent.full_name, self.wrapper_creator_name] )
- def _create_impl( self ):
- result = []
- if self.__is_protected:
- result.append( self.generate_public_accessor() )
- result.append( '' )
-
+ def _create_impl( self ):
tmpl = [ "static %(wrapper_type)s" ]
if self.declaration.type_qualifiers.has_static:
tmpl.append( "%(wrapper_creator_name)s(){" )
- if self.__is_protected:
- tmpl.append( self.indent( "return %(wrapper_type)s( %(wrapped_class_type_only)s::%(public_accessor_name)s() );" ) )
- else:
- tmpl.append( self.indent( "return %(wrapper_type)s( %(parent_class_type)s::%(mem_var_ref)s );" ) )
+ tmpl.append( self.indent( "return %(wrapper_type)s( %(parent_class_type)s::%(mem_var_ref)s );" ) )
else:
tmpl.append( "%(wrapper_creator_name)s( %(wrapped_class_type)s inst ){" )
- if self.__is_protected:
- tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(public_accessor_name)s() );" ) )
- else:
- tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) )
-
+ tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) )
tmpl.append( "}" )
-
+
tmpl = os.linesep.join( tmpl )
+
+ return tmpl % {
+ 'wrapper_type' : self.wrapper_type.decl_string
+ , 'parent_class_type' : self.parent.declaration.partial_decl_string
+ , 'wrapper_creator_name' : self.wrapper_creator_name
+ , 'wrapped_class_type' : self.wrapped_class_type.decl_string
+ , 'mem_var_ref' : self.declaration.name
+ }
- result.append( tmpl % { 'wrapper_type' : self.wrapper_type.decl_string
- , 'parent_class_type' : self.parent.declaration.partial_decl_string
- , 'wrapper_creator_name' : self.wrapper_creator_name
- , 'wrapped_class_type' : self.wrapped_class_type.decl_string
- , 'wrapped_class_type_only' : self.parent.full_name
- , 'mem_var_ref' : self.declaration.name
- , 'public_accessor_name' : self.public_accessor_name
- } )
- return os.linesep.join( result )
-
def _get_system_files_impl( self ):
return [code_repository.array_1.file_name]
@@ -627,17 +579,13 @@
def __init__(self, variable ):
code_creator.code_creator_t.__init__( self )
declaration_based.declaration_based_t.__init__( self, declaration=variable)
- self.__is_protected = bool( variable.access_type == declarations.ACCESS_TYPES.PROTECTED )
def _get_getter_full_name(self):
return self.parent.full_name + '::' + 'get_' + self.declaration.name
getter_full_name = property( _get_getter_full_name )
def _get_class_inst_type( self ):
- if self.__is_protected:
- return declarations.dummy_type_t( self.parent.full_name )
- else:
- return declarations.declarated_t( self.declaration.parent )
+ return declarations.declarated_t( self.declaration.parent )
def _get_exported_var_type( self ):
type_ = declarations.remove_reference( self.declaration.type )
@@ -689,7 +637,7 @@
def _create_impl(self):
answer = []
- cls_type = algorithm.create_identifier( self, self._get_class_inst_type().decl_string )
+ cls_type = algorithm.create_identifier( self, self.declaration.parent.decl_string )
substitutions = dict( type=self._get_exported_var_type().decl_string
, class_type=cls_type
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2010-03-25 21:12:47 UTC (rev 1832)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2010-04-03 09:59:41 UTC (rev 1833)
@@ -429,8 +429,6 @@
for member in self.protected_members:
if isinstance( member, declarations.calldef_t ):
members.append( member )
- elif isinstance( member, declarations.variable_t ) and variable_wrapper.variable_t.EXPOSE_PROTECTED_VARIABLES:
- members.append( member )
else:
pass
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2010-03-25 21:12:47 UTC (rev 1832)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2010-04-03 09:59:41 UTC (rev 1833)
@@ -15,8 +15,6 @@
class variable_t(decl_wrapper.decl_wrapper_t, declarations.variable_t):
"""defines a set of properties, that will instruct `Py++` how to expose the variable"""
- EXPOSE_PROTECTED_VARIABLES = False
-
def __init__(self, *arguments, **keywords):
declarations.variable_t.__init__(self, *arguments, **keywords )
decl_wrapper.decl_wrapper_t.__init__( self )
@@ -216,11 +214,7 @@
# return messages.W1061 % ( str( self ), str( cls ) )
if isinstance( self.parent, declarations.class_t ):
if self.access_type != declarations.ACCESS_TYPES.PUBLIC:
- if self.access_type == declarations.ACCESS_TYPES.PRIVATE:
- return messages.W1039
- else: #protected
- if not self.EXPOSE_PROTECTED_VARIABLES:
- return messages.W1039
+ return messages.W1039
if declarations.is_array( type_ ):
item_type = declarations.array_item_type( type_ )
if declarations.is_pointer( item_type ):
@@ -243,6 +237,4 @@
explanation.append( messages.W1026 % self.name )
if declarations.is_array( self.type ):
explanation.append( messages.W1027 % self.name)
- if self.access_type == declarations.ACCESS_TYPES.PROTECTED:
- explanation.append( messages.W1066 % self.name)
return explanation
Modified: pyplusplus_dev/pyplusplus/messages/warnings_.py
===================================================================
--- pyplusplus_dev/pyplusplus/messages/warnings_.py 2010-03-25 21:12:47 UTC (rev 1832)
+++ pyplusplus_dev/pyplusplus/messages/warnings_.py 2010-04-03 09:59:41 UTC (rev 1833)
@@ -257,9 +257,6 @@
'Use `wrapper_alias` property to change class wrapper alias value'
'Other classes : %s' )
-
-W1066 = warning( '`Py++` will generate class wrapper - class contains "%s" - protected member variable' )
-
warnings = globals()
all_warning_msgs = []
Deleted: pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp
===================================================================
--- pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp 2010-03-25 21:12:47 UTC (rev 1832)
+++ pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp 2010-04-03 09:59:41 UTC (rev 1833)
@@ -1,54 +0,0 @@
-// Copyright 2004-2008 Roman Yakovenko.
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#include "member_variables_protected_to_be_exported.hpp"
-
-namespace member_variables{
-
-const array_t::variable_t array_t::vars[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() };
-array_t::variable_t array_t::vars_nonconst[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() };
-/*
-int point::instance_count = 0;
-const point::color point::default_color = point::red;
-*/
-unsigned int get_a(const bit_fields_t& inst){
- return inst.a;
-}
-
-void set_a( bit_fields_t& inst, unsigned int new_value ){
- inst.a = new_value;
-}
-
-unsigned int get_b(const bit_fields_t& inst){
- return inst.b;
-}
-/*
-namespace pointers{
-
-std::auto_ptr<tree_node_t> create_tree(){
- std::auto_ptr<tree_node_t> root( new tree_node_t() );
- root->data = new data_t();
- root->data->value = 0;
-
- root->left = new tree_node_t( root.get() );
- root->left->data = new data_t();
- root->left->data->value = 1;
-
- return root;
-}
-
-}
-
-namespace statics{
- std::string mem_var_str_t::class_name( "mem_var_str_t" );
-}
-
-
-namespace ctypes{
- int xxx = 1997;
- int* image_t::none_image = &xxx;
-}
-*/
-}
Deleted: pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp 2010-03-25 21:12:47 UTC (rev 1832)
+++ pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp 2010-04-03 09:59:41 UTC (rev 1833)
@@ -1,199 +0,0 @@
-// Copyright 2004-2008 Roman Yakovenko.
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef __member_variables_protected_to_be_exported_hpp__
-#define __member_variables_protected_to_be_exported_hpp__
-#include <memory>
-#include <string>
-#include <iostream>
-
-namespace member_variables{
-/*
-struct point{
- enum color{ red, green, blue };
-
- point()
- : prefered_color( blue )
- , x( -1 )
- , y( 2 )
- {++instance_count;}
-
- point( const point& other )
- : prefered_color( other.prefered_color )
- , x( other.x )
- , y( other.y )
- {}
-
- ~point()
- { --instance_count; }
-protected:
- int x;
- int y;
- const color prefered_color;
- static int instance_count;
- static const color default_color;
-};
-*/
-struct bit_fields_t{
- friend unsigned int get_a(const bit_fields_t& inst);
- friend void set_a( bit_fields_t& inst, unsigned int new_value );
- friend unsigned int get_b(const bit_fields_t& inst);
-
- bit_fields_t()
- : b(28){}
-protected:
- unsigned int a : 1;
- unsigned int : 0;
- const unsigned int b : 11;
-};
-
-unsigned int get_a(const bit_fields_t& inst);
-void set_a( bit_fields_t& inst, unsigned int new_value );
-unsigned int get_b(const bit_fields_t& inst);
-
-struct array_t{
- array_t()
- {
- for( int i = 0; i < 10; ++i ){
- ivars[i] = -i;
- }
- }
-
- struct variable_t{
- variable_t() : value(-9){}
- int value;
- };
-
- int get_ivars_item( int index ){
- return ivars[index];
- }
-protected:
- static const variable_t vars[3];
- static variable_t vars_nonconst[3];
- int ivars[10];
- int ivars2[10];
-};
-/*
-namespace pointers{
-
-struct tree_node_t;
-
-struct data_t{
- friend struct tree_node_t;
- friend std::auto_ptr<tree_node_t> create_tree();
- data_t() : value( 201 ) {}
-protected:
- int value;
- static char* reserved;
-};
-
-struct tree_node_t{
-protected:
- data_t *data;
- tree_node_t *left;
- tree_node_t *right;
- const tree_node_t *parent;
-public:
- tree_node_t(const tree_node_t* parent=0)
- : data(0)
- , left( 0 )
- , right( 0 )
- , parent( parent )
- {}
-
- ~tree_node_t(){
- std::cout << "\n~tree_node_t";
- }
- friend std::auto_ptr<tree_node_t> create_tree();
-};
-
-std::auto_ptr<tree_node_t> create_tree();
-
-}
-*/
-namespace reference{
-
-enum EFruit{ apple, orange };
-
-struct fundamental_t{
- fundamental_t( EFruit& fruit, const int& i )
- : m_fruit( fruit ), m_i( i )
- {}
-protected:
- EFruit& m_fruit;
- const int& m_i;
-};
-
-struct A{};
-
-
-struct B {
- B( A& a_ ): a( a_ ){}
-protected:
- A& a;
-};
-
-struct C {
- C( A& a_ ): a( a_ ){}
-protected:
- const A& a;
-};
-
-}
-/*
-namespace statics{
-
-struct mem_var_str_t{
-protected:
- static std::string class_name;
-public:
- std::string identity(std::string x){ return x; }
-};
-
-}
-
-namespace bugs{
-struct allocator_ {
- void * (*alloc) (unsigned);
- void (*dispose) (void *p);
-};
-
-typedef struct allocator_ *allocator_t;
-
-struct faulty {
-protected:
- allocator_t allocator;
-};
-
-}
-
-
-namespace ctypes{
- struct image_t{
- image_t(){
- data = new int[5];
- for(int i=0; i<5; i++){
- data[i] = i;
- }
- }
- int* data;
-
- static int* none_image;
- };
-
- class Andy{
- protected:
- Andy() : userData(NULL) {}
-
- virtual ~Andy() {}
-
- public:
- void * userData;
- };
-
-}*/
-
-}
-#endif//__member_variables_protected_to_be_exported_hpp__
Deleted: pyplusplus_dev/unittests/member_variables_protected_tester.py
===================================================================
--- pyplusplus_dev/unittests/member_variables_protected_tester.py 2010-03-25 21:12:47 UTC (rev 1832)
+++ pyplusplus_dev/unittests/member_variables_protected_tester.py 2010-04-03 09:59:41 UTC (rev 1833)
@@ -1,131 +0,0 @@
-# Copyright 2004-2008 Roman Yakovenko.
-# Distributed under the Boost Software License, Version 1.0. (See
-# accompanying file LICENSE_1_0.txt or copy at
-# http://www.boost.org/LICENSE_1_0.txt)
-
-import os
-import sys
-import ctypes
-import unittest
-import fundamental_tester_base
-from pygccxml import declarations
-from pyplusplus import decl_wrappers
-
-decl_wrappers.variable_t.EXPOSE_PROTECTED_VARIABLES = True
-
-class tester_t(fundamental_tester_base.fundamental_tester_base_t):
- EXTENSION_NAME = 'member_variables_protected'
-
- def __init__( self, *args ):
- fundamental_tester_base.fundamental_tester_base_t.__init__(
- self
- , tester_t.EXTENSION_NAME
- , *args )
-
- def customize(self, mb ):
- #mb.variable( 'prefered_color' ).alias = 'PreferedColor'
- mb.classes().always_expose_using_scope = True
- #image = mb.class_( 'image_t' )
- #image.var( 'data' ).expose_address = True
- #image.var( 'none_image' ).expose_address = True
- #mb.class_( 'Andy' ).var('userData').expose_address = True
-
- def change_default_color( self, module ):
- module.point.default_color = module.point.color.blue
-
- def change_prefered_color( self, module ):
- xypoint = module.point()
- xypoint.PreferedColor = module.point.color.blue
-
- def set_b( self, bf, value ):
- bf.b = value
-
- def run_tests(self, module):
- #self.failIfRaisesAny( module.point )
- #xypoint = module.point()
- #self.failUnless( module.point.instance_count == 1)
- #self.failUnless( xypoint.instance_count == 1)
- #self.failUnless( module.point.default_color == module.point.color.red)
- #self.failUnless( xypoint.default_color == module.point.color.red)
- #self.failUnless( xypoint.x == -1)
- #self.failUnless( xypoint.y == 2 )
- #self.failUnless( xypoint.PreferedColor == xypoint.color.blue )
- #self.failUnlessRaises( Exception, self.change_default_color )
- #self.failUnlessRaises( Exception, self.change_prefered_color )
-
- bf = module.bit_fields_t()
- module.set_a( bf, 1 )
- self.failUnless( 1 == bf.a )
- self.failUnless( bf.b == module.get_b( bf ) )
- self.failIfNotRaisesAny( lambda: self.set_b( bf, 23 ) )
-
- #tree = module.create_tree()
- #self.failUnless( tree.parent is None )
- #self.failUnless( tree.data.value == 0 )
- #self.failUnless( tree.right is None )
- #self.failUnless( tree.left )
- #self.failUnless( tree.left.data.value == 1 )
-
- #tree.right = module.create_tree()
- #self.failUnless( tree.right.parent is None )
- #self.failUnless( tree.right.data.value == 0 )
- #self.failUnless( tree.right.right is None )
- #self.failUnless( tree.right.left )
- #self.failUnless( tree.right.left.data.value == 1 )
-
- #mem_var_str = module.mem_var_str_t()
- #mem_var_str.identity( module.mem_var_str_t.class_name )
-
- #image = module.image_t()
-
- #data_type = ctypes.POINTER( ctypes.c_int )
- #data = data_type.from_address( image.data )
- #for j in range(5):
- #self.failUnless( j == data[j] )
-
- #int_array = ctypes.c_int * 5
- #array = int_array()
- #for i in range( 5 ):
- #array[i] = 2*i
- #image.data = ctypes.addressof(array)
- #data = data_type.from_address( image.data )
- #for j in range(5):
- #self.failUnless( j*2 == data[j] )
-
- #data_type = ctypes.POINTER( ctypes.c_int )
- #data = data_type.from_address( module.image_t.none_image )
- #self.failUnless( 1997 == data.contents.value )
-
- array = module.array_t()
- self.failUnless( len( array.ivars ) == 10 )
-
- ivars = array.ivars
- del array #testing call policies
- for i in range(20):
- for index in range(10):
- self.failUnless( ivars[index] == -index )
-
- array = module.array_t()
- for index in range( len(array.ivars) ):
- array.ivars[index] = index * index
- self.failUnless( array.get_ivars_item( index ) == index * index )
-
-
- self.failUnless( len( module.array_t.vars ) == 3 )
- for i in range( len( module.array_t.vars ) ):
- self.failUnless( module.array_t.vars[i].value == -9 )
-
- self.failUnless( len( module.array_t.vars_nonconst ) == 3 )
- for i in range( len( module.array_t.vars_nonconst ) ):
- self.failUnless( module.array_t.vars_nonconst[i].value == -9 )
-
-def create_suite():
- suite = unittest.TestSuite()
- suite.addTest( unittest.makeSuite(tester_t))
- return suite
-
-def run_suite():
- unittest.TextTestRunner(verbosity=2).run( create_suite() )
-
-if __name__ == "__main__":
- run_suite()
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2010-03-25 21:12:47 UTC (rev 1832)
+++ pyplusplus_dev/unittests/test_all.py 2010-04-03 09:59:41 UTC (rev 1833)
@@ -126,7 +126,7 @@
import ft_output_static_matrix_tester
import ft_inout_static_matrix_tester
import ft_inout_static_array_tester
-import member_variables_protected_tester
+import inner_base_class_tester
testers = [
algorithms_tester
@@ -241,7 +241,7 @@
, ft_output_static_matrix_tester
, ft_inout_static_matrix_tester
, ft_inout_static_array_tester
- , member_variables_protected_tester
+ , inner_base_class_tester
# , ogre_generate_tester too much time
]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|