You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(622) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(303) |
Feb
(64) |
Mar
(5) |
Apr
(63) |
May
(82) |
Jun
(53) |
Jul
(50) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: stephan b. <sg...@us...> - 2004-12-23 21:08:18
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6937 Added Files: SharedLib.ltdl.cpp Log Message: egg --- NEW FILE: SharedLib.ltdl.cpp --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/System/SharedLib.h" #include "pclasses/Phoenix.h" #include <ltdl.h> #include <errno.h> #ifndef PCLASSES_WITH_STL # error "This header requires PCLASSES_WITH_STL to be defined." #endif #include <string> #include <sstream> #include <map> #include <utility> // make_pair() namespace P { namespace System { typedef unsigned long handle_type; typedef std::map<handle_type,lt_dlhandle> lt_handle_map_t; struct ltdl_sharing_context {}; // marker class lt_handle_map_t & lt_handle_map() { typedef ::P::Phoenix< lt_handle_map_t, ltdl_sharing_context > PHX; return PHX::instance(); } int BindMode2Flags(SharedLib::BindMode mode) { // ltdl doesn't use dlopen() flags return 0; } SharedLib::SharedLib(const Unicode::String& name, BindMode mode) throw(SystemError) : _handle(0) { Unicode::String realName = name; realName.append(".so"); //@fixme _handle = (unsigned long)dlopen(realName.utf8(), BindMode2Flags(mode)); if(!_handle) throw SystemError(errno, lt_dlerror(), P_SOURCEINFO); } #ifdef PCLASSES_WITH_STL SharedLib::SharedLib(const std::string& name, BindMode mode) throw(SystemError) : _handle(0) { std::ostringstream realName; realName << name; realName << ".so"; lt_dlhandle h = lt_dlopen(realName.str().c_str() /** BindMode2Flags(mode) */ ); if( h ) { _handle = reinterpret_cast<handle_type>( static_cast<void *>( h ) ); lt_handle_map().insert( std::make_pair( _handle, h ) ); } if(!_handle) throw SystemError(errno, lt_dlerror(), P_SOURCEINFO); } #endif SharedLib::~SharedLib() throw() { lt_handle_map_t::iterator it = lt_handle_map().find( _handle ); if( lt_handle_map().end() != it ) { // nononono! // lt_dlclose((*it).second); lt_handle_map().erase( it ); } } void* SharedLib::operator[](const char* symbol) throw(RuntimeError) { lt_handle_map_t::iterator it = lt_handle_map().find( _handle ); if( lt_handle_map().end() == it ) { throw RuntimeError( "DLL handle is invalid.", P_SOURCEINFO ); } lt_dlhandle lth = (*it).second; void* addr = lt_dlsym( lth, symbol); if(!addr) { std::ostringstream os; os << "Symbol '"<<symbol<<"' not found in shared library."; throw RuntimeError(os.str().c_str(), P_SOURCEINFO); } return addr; } #ifdef PCLASSES_WITH_STL void* SharedLib::operator[](const std::string& symbol) throw(RuntimeError) { return operator[](symbol.c_str()); } #endif } // !namespace System } // !namespace P |
From: stephan b. <sg...@us...> - 2004-12-23 20:12:53
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26461 Modified Files: Makefile.toc Log Message: added FactoryTest Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/Makefile.toc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.toc 23 Dec 2004 00:18:57 -0000 1.1 +++ Makefile.toc 23 Dec 2004 20:12:41 -0000 1.2 @@ -1,32 +1,21 @@ -################################################### -# AUTO-GENERATED guess at a toc-aware Makefile, -# based off of the contents of directory: -# ./test -# Created by ./toc/bin/create_makefile_stubs.sh -# Wed Dec 22 23:10:45 CET 2004 -# It must be tweaked to suit your needs. -################################################### +#!/usr/bin/make -f include toc.make -############## FLEXES: -# WARNING: FLEXES stuff only works for C++-based flexers -FLEXES = -FLEXES_ARGS = -+ -p -OBJECTS += -include $(TOC_MAKESDIR)/flex.make -# Run target FLEXES to process these. -# REMINDER: add the generated C++ files to your SOURCES, if needed. -############## /FLEXES + HEADERS = Test.h + DIST_FILES += $(HEADERS) -INSTALL_PACKAGE_HEADERS += $(HEADERS) -SOURCES = IntTypeTest.cpp \ +SOURCES = \ + FactoryTest.cpp \ + IntTypeTest.cpp \ ListTest.cpp \ PtrTest.cpp \ QueueTest.cpp \ StackTest.cpp \ ThreadTest.cpp + DIST_FILES += $(SOURCES) + OBJECTS = IntTypeTest.o \ ListTest.o \ PtrTest.o \ @@ -36,27 +25,14 @@ CLEAN_FILES += $(OBJECTS) -build_libs = 0 -ifeq (1,$(build_libs)) - STATIC_LIBS = thislib - thislib_a_OBJECTS = $(OBJECTS) - thislib_so_OBJECTS = $(thislib_a_OBJECTS) - # thislib_so_VERSION = $(PACKAGE_VERSION) - include $(TOC_MAKESDIR)/SHARED_LIBS.make - include $(TOC_MAKESDIR)/STATIC_LIBS.make - # Run targets STATIC_LIBS and SHARED_LIBS build these. -endif - -build_bins = 0 +build_bins = 1 ifeq (1,$(build_bins)) - BIN_PROGRAMS = thisbin - thisbin_bin_OBJECTS = $(OBJECTS) + BIN_PROGRAMS = FactoryTest + FactoryTest_bin_OBJECTS = FactoryTest.o include $(TOC_MAKESDIR)/BIN_PROGRAMS.make - INSTALL_BINS += $(BIN_PROGRAMS) +# INSTALL_BINS += $(BIN_PROGRAMS) # Run target BIN_PROGRAMS to build these. endif -all: -################################################### -# end auto-generated rules -################################################### +all: BIN_PROGRAMS + |
From: stephan b. <sg...@us...> - 2004-12-23 20:12:28
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26362 Added Files: FactoryTest.cpp Log Message: egg --- NEW FILE: FactoryTest.cpp --- #ifdef NDEBUG # // force assert() to work... # undef NDEBUG #endif #include <string> #include <cassert> #include <pclasses/Factory.h> #ifndef CERR #define CERR std::cerr << __FILE__ << ":" << std::dec << __LINE__ << " : " #endif struct AType { AType() { CERR << "AType()\n"; } virtual ~AType() { CERR << "~AType()\n"; } virtual std::string classname() { return "AType"; } }; struct BType : public AType { BType() { CERR << "BType()\n"; } virtual ~BType() { CERR << "~BType()\n"; } virtual std::string classname() { return "BType"; } }; struct CType : public BType { CType() { CERR << "CType()\n"; } virtual ~CType() { CERR << "~CType()\n"; } virtual std::string classname() { return "CType"; } }; int main( int argc, char ** argv ) { CERR << "Factory tests...\n"; typedef P::Factory<AType> FT; P::CL::registerBase<AType>( "AType" ); P::CL::registerSubtype<AType,BType>( "BType" ); P::CL::registerSubtype<AType,CType>( "CType" ); AType * a = 0; #define LOAD(CN) a = P::CL::classload<AType>( CN ); \ CERR << CN << " loaded? == " << a << "\n"; \ if( a ) CERR << "classname="<<a->classname()<<"\n"; \ delete( a ); a = 0; LOAD("AType"); LOAD("BType"); LOAD("CType"); LOAD("NoType"); return 0; } |
From: stephan b. <sg...@us...> - 2004-12-23 20:12:06
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26210 Modified Files: Factory.h Phoenix.h Log Message: converted spaces to tabs Index: Factory.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Factory.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Factory.h 23 Dec 2004 14:13:35 -0000 1.3 +++ Factory.h 23 Dec 2004 20:11:49 -0000 1.4 @@ -1,5 +1,5 @@ -#ifndef p_BASICFACTORY_H_INCLUDED -#define p_BASICFACTORY_H_INCLUDED 1 +#ifndef p_FACTORY_H_INCLUDED +#define p_FACTORY_H_INCLUDED 1 // Author: stephan beal <st...@s1...> // License: Public Domain @@ -9,242 +9,250 @@ #include <functional> #include <pclasses/Phoenix.h> // i don't like this dep, but i also don't like - // what happens in some cases when i don't use - // phoenix. :/ +// what happens in some cases when i don't use +// phoenix. :/ namespace P { + + /** + Namespace Sharing holds internal "sharing context" marker + classes. + */ + namespace Sharing + { + /** Internal marker class. */ + struct FactoryContext {}; + } + /** + The Hook namespace holds classes intended to be used to + allow client-side code to hook in to the framework's + behaviour, replacing certain parts of the core with their + own. + */ + namespace Hook + { + /** + FactoryCreateHook is a helper object factory for the P::Factory + API. - /** - Namespace Sharing holds internal "sharing context" marker - classes. - */ - namespace Sharing - { - /** Internal marker class. */ - struct FactoryContext {}; - } + General conventions: - /** - The Hook namespace holds classes intended to be used to - allow client-side code to hook in to the framework's - behaviour, replacing certain parts of the core with their - own. - */ - namespace Hook - { - /** - FactoryCreateHook is a helper object factory for the P::Factory - API. + SubT must derive from (or be) T and must be Default + Constructuable on the heap. In short, the following must be + able to succeed: + + <pre> + T * foo = new SubT; + </pre> - General conventions: + Clients may freely specialize this type to hook their + factories in to P, and the above requirement may not be + imposed by client-side specializations. + */ - SubT must derive from (or be) T and must be Default - Constructuable on the heap. In short, the following must be - able to succeed: - - <pre> - T * foo = new SubT; - </pre> + template < class T, class SubT > + struct FactoryCreateHook + { + /** + The type returned by create() and + operator(). + */ + typedef T * result_type; - Clients may freely specialize this type to hook their - factories in to P, and the above requirement may not be - imposed by client-side specializations. - */ + /** + A typedef for the second template parameter for this + type. + */ + typedef SubT actual_type; + + /** + This creates a new SubT, which is assumed to be a + subclass of T. It can be used as a factory for + Factory & class_loader. + + If T or SubT are abstract types, you must + specialize this type such that create() returns 0 + for those. That is, we "simulate" creation of + abstract types by returning 0. - template < class T, class SubT > - struct FactoryCreateHook - { - /** - The type returned by create() and - operator(). - */ - typedef T * result_type; + The caller owns the returned pointer, which + may be 0. + */ + static result_type create() + { + return new actual_type; + } - /** - A typedef for the second template parameter for this - type. - */ - typedef SubT actual_type; - - /** - This creates a new SubT, which is assumed to be a - subclass of T. It can be used as a factory for - Factory & class_loader. - - If T or SubT are abstract types, you must - specialize this type such that create() returns 0 - for those. That is, we "simulate" creation of - abstract types by returning 0. + /** + A factory which always returns 0. This can + be used as a factory when, e.g., T is + abstract. + */ + static result_type no_create() + { + return 0; + } + + /** + Same as create(). + */ + result_type operator()() const + { + return create(); + } + }; - The caller owns the returned pointer, which - may be 0. - */ - static result_type create() - { - return new actual_type; - } - - /** - Same as create(). - */ - result_type operator()() const - { - return create(); - } - }; + /** + FactoryInstanceHook provides a way for non-core + code to manipulate or swap out the object returned + by Factory::instance(). - /** - FactoryInstanceHook provides a way for non-core - code to manipulate or swap out the object returned - by Factory::instance(). + Client code may want to specialize this to, e.g., plug in a + DLL-aware object lookups, auto-loading of plugins, etc. - Client code may want to specialize this to, e.g., plug in a - DLL-aware object lookups, auto-loading of plugins, etc. + Specializing this type on a specific T will cause: - Specializing this type on a specific T will cause: + MyFacT & fac = MyFacT::instance(); - MyFacT & fac = MyFacT::instance(); + to trigger a call to operator()( fac ) the first + time fac is initialized AND on any re-initializations + (which may get called post-main()). - to trigger a call to operator()( fac ) the first - time fac is initialized AND on any re-initializations - (which may get called post-main()). - */ - template <typename FactoryT> - struct FactoryInstanceHook - { - typedef FactoryInstanceHook<FactoryT> ThisType; - - /** - Specializations of this type may initialize - instance() here. It will be called whenever Phoenix - initializes the object. See Phoenix for details. + FactoryT is expected to be of type ::P::Factory<>, + but there is nothing in the implementation which is actually + specific to that type. + */ + template <typename FactoryT> + struct FactoryInstanceHook + { + typedef FactoryInstanceHook<FactoryT> ThisType; + + /** + Specializations of this type may initialize + instance() here. It will be called whenever Phoenix + initializes the object. See Phoenix for details. - The default implementation does nothing. - */ - void operator()( FactoryT & ) throw() - { - } - - /** - The default implementation returns a shared Factory object. - THIS type's operator() will be called on the factory immediately - after creating the factory. - */ - static FactoryT & instance() - { - typedef ::P::Phoenix<FactoryT, ::P::Sharing::FactoryContext, ThisType > PHX; - return PHX::instance(); - } - }; - } // namespace Hook + The default implementation does nothing. + */ + void operator()( FactoryT & ) throw() + { + } + + /** + The default implementation returns a shared Factory object. + THIS type's operator() will be called on the factory immediately + after creating the factory. + */ + static FactoryT & instance() + { + typedef ::P::Phoenix<FactoryT, ::P::Sharing::FactoryContext, ThisType > PHX; + return PHX::instance(); + } + }; + } // namespace Hook - /** - Factory is essentially a static classloader, capable of - loading classes by using registered factories for a given - set of keys (e.g., class names). + /** + Factory is essentially a static classloader, capable of + loading classes by using registered factories for a given + set of keys (e.g., class names). - Classloaders, at least in my experience, need to be able to - load all classes which derive from some given type. Without - a common base class, one can't safely attempt to cast from - an arbitrary pointer to the type we want to load. That's - where the InterfaceT parameter comes in. All objects - instantiated via this loader must inherit from InterfaceT. + Classloaders, at least in my experience, need to be able to + load all classes which derive from some given type. Without + a common base class, one can't safely attempt to cast from + an arbitrary pointer to the type we want to load. That's + where the InterfaceT parameter comes in. All objects + instantiated via this loader must inherit from InterfaceT. - KeyType is a type which specifies the type of key used to - look up classes, defaulting to std::string. + KeyType is a type which specifies the type of key used to + look up classes, defaulting to std::string. - Both InterfaceT and KeyType must be Default Constructable, - and InterfaceT must be constructable on the heap - (e.g., via new InterfaceT()). + Both InterfaceT and KeyType must be Default Constructable, + and InterfaceT must be constructable on the heap + (e.g., via new InterfaceT()). - The default ipmlementation holds no per-instance state, - thus it can be copied quickly. + The default ipmlementation holds no per-instance state, + thus it can be copied quickly. - Sample usage: -<pre> + Sample usage: + + <pre> Factory<MyClass> & fac = Factory<MyClass>::instance(); -fac.registerFactory( "my_key", MyClass::new_instance ); +fac.registerFactory( "my_key", P::Hook::FactoryCreateHook>MyClass<::create ); MyClass *foo = fac.instantiate( "some_key" ); // == NULL foo = fac.instantiate( "my_key" ); // == a new MyClass object -</pre> + </pre> - Note that all instantiators of the same type use the same - object factories. The ContextType template parameter can be - used to limit the scope of the object factory registrations - to a specific context: instantiators with different Contexts - use different maps. ContextType is only used as a type, and - is never instantiated by this class. - */ + Note that all instantiators of the same type use the same + object factories. The ContextType template parameter can be + used to limit the scope of the object factory registrations + to a specific context: Factories with different Contexts + use different maps. ContextType is only used as a marker type, + and is never instantiated by this class. + */ template < class InterfaceT, - class KeyType = std::string, - class ContextType = Sharing::FactoryContext - > - class Factory + class KeyType = std::string, + class ContextType = Sharing::FactoryContext + > + class Factory { - public: + public: - /** - A typedef for the InterfaceT used by this class. - */ + /** + A typedef for the InterfaceT used by this class. + */ typedef InterfaceT value_type; + /** + Same as (InterfaceT *), for conformance with the + Adaptable Unary Functor model. + */ + typedef InterfaceT * result_type; - /** - A typedef for the KeyType used by this class. - */ - typedef KeyType key_type; - - /** Same as ContextType */ - typedef ContextType context_type; - /** - Same as KeyType, for conformance with the the - Adaptable Unary Functor model. - */ - typedef KeyType key_type; + /** + A typedef for the KeyType used by this class. + */ + typedef KeyType key_type; - /** - Same as (InterfaceT *), for conformance with the - Adaptable Unary Functor model. - */ - typedef InterfaceT * result_type; + /** Same as ContextType */ + typedef ContextType context_type; - /** - Convenience typedef. - */ + /** + Convenience typedef. + */ typedef Factory< InterfaceT, KeyType, ContextType > ThisType; - Factory() {} + Factory() {} - virtual ~Factory() {} + virtual ~Factory() {} - /** - The type of factories used by this class: a - function taking void and returning (value_type - *). See factoryMap(). + /** + The type of factories used by this class: a + function taking void and returning (value_type + *). See factoryMap(). - todo: implement proper functor support. - */ - typedef result_type ( *factory_type ) (); + todo: implement proper functor support. + */ + typedef result_type ( *factory_type ) (); - /** - Internal container type used for mapping keys to - factories. - */ + /** + Internal container type used for mapping keys to + factories. + */ typedef std::map < key_type, factory_type > FactoryMap; - /** - Tries to instantiate an instance of value_type - using the given key. Returns NULL if no class could - be loaded for the given key. + /** + Tries to instantiate an instance of value_type + using the given key. Returns NULL if no object + could be loaded for the given key. - Subtypes are free to implement, e.g., DLL lookups. - */ + Subtypes are free to implement, e.g., DLL lookups. + */ virtual result_type instantiate( const key_type & key ) { typename FactoryMap::const_iterator it = factoryMap().find( key ); @@ -256,143 +264,143 @@ } - /** - Returns this->internalInstantiate(key). - */ - result_type operator()( const key_type & key ) - { - return this->internal( key ); - } + /** + Returns this->instantiate(key). + */ + result_type operator()( const key_type & key ) + { + return this->internal( key ); + } /** - Registers a factory using the given key. If fp is - NULL then a default factory is used. Note that fp - may not return a type other than - ThisType::value_type *, but the actual object it - creates may be a polymorphic subclass of - value_type. See the FactoryCreateHook class for a - factory which does this subtype-to-base conversion. - */ + Registers a factory using the given key. If fp is + NULL then a default factory is used. Note that fp + may not return a type other than + ThisType::value_type *, but the actual object it + creates may be a polymorphic subclass of + value_type. See the FactoryCreateHook class for a + factory which does this subtype-to-base conversion. + */ void registerFactory( const key_type & key, factory_type fp ) { - factoryMap().insert( FactoryMap::value_type( key, fp ) ); - } + factoryMap().insert( FactoryMap::value_type( key, fp ) ); + } - /** - Returns the internal key-to-factory map. It is safe - for clients to modify this except in multi-threaded - environments, and then all guarantees go out the - window. That said, it should never be necessary for - clients to use this. + /** + Returns the internal key-to-factory map. It is safe + for clients to modify this except in multi-threaded + environments, and then all guarantees go out the + window. That said, it should never be necessary for + clients to use this. - It is safe to call this post-main(), but such calls - may return an empty map! - */ + It is safe to call this post-main(), but such calls + may return an empty map! + */ static FactoryMap & factoryMap() { return Phoenix<FactoryMap,ThisType>::instance(); } - /** - Returns true if the given key is registered. This is sometimes useful - for checking whether a factory needs to be re-registered, which - is sometimes necessary post-main(), when the internal map gets hosed - before clients are done using it. - */ - bool isRegistered( const key_type & key ) const - { - return factoryMap().end() != factoryMap().find( key ); - } + /** + Returns true if the given key is registered. This is sometimes useful + for checking whether a factory needs to be re-registered, which + is sometimes necessary post-main(), when the internal map gets hosed + before clients are done using it. + */ + bool isRegistered( const key_type & key ) const + { + return factoryMap().end() != factoryMap().find( key ); + } - /** - Returns a shared reference to a Factory. - - Client code may plug in a new default instance() by - specializing Hook::FactoryInstanceHook< FactoryT >. See - that type for details. - */ - static Factory & instance() - { - return Hook::FactoryInstanceHook<ThisType>::instance(); - } + /** + Returns a shared reference to a Factory. + + Client code may plug in a new default instance() by + specializing Hook::FactoryInstanceHook< FactoryT >. See + that type for details. + */ + static Factory & instance() + { + return Hook::FactoryInstanceHook<ThisType>::instance(); + } - + }; // class Factory - /** - NamedTypeFactory works for string-keyed types. It is - expected that this will be the most-used factory - implementation, as non-string-keyed factories are rare in - practice (but sometimes very useful). - */ - template <typename InterfaceT> - struct NamedTypeFactory : public Factory< InterfaceT, std::string, Sharing::FactoryContext > - { - virtual ~NamedTypeFactory(){} - }; + /** + NamedTypeFactory works for string-keyed types. It is + expected that this will be the most-used factory + implementation, as non-string-keyed factories are rare in + practice (but sometimes very useful). + */ + template <typename InterfaceT> + struct NamedTypeFactory : public Factory< InterfaceT, std::string, Sharing::FactoryContext > + { + virtual ~NamedTypeFactory(){} + }; - /** - The CL namespace encapsulates P's classloader-related API. + /** + The CL namespace encapsulates P's classloader-related API. - All of the functions in this API use the obbject - NamedTypeFactory<InterfaceT>::instance() for - factory-related operations. Thus, using the various Hook - classes you can force these functions to use your factory. + All of the functions in this API use the obbject + NamedTypeFactory<InterfaceT>::instance() for + factory-related operations. Thus, using the various Hook + classes you can force these functions to use your factory. - i don't like this namespace. Maybe move these functions - into Factory itself??? They're simply proxying that type, - after all. + i don't like this namespace. Maybe move these functions + into Factory itself??? They're simply proxying that type, + after all. - */ - namespace CL { - - using namespace ::P; - using namespace ::P::Sharing; + */ + namespace CL { + + using namespace ::P; + using namespace ::P::Sharing; - /** - Registers classname with InterfaceT. If factory_function is 0 - then ::P::Hook::FactoryCreateHook<InterfaceT,InterfaceT>::create is - used. If InterfaceT is abstract then you must specialize - ::P::Hook::FactoryCreateHook<InterfaceT,InterfaceT>, as documented - in FactoryCreateHook::create(). - */ - template <typename InterfaceT> - void registerBase( const std::string & classname, InterfaceT *(*factory_function)() = 0 ) - { - NamedTypeFactory<InterfaceT>::instance().registerFactory( classname, - ( 0 != factory_function ) - ? factory_function - : ::P::Hook::FactoryCreateHook<InterfaceT,InterfaceT>::create - ); - } - /** - Registers a factory creating ImplT objects with the - InterfaceT classloader. If factory_function is 0 then - ::P::Hook::FactoryCreateHook<InterfaceT,ImplT>::create is - used. - */ - template <typename InterfaceT, typename ImplT> - void registerSubtype( const std::string & classname, InterfaceT *(*factory_function)() = 0 ) - { - NamedTypeFactory<InterfaceT>::instance().registerFactory( classname, - ( 0 != factory_function ) - ? factory_function - : ::P::Hook::FactoryCreateHook<InterfaceT,ImplT>::create - ); - } - - /** - Returns the same as NamedTypeFactory<InterfaceT>::instance().instantiate( classname ). - */ - template <typename InterfaceT> - InterfaceT * classload( const std::string & classname ) - { - return NamedTypeFactory<InterfaceT>::instance().instantiate( classname ); - } - } // namespace CL + /** + Registers classname with InterfaceT. If factory_function is 0 + then ::P::Hook::FactoryCreateHook<InterfaceT,InterfaceT>::create is + used. If InterfaceT is abstract then you must specialize + ::P::Hook::FactoryCreateHook<InterfaceT,InterfaceT>, as documented + in FactoryCreateHook::create(). + */ + template <typename InterfaceT> + void registerBase( const std::string & classname, InterfaceT *(*factory_function)() = 0 ) + { + NamedTypeFactory<InterfaceT>::instance().registerFactory( classname, + ( 0 != factory_function ) + ? factory_function + : ::P::Hook::FactoryCreateHook<InterfaceT,InterfaceT>::create + ); + } + /** + Registers a factory creating ImplT objects with the + InterfaceT classloader. If factory_function is 0 then + ::P::Hook::FactoryCreateHook<InterfaceT,ImplT>::create is + used. + */ + template <typename InterfaceT, typename ImplT> + void registerSubtype( const std::string & classname, InterfaceT *(*factory_function)() = 0 ) + { + NamedTypeFactory<InterfaceT>::instance().registerFactory( classname, + ( 0 != factory_function ) + ? factory_function + : ::P::Hook::FactoryCreateHook<InterfaceT,ImplT>::create + ); + } + + /** + Returns the same as NamedTypeFactory<InterfaceT>::instance().instantiate( classname ). + */ + template <typename InterfaceT> + InterfaceT * classload( const std::string & classname ) + { + return NamedTypeFactory<InterfaceT>::instance().instantiate( classname ); + } + } // namespace CL } // namespace P -#endif // p_BASICFACTORY_H_INCLUDED +#endif // p_FACTORY_H_INCLUDED Index: Phoenix.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Phoenix.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Phoenix.h 23 Dec 2004 04:45:52 -0000 1.1 +++ Phoenix.h 23 Dec 2004 20:11:49 -0000 1.2 @@ -10,7 +10,7 @@ //////////////////////////////////////////////////////////////////////////////// #include <stdlib.h> // atexit() -#include <iostream> // cout/cerr +#include <iostream> // cout/cerr, only for debuggering #ifndef phoenix_DEBUG @@ -21,8 +21,8 @@ #if phoenix_DEBUG # include <typeinfo> # define phoenix_CERR std::cerr << __FILE__ << ":" << std::dec << __LINE__ << " : " \ - << "Phoenix<"<<typeid((base_type *)NULL).name()<<" , " \ - << typeid((context_type *)NULL).name()<<"> " + << "Phoenix<"<<typeid((base_type *)NULL).name()<<" , " \ + << typeid((context_type *)NULL).name()<<"> " #else # define phoenix_CERR if(0) std::cerr #endif // phoenix_DEBUG @@ -34,179 +34,179 @@ */ namespace P { - - /** - Internal helper class to provide a default no-op - initializer for phoenixed objects. + + /** + Internal helper class to provide a default no-op + initializer for phoenixed objects. - See the Phoenix<> class. - */ - struct no_op_phoenix_initializer - { - /** Does nothing: This class is called no_op for a reason ;) */ - template <typename T> - void operator()( T & ) throw() { return; } - }; + See the Phoenix<> class. + */ + struct no_op_phoenix_initializer + { + /** Does nothing: This class is called no_op for a reason ;) */ + template <typename T> + void operator()( T & ) throw() { return; } + }; - /** - Phoenix is class for holding singleton-style instances of - BaseType objects. Rather than requiring that BaseType be a - Singleton type, Phoenix subclasses BaseType to add the - Phoenix-like capabilities. Phoenixing makes the shared - object post-main() safe, in terms of object destruction - order. + /** + Phoenix is class for holding singleton-style instances of + BaseType objects. Rather than requiring that BaseType be a + Singleton type, Phoenix subclasses BaseType to add the + Phoenix-like capabilities. Phoenixing makes the shared + object post-main() safe, in terms of object destruction + order. - Parameterized on: + Parameterized on: - - BaseType: must be struct or class type and must be - default-constructable. i have no clue what is supposed to - happen if BaseType's dtor is not virtual. That said, - Phoenix has been successfully demonstrated with a BaseType - of std::map, which has no virtual dtor. + - BaseType: must be struct or class type and must be + default-constructable. i have no clue what is supposed to + happen if BaseType's dtor is not virtual. That said, + Phoenix has been successfully demonstrated with a BaseType + of std::map, which has no virtual dtor. - - ContextType: These objects are only singletons within the - given ContextType. That is, Phoenix<T,X>::instance() - will return a different object than Phoenix<T,Y> - will. + - ContextType: These objects are only singletons within the + given ContextType. That is, Phoenix<T,X>::instance() + will return a different object than Phoenix<T,Y> + will. - - InitializerType: must be a unary functor accepting a - BaseType &. It's return value is ignored. The default - functor does nothing. The InitializerType is called when a - to-be-phoenixed object is initially created and whenever it - is phoenixed. This is intended to be used, e.g., for - re-populating a phoenixed shared object. - TODO: investigate the implications of a predicate - initializer, which would return false if the object could - not be initialized. InitializerType::operator() must - not throw. + - InitializerType: must be a unary functor accepting a + BaseType &. It's return value is ignored. The default + functor does nothing. The InitializerType is called when a + to-be-phoenixed object is initially created and whenever it + is phoenixed. This is intended to be used, e.g., for + re-populating a phoenixed shared object. + TODO: investigate the implications of a predicate + initializer, which would return false if the object could + not be initialized. InitializerType::operator() must + not throw. - Whether or not BaseType is technically a singleton depends - on entirely BaseType itself. This class is more often used - to provide easy access to context-dependent shared objects, - rather than pure singletons. The Phoenix class itself is a - true Singleton, but each combination of template arguments - provides a different Singleton *type*, so the end effect is - "context singletons." + Whether or not BaseType is technically a singleton depends + on entirely BaseType itself. This class is more often used + to provide easy access to context-dependent shared objects, + rather than pure singletons. The Phoenix class itself is a + true Singleton, but each combination of template arguments + provides a different Singleton *type*, so the end effect is + "context singletons." - This is another attempt to solve the classic - Keyboard-Console-Log problem, as discussed at length in - <i>Modern C++ Design</i>. It relies on sane behaviour in - the C library's atexit() function, which, as is shown in - MC++D, is not the case on all systems. That said, the - Phoenix-specific behaviours are undefined on those systems, - which is only to say that it might not be post-main() safe. + This is another attempt to solve the classic + Keyboard-Console-Log problem, as discussed at length in + <i>Modern C++ Design</i>. It relies on sane behaviour in + the C library's atexit() function, which, as is shown in + MC++D, is not the case on all systems. That said, the + Phoenix-specific behaviours are undefined on those systems, + which is only to say that it might not be post-main() safe. - Caveats: + Caveats: - i am not 100% clear on all of the implications of this - implementation's approach... my gut tells me i'm missing - some significant bits. i mean, it <i>can't</i> have been - this straightforward to solve ;). The very nature of the - Phoenix Singleton problem makes it difficult to reliably - test in real-world applications. That said, i have seen a - objects be successfully phoenixed and atexit()ed, so it is - known to at least "basically" work. + i am not 100% clear on all of the implications of this + implementation's approach... my gut tells me i'm missing + some significant bits. i mean, it <i>can't</i> have been + this straightforward to solve ;). The very nature of the + Phoenix Singleton problem makes it difficult to reliably + test in real-world applications. That said, i have seen a + objects be successfully phoenixed and atexit()ed, so it is + known to at least "basically" work. - There's a paper about "context singletons", this class, - and some of it's implications, at: + There's a paper about "context singletons", this class, + and some of it's implications, at: - http://s11n.net/misccode/context_singletons.html + http://s11n.net/misccode/context_singletons.html - [Much later: i've gotten more re-use out of this class than - probably any other single class i've ever written.] - */ - template < - typename BaseType, - typename ContextType = BaseType, - typename InitializerType = no_op_phoenix_initializer - > - struct Phoenix : public BaseType - { - /** - context_type is unused by this class, but might be useful - for type identification at some point. - */ - typedef ContextType context_type; - /** - The BaseType parameterized type. - */ - typedef BaseType base_type; + [Much later: i've gotten more re-use out of this class than + probably any other single class i've ever written.] + */ + template < + typename BaseType, + typename ContextType = BaseType, + typename InitializerType = no_op_phoenix_initializer + > + struct Phoenix : public BaseType + { + /** + context_type is unused by this class, but might be useful + for type identification at some point. + */ + typedef ContextType context_type; + /** + The BaseType parameterized type. + */ + typedef BaseType base_type; - /** - The functor type used to initialize this phoenixed object. - */ - typedef InitializerType initializer_type; + /** + The functor type used to initialize this phoenixed object. + */ + typedef InitializerType initializer_type; - /** - Returns a shared instance of this object. + /** + Returns a shared instance of this object. - The instance() method will always return the same - address, though it is potentially possible - (post-main()) that the actual object living at that - address is different from previous calls. + The instance() method will always return the same + address, though it is potentially possible + (post-main()) that the actual object living at that + address is different from previous calls. - It is never a good idea to hold on to the returned - reference for the life of an object, as that bypasses - the phoenixing capabilities. + It is never a good idea to hold on to the returned + reference for the life of an object, as that bypasses + the phoenixing capabilities. - If you ever delete it you're on you're own. That's - a Bad Idea. - */ - static base_type & instance() - { - static this_type meyers; - static bool donethat = false; - if( this_type::m_destroyed ) - { - phoenix_CERR << "Phoenixing!" << std::endl; - donethat = false; - new( &meyers ) this_type; - atexit( this_type::do_atexit ); - } - if( !donethat ) - { - phoenix_CERR << "initializing instance" << std::endl; - donethat = true; - initializer_type()( meyers ); - } - phoenix_CERR << "instance() == " <<std::hex<<&meyers<<std::endl; - return meyers; - } + If you ever delete it you're on you're own. That's + a Bad Idea. + */ + static base_type & instance() + { + static this_type meyers; + static bool donethat = false; + if( this_type::m_destroyed ) + { + phoenix_CERR << "Phoenixing!" << std::endl; + donethat = false; + new( &meyers ) this_type; + atexit( this_type::do_atexit ); + } + if( !donethat ) + { + phoenix_CERR << "initializing instance" << std::endl; + donethat = true; + initializer_type()( meyers ); + } + phoenix_CERR << "instance() == " <<std::hex<<&meyers<<std::endl; + return meyers; + } - private: + private: - /** A convenience typedef. */ - typedef Phoenix<base_type,context_type,initializer_type> this_type; + /** A convenience typedef. */ + typedef Phoenix<base_type,context_type,initializer_type> this_type; - static bool m_destroyed; + static bool m_destroyed; - Phoenix() - { - phoenix_CERR << "Phoenix() @" << std::hex<< this << std::endl; - m_destroyed = false; - } + Phoenix() + { + phoenix_CERR << "Phoenix() @" << std::hex<< this << std::endl; + m_destroyed = false; + } - virtual ~Phoenix() - { - phoenix_CERR << "~Phoenix() @" << std::hex<< this << std::endl; - m_destroyed = true; - } - /** - Destroys the shared object via a manual call to it's dtor. - */ - static void do_atexit() - { - if( m_destroyed ) return; - phoenix_CERR << "::do_atexit() @ " << std::hex << &instance() << std::endl; - static_cast<this_type &>(instance()).~Phoenix(); // will eventually trigger the BaseType dtor - } - - }; - template <typename T, typename C, typename I> bool Phoenix<T,C,I>::m_destroyed = false; + virtual ~Phoenix() + { + phoenix_CERR << "~Phoenix() @" << std::hex<< this << std::endl; + m_destroyed = true; + } + /** + Destroys the shared object via a manual call to it's dtor. + */ + static void do_atexit() + { + if( m_destroyed ) return; + phoenix_CERR << "::do_atexit() @ " << std::hex << &instance() << std::endl; + static_cast<this_type &>(instance()).~Phoenix(); // will eventually trigger the BaseType dtor + } + + }; + template <typename T, typename C, typename I> bool Phoenix<T,C,I>::m_destroyed = false; } // namespace |
From: stephan b. <sg...@us...> - 2004-12-23 14:13:58
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16132 Modified Files: Factory.h Log Message: removed the internalInstantiate() altogether - the extra indirection brought nothing Index: Factory.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Factory.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Factory.h 23 Dec 2004 13:49:54 -0000 1.2 +++ Factory.h 23 Dec 2004 14:13:35 -0000 1.3 @@ -238,16 +238,22 @@ typedef std::map < key_type, factory_type > FactoryMap; - /** - returns instance().internalInstantiate( key ). + /** + Tries to instantiate an instance of value_type + using the given key. Returns NULL if no class could + be loaded for the given key. - The caller takes responsibility for the returned pointer. + Subtypes are free to implement, e.g., DLL lookups. */ - static result_type instantiate( const key_type & key ) + virtual result_type instantiate( const key_type & key ) { - - return instance().internalInstantiate( key ); - } + typename FactoryMap::const_iterator it = factoryMap().find( key ); + if ( it != factoryMap().end() ) // found a factory? + { + return ( it->second ) (); // run our factory. + } + return 0; + } /** @@ -255,7 +261,7 @@ */ result_type operator()( const key_type & key ) { - return this->internalInstantiate( key ); + return this->internal( key ); } @@ -311,26 +317,6 @@ return Hook::FactoryInstanceHook<ThisType>::instance(); } - - protected: - /** - Tries to instantiate an instance of value_type - using the given key. Returns NULL if no class could - be loaded for the given key. - - This is the virtual equivalent to the static instantiate(). - - Subtypes are free to implement, e.g., DLL lookups. - */ - virtual result_type internalInstantiate( const key_type & key ) - { - typename FactoryMap::const_iterator it = factoryMap().find( key ); - if ( it != factoryMap().end() ) // found a factory? - { - return ( it->second ) (); // run our factory. - } - return 0; - } }; // class Factory @@ -341,7 +327,7 @@ implementation, as non-string-keyed factories are rare in practice (but sometimes very useful). */ -template <typename InterfaceT> + template <typename InterfaceT> struct NamedTypeFactory : public Factory< InterfaceT, std::string, Sharing::FactoryContext > { virtual ~NamedTypeFactory(){} @@ -350,9 +336,15 @@ /** The CL namespace encapsulates P's classloader-related API. - All of the functions in this API use the obbject NamedTypeFactory<InterfaceT>::instance() - for factory-related operations. Thus, using the various Hook classes you can force these - functions to use your factory. + All of the functions in this API use the obbject + NamedTypeFactory<InterfaceT>::instance() for + factory-related operations. Thus, using the various Hook + classes you can force these functions to use your factory. + + i don't like this namespace. Maybe move these functions + into Factory itself??? They're simply proxying that type, + after all. + */ namespace CL { |
From: stephan b. <sg...@us...> - 2004-12-23 13:50:03
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11870 Modified Files: Factory.h Log Message: renamed internal_instantiate() to internalInstantiate(), for consistency. still do not like the name at all! Index: Factory.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Factory.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Factory.h 23 Dec 2004 04:45:52 -0000 1.1 +++ Factory.h 23 Dec 2004 13:49:54 -0000 1.2 @@ -167,10 +167,10 @@ Sample usage: <pre> -typedef Factory<MyClass> CL; -CL::register_factory( "my_key" ); -MyClass *foo = CL::load( "some_key" ); // == NULL -foo = CL::instantiate( "my_key" ); // == a new object +Factory<MyClass> & fac = Factory<MyClass>::instance(); +fac.registerFactory( "my_key", MyClass::new_instance ); +MyClass *foo = fac.instantiate( "some_key" ); // == NULL +foo = fac.instantiate( "my_key" ); // == a new MyClass object </pre> Note that all instantiators of the same type use the same @@ -239,23 +239,23 @@ /** - returns instance().internal_instantiate( key ). + returns instance().internalInstantiate( key ). The caller takes responsibility for the returned pointer. */ static result_type instantiate( const key_type & key ) { - return instance().internal_instantiate( key ); + return instance().internalInstantiate( key ); } /** - Returns this->internal_instantiate(key). + Returns this->internalInstantiate(key). */ result_type operator()( const key_type & key ) { - return this->internal_instantiate( key ); + return this->internalInstantiate( key ); } @@ -322,7 +322,7 @@ Subtypes are free to implement, e.g., DLL lookups. */ - virtual result_type internal_instantiate( const key_type & key ) + virtual result_type internalInstantiate( const key_type & key ) { typename FactoryMap::const_iterator it = factoryMap().find( key ); if ( it != factoryMap().end() ) // found a factory? |
From: stephan b. <sg...@us...> - 2004-12-23 06:28:12
|
Update of /cvsroot/pclasses/pclasses2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4188 Modified Files: configure.pclasses2 Log Message: removed libltdl test, as P does not yet support it (TODO). Added some more module-specific defines. Index: configure.pclasses2 =================================================================== RCS file: /cvsroot/pclasses/pclasses2/configure.pclasses2,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- configure.pclasses2 23 Dec 2004 02:28:13 -0000 1.3 +++ configure.pclasses2 23 Dec 2004 06:28:03 -0000 1.4 @@ -23,7 +23,9 @@ ############################################################ -toc_test libltdl || toc_test_require libdl # prefer ltdl, else allow dl. +# reminder: need to add SharedLib.ltdl.cpp +# toc_test libltdl || toc_test_require libdl # prefer ltdl, else allow dl. +toc_test_require libdl ############################################################ @@ -131,9 +133,12 @@ toc_export LIBPCORE_LDADD="$(${removeDupes} ${ldadd})" toc_export LIBPCORE_INCLUDES="$(${removeDupes} ${inc})" -toc_export LIBPSYSTEM_LDADD="$(${removeDupes} ${THREADS_LDADD})" +toc_export LIBPSYSTEM_LDADD="$(${removeDupes} ${THREADS_INCLUDES})" toc_export LIBPSYSTEM_INCLUDES="$(${removeDupes} ${THREADS_INCLUDES})" +toc_export LIBPUTIL_LDADD="$(${removeDupes} ${THREADS_LDADD})" +toc_export LIBPUTIL_INCLUDES="$(${removeDupes} ${THREADS_INCLUDES})" + toc_export LIBPSQL_MYSQL_LDADD="$(${removeDupes} ${ldadd} ${MYSQL_LDADD})" toc_export LIBPSQL_MYSQL_INCLUDES="$(${removeDupes} ${inc} ${MYSQL_INCLUDES})" toc_export LIBPSQL_POSTSQL_LDADD="$(${removeDupes} ${ldadd} ${POSTGRES_LDADD})" |
From: stephan b. <sg...@us...> - 2004-12-23 06:27:33
|
Update of /cvsroot/pclasses/pclasses2/toc/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4075 Modified Files: create_makefile_stubs.sh Log Message: tweaks Index: create_makefile_stubs.sh =================================================================== RCS file: /cvsroot/pclasses/pclasses2/toc/bin/create_makefile_stubs.sh,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- create_makefile_stubs.sh 23 Dec 2004 05:03:11 -0000 1.3 +++ create_makefile_stubs.sh 23 Dec 2004 06:27:24 -0000 1.4 @@ -120,20 +120,26 @@ cat <<EOF build_libs = 0 +LIBNAME = libfoo ifeq (1,\$(build_libs)) - STATIC_LIBS = thislib - thislib_a_OBJECTS = \$(OBJECTS) - thislib_so_OBJECTS = \$(thislib_a_OBJECTS) - # thislib_so_VERSION = \$(PACKAGE_VERSION) + STATIC_LIBS = \$(LIBNAME) + SHARED_LIBS = \$(LIBNAME) + \$(LIBNAME)_a_OBJECTS = \$(OBJECTS) + \$(LIBNAME)_so_OBJECTS = \$(\$(LIBNAME)_a_OBJECTS) + # \$(LIBNAME)_so_VERSION = \$(PACKAGE_VERSION) + # \$(LIBNAME)_so_LDADD = include \$(TOC_MAKESDIR)/SHARED_LIBS.make include \$(TOC_MAKESDIR)/STATIC_LIBS.make # Run targets STATIC_LIBS and SHARED_LIBS build these. +SHARED_LIBS: STATIC_LIBS endif build_bins = 0 +BINNAME = mybin ifeq (1,\$(build_bins)) - BIN_PROGRAMS = thisbin - thisbin_bin_OBJECTS = \$(OBJECTS) + BIN_PROGRAMS = \$(BINNAME) + \$(BINNAME)_bin_OBJECTS = \$(OBJECTS) +# \$(BINNAME)_bin_LDADD = include \$(TOC_MAKESDIR)/BIN_PROGRAMS.make INSTALL_BINS += \$(BIN_PROGRAMS) # Run target BIN_PROGRAMS to build these. |
From: stephan b. <sg...@us...> - 2004-12-23 06:25:42
|
Update of /cvsroot/pclasses/pclasses2/src/Net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3822 Modified Files: Makefile.toc Log Message: it builds :) Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Net/Makefile.toc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.toc 23 Dec 2004 06:09:32 -0000 1.2 +++ Makefile.toc 23 Dec 2004 06:25:34 -0000 1.3 @@ -1,14 +1,7 @@ #!/usr/bin/make -f -################################################### -# AUTO-GENERATED guess at a toc-aware Makefile, -# based off of the contents of directory: -# ./src/Net -# Created by ./toc/bin/create_makefile_stubs.sh -# Thu Dec 23 01:31:56 CET 2004 -# It must be tweaked to suit your needs. -################################################### + include toc.make -############## FLEXES: + HEADERS = SocketOption.h DIST_FILES += $(HEADERS) INSTALL_PACKAGE_HEADERS += $(HEADERS) @@ -17,7 +10,9 @@ InetSocket.cpp \ NetworkAddress.cpp \ Socket.cpp + DIST_FILES += $(SOURCES) + OBJECTS = InetAddress.o \ InetSocket.o \ NetworkAddress.o \ @@ -25,27 +20,23 @@ CLEAN_FILES += $(OBJECTS) -build_libs = 0 +build_libs = 1 +LIBNAME = libpnet ifeq (1,$(build_libs)) - STATIC_LIBS = thislib - thislib_a_OBJECTS = $(OBJECTS) - thislib_so_OBJECTS = $(thislib_a_OBJECTS) - # thislib_so_VERSION = $(PACKAGE_VERSION) + STATIC_LIBS = $(LIBNAME) + SHARED_LIBS = $(LIBNAME) + $(LIBNAME)_a_OBJECTS = $(OBJECTS) + $(LIBNAME)_so_OBJECTS = $($(LIBNAME)_a_OBJECTS) + $(LIBNAME)_so_VERSION = $(PACKAGE_VERSION) + # $(LIBNAME)_so_LDADD = include $(TOC_MAKESDIR)/SHARED_LIBS.make include $(TOC_MAKESDIR)/STATIC_LIBS.make - # Run targets STATIC_LIBS and SHARED_LIBS build these. +SHARED_LIBS: STATIC_LIBS endif -build_bins = 0 -ifeq (1,$(build_bins)) - BIN_PROGRAMS = thisbin - thisbin_bin_OBJECTS = $(OBJECTS) - include $(TOC_MAKESDIR)/BIN_PROGRAMS.make - INSTALL_BINS += $(BIN_PROGRAMS) - # Run target BIN_PROGRAMS to build these. -endif -all: +all: SHARED_LIBS + ################################################### # end auto-generated rules ################################################### |
From: stephan b. <sg...@us...> - 2004-12-23 06:25:04
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3738 Modified Files: Makefile.toc Log Message: added Net subdir Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Makefile.toc,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile.toc 23 Dec 2004 06:20:06 -0000 1.4 +++ Makefile.toc 23 Dec 2004 06:24:54 -0000 1.5 @@ -2,8 +2,7 @@ include toc.make -SUBDIRS = Unicode System IO Util -# Net +SUBDIRS = Unicode System IO Util Net SOURCES = Alloc.cpp \ AtomicInt.gcc-x86.cpp \ |
From: stephan b. <sg...@us...> - 2004-12-23 06:23:55
|
Update of /cvsroot/pclasses/pclasses2/src/Net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3588 Modified Files: Socket.cpp Log Message: added a missing return. removed a bogus "static" declartor on allocSocketAddress() Index: Socket.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Net/Socket.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Socket.cpp 23 Dec 2004 04:32:18 -0000 1.2 +++ Socket.cpp 23 Dec 2004 06:23:46 -0000 1.3 @@ -115,9 +115,10 @@ default: throw; } + return socketAddress; } -static sockaddr* allocSocketAddress(int domain, size_t& addrLen) +sockaddr* allocSocketAddress(int domain, size_t& addrLen) { sockaddr* socketAddress = 0; switch(domain) |
From: stephan b. <sg...@us...> - 2004-12-23 06:23:17
|
Update of /cvsroot/pclasses/pclasses2/src/Net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3548 Modified Files: InetAddress.cpp Log Message: added a missing return. Index: InetAddress.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Net/InetAddress.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- InetAddress.cpp 23 Dec 2004 04:32:18 -0000 1.2 +++ InetAddress.cpp 23 Dec 2004 06:23:09 -0000 1.3 @@ -64,6 +64,8 @@ Unicode::String InetAddress::str() const { //@todo InetAddress::str() + return Unicode::String(); + // ^^^^ added by stephan to avoid an implicit return warning. } InetAddress* InetAddress::clone() const |
From: stephan b. <sg...@us...> - 2004-12-23 06:20:18
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3128 Modified Files: Makefile.toc Log Message: added Util subdir Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Makefile.toc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.toc 23 Dec 2004 06:09:32 -0000 1.3 +++ Makefile.toc 23 Dec 2004 06:20:06 -0000 1.4 @@ -2,8 +2,8 @@ include toc.make -SUBDIRS = Unicode System IO -# Net Util +SUBDIRS = Unicode System IO Util +# Net SOURCES = Alloc.cpp \ AtomicInt.gcc-x86.cpp \ |
From: stephan b. <sg...@us...> - 2004-12-23 06:19:04
|
Update of /cvsroot/pclasses/pclasses2/src/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2916 Modified Files: Makefile.toc Log Message: it builds :) Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Util/Makefile.toc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.toc 23 Dec 2004 06:09:33 -0000 1.2 +++ Makefile.toc 23 Dec 2004 06:18:56 -0000 1.3 @@ -12,34 +12,31 @@ SOURCES = ManagedThread.cpp \ ThreadPool.cpp \ WorkQueue.cpp + DIST_FILES += $(SOURCES) + OBJECTS = ManagedThread.o \ ThreadPool.o \ WorkQueue.o CLEAN_FILES += $(OBJECTS) -build_libs = 0 +INCLUDES += $(LIBPUTIL_INCLUDES) +build_libs = 1 +LIBNAME = libputil ifeq (1,$(build_libs)) - STATIC_LIBS = thislib - thislib_a_OBJECTS = $(OBJECTS) - thislib_so_OBJECTS = $(thislib_a_OBJECTS) - # thislib_so_VERSION = $(PACKAGE_VERSION) + STATIC_LIBS = $(LIBNAME) + SHARED_LIBS = $(STATIC_LIBS) + $(LIBNAME)_a_OBJECTS = $(OBJECTS) + $(LIBNAME)_so_OBJECTS = $($(LIBNAME)_a_OBJECTS) + $(LIBNAME)_so_VERSION = $(PACKAGE_VERSION) include $(TOC_MAKESDIR)/SHARED_LIBS.make include $(TOC_MAKESDIR)/STATIC_LIBS.make # Run targets STATIC_LIBS and SHARED_LIBS build these. +SHARED_LIBS: STATIC_LIBS endif -build_bins = 0 -ifeq (1,$(build_bins)) - BIN_PROGRAMS = thisbin - thisbin_bin_OBJECTS = $(OBJECTS) - include $(TOC_MAKESDIR)/BIN_PROGRAMS.make - INSTALL_BINS += $(BIN_PROGRAMS) - # Run target BIN_PROGRAMS to build these. -endif - -all: +all: SHARED_LIBS ################################################### # end auto-generated rules ################################################### |
From: stephan b. <sg...@us...> - 2004-12-23 06:10:13
|
Update of /cvsroot/pclasses/pclasses2/src/Net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1508/Net Modified Files: Makefile.toc Log Message: mass commit: most of the build works. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Net/Makefile.toc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.toc 23 Dec 2004 00:18:53 -0000 1.1 +++ Makefile.toc 23 Dec 2004 06:09:32 -0000 1.2 @@ -1,21 +1,14 @@ +#!/usr/bin/make -f ################################################### # AUTO-GENERATED guess at a toc-aware Makefile, # based off of the contents of directory: # ./src/Net # Created by ./toc/bin/create_makefile_stubs.sh -# Wed Dec 22 23:10:45 CET 2004 +# Thu Dec 23 01:31:56 CET 2004 # It must be tweaked to suit your needs. ################################################### include toc.make ############## FLEXES: -# WARNING: FLEXES stuff only works for C++-based flexers -FLEXES = -FLEXES_ARGS = -+ -p -OBJECTS += -include $(TOC_MAKESDIR)/flex.make -# Run target FLEXES to process these. -# REMINDER: add the generated C++ files to your SOURCES, if needed. -############## /FLEXES HEADERS = SocketOption.h DIST_FILES += $(HEADERS) INSTALL_PACKAGE_HEADERS += $(HEADERS) |
From: stephan b. <sg...@us...> - 2004-12-23 06:10:12
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1508 Modified Files: Alloc.cpp Makefile.toc Log Message: mass commit: most of the build works. Index: Alloc.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Alloc.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Alloc.cpp 23 Dec 2004 02:31:07 -0000 1.2 +++ Alloc.cpp 23 Dec 2004 06:09:32 -0000 1.3 @@ -22,6 +22,8 @@ #include <stdlib.h> #include <new> +// #include "pclasses/Factory.h" + namespace P { OutOfMemory::OutOfMemory(const SourceInfo& si) throw() Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Makefile.toc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.toc 23 Dec 2004 02:27:52 -0000 1.2 +++ Makefile.toc 23 Dec 2004 06:09:32 -0000 1.3 @@ -2,7 +2,8 @@ include toc.make -# SUBDIRS = Net System Unicode Util +SUBDIRS = Unicode System IO +# Net Util SOURCES = Alloc.cpp \ AtomicInt.gcc-x86.cpp \ @@ -31,7 +32,8 @@ # Run targets STATIC_LIBS and SHARED_LIBS build these. endif -all: STATIC_LIBS SHARED_LIBS +all: STATIC_LIBS SHARED_LIBS subdirs + ################################################### # end auto-generated rules ################################################### |
From: stephan b. <sg...@us...> - 2004-12-23 06:10:12
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1508/System Modified Files: Makefile.toc Log Message: mass commit: most of the build works. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Makefile.toc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.toc 23 Dec 2004 00:18:53 -0000 1.1 +++ Makefile.toc 23 Dec 2004 06:09:32 -0000 1.2 @@ -1,98 +1,83 @@ -################################################### -# AUTO-GENERATED guess at a toc-aware Makefile, -# based off of the contents of directory: -# ./src/System -# Created by ./toc/bin/create_makefile_stubs.sh -# Wed Dec 22 23:10:45 CET 2004 -# It must be tweaked to suit your needs. -################################################### +#!/usr/bin/make -f + include toc.make -############## FLEXES: -# WARNING: FLEXES stuff only works for C++-based flexers -FLEXES = -FLEXES_ARGS = -+ -p -OBJECTS += -include $(TOC_MAKESDIR)/flex.make -# Run target FLEXES to process these. -# REMINDER: add the generated C++ files to your SOURCES, if needed. -############## /FLEXES + HEADERS = timeout.h + DIST_FILES += $(HEADERS) + INSTALL_PACKAGE_HEADERS += $(HEADERS) -SOURCES = Condition.posix.cpp \ - Condition.solaris.cpp \ - Condition.win32.cpp \ + + +SOURCES_COMMON = \ CriticalSection.cpp \ CriticalSection.generic.cpp \ - CriticalSection.win32.cpp \ - File.posix.cpp \ Mutex.cpp \ + SharedLib.dl.cpp \ + SystemError.cpp \ + timeout.cpp + +SOURCES_WTF = \ + SharedLib.shl.cpp + +SOURCES_MACH = \ + SharedLib.dyld.cpp + +SOURCES_SYSV = \ + SharedMemory.sysv.cpp \ + Semaphore.sysv.cpp + +SOURCES_SOLARIS = \ + Condition.solaris.cpp \ + Mutex.solaris.cpp + +SOURCES_POSIX = Condition.posix.cpp \ + File.posix.cpp \ Mutex.posix.cpp \ - Mutex.solaris.cpp \ - Mutex.win32.cpp \ Pipe.posix.cpp \ - Semaphore.posix.cpp \ - Semaphore.sysv.cpp \ - Semaphore.win32.cpp \ - SharedLib.dl.cpp \ - SharedLib.dyld.cpp \ - SharedLib.shl.cpp \ - SharedLib.win32.cpp \ SharedMemory.posix.cpp \ - SharedMemory.sysv.cpp \ - SystemError.cpp \ Thread.posix.cpp \ - timeout.cpp -DIST_FILES += $(SOURCES) -OBJECTS = Condition.posix.o \ - Condition.solaris.o \ - Condition.win32.o \ - CriticalSection.o \ - CriticalSection.generic.o \ - CriticalSection.win32.o \ - File.posix.o \ - Mutex.o \ - Mutex.posix.o \ - Mutex.solaris.o \ - Mutex.win32.o \ - Pipe.posix.o \ - Semaphore.posix.o \ - Semaphore.sysv.o \ - Semaphore.win32.o \ - SharedLib.dl.o \ - SharedLib.dyld.o \ - SharedLib.shl.o \ - SharedLib.win32.o \ - SharedMemory.posix.o \ - SharedMemory.sysv.o \ - SystemError.o \ - Thread.posix.o \ - timeout.o + +SOURCES_WIN32 = Condition.win32.cpp \ + CriticalSection.win32.cpp \ + Mutex.win32.cpp \ + Semaphore.posix.cpp \ + Semaphore.win32.cpp \ + SharedLib.win32.cpp + + +############################################## +# TODO: use the config-mandated BUILD_SOURCES! +BUILD_SOURCES = $(SOURCES_COMMON) +BUILD_SOURCES += $(SOURCES_POSIX) +############################################## + +DIST_FILES += $(wildcard *.cpp *.h) + +OBJECTS = \ + $(patsubst %.cpp,%.o,$(BUILD_SOURCES)) CLEAN_FILES += $(OBJECTS) -build_libs = 0 +INCLUDES += $(LIBPSYSTEM_INCLUDES) +LDADD += $(LIBPSYSTEM_LDADD) + +LIBNAME = libpsystem +build_libs = 1 ifeq (1,$(build_libs)) - STATIC_LIBS = thislib - thislib_a_OBJECTS = $(OBJECTS) - thislib_so_OBJECTS = $(thislib_a_OBJECTS) - # thislib_so_VERSION = $(PACKAGE_VERSION) + STATIC_LIBS = $(LIBNAME) + SHARED_LIBS = $(STATIC_LIBS) + $(LIBNAME)_a_OBJECTS = $(OBJECTS) + $(LIBNAME)_so_OBJECTS = $($(LIBNAME)_a_OBJECTS) + $(LIBNAME)_so_VERSION = $(PACKAGE_VERSION) + # $(LIBNAME)_so_LDADD = $(LIBPSYSTEM_LDADD) include $(TOC_MAKESDIR)/SHARED_LIBS.make include $(TOC_MAKESDIR)/STATIC_LIBS.make # Run targets STATIC_LIBS and SHARED_LIBS build these. endif -build_bins = 0 -ifeq (1,$(build_bins)) - BIN_PROGRAMS = thisbin - thisbin_bin_OBJECTS = $(OBJECTS) - include $(TOC_MAKESDIR)/BIN_PROGRAMS.make - INSTALL_BINS += $(BIN_PROGRAMS) - # Run target BIN_PROGRAMS to build these. -endif - -all: +all: STATIC_LIBS SHARED_LIBS ################################################### # end auto-generated rules ################################################### |
From: stephan b. <sg...@us...> - 2004-12-23 06:09:56
|
Update of /cvsroot/pclasses/pclasses2/src/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1508/Util Modified Files: Makefile.toc Log Message: mass commit: most of the build works. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Util/Makefile.toc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.toc 23 Dec 2004 00:18:53 -0000 1.1 +++ Makefile.toc 23 Dec 2004 06:09:33 -0000 1.2 @@ -1,21 +1,14 @@ +#!/usr/bin/make -f ################################################### # AUTO-GENERATED guess at a toc-aware Makefile, # based off of the contents of directory: # ./src/Util # Created by ./toc/bin/create_makefile_stubs.sh -# Wed Dec 22 23:10:45 CET 2004 +# Thu Dec 23 01:31:56 CET 2004 # It must be tweaked to suit your needs. ################################################### include toc.make ############## FLEXES: -# WARNING: FLEXES stuff only works for C++-based flexers -FLEXES = -FLEXES_ARGS = -+ -p -OBJECTS += -include $(TOC_MAKESDIR)/flex.make -# Run target FLEXES to process these. -# REMINDER: add the generated C++ files to your SOURCES, if needed. -############## /FLEXES SOURCES = ManagedThread.cpp \ ThreadPool.cpp \ WorkQueue.cpp |
From: stephan b. <sg...@us...> - 2004-12-23 06:05:49
|
Update of /cvsroot/pclasses/pclasses2/src/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv808 Modified Files: Makefile.toc Log Message: More build fixes. unicode*.h are now generated. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/Makefile.toc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.toc 23 Dec 2004 05:51:43 -0000 1.2 +++ Makefile.toc 23 Dec 2004 06:05:26 -0000 1.3 @@ -5,17 +5,20 @@ String.cpp \ TextStream.cpp - -DIST_FILES += $(SOURCES) $(HEADERS) +SOURCES_GEN = unicodedata.h unicodedata_extra.h OBJECTS = Char.o \ String.o \ TextStream.o +$(OBJECTS): $(SOURCES_GEN) + + +DIST_FILES += $(SOURCES) CLEAN_FILES += $(OBJECTS) build_libs = 1 -LIBNAME = punicode +LIBNAME = libpunicode ifeq (1,$(build_libs)) STATIC_LIBS = $(LIBNAME) SHARED_LIBS = $(STATIC_LIBS) @@ -27,25 +30,24 @@ # Run targets STATIC_LIBS and SHARED_LIBS build these. endif -SOURCES_GEN = unicodedata.h unicodedata_extra.h UNICODE_DATA_FILE = UnicodeData.txt UNICODE_DATA_URL = http://www.unicode.org/Public/UNIDATA/$(UNICODE_DATA_FILE) INSTALL_HEADERS = $(SOURCES_GEN) -$(SOURCES_GEN): - test -f $(UNICODE_DATA_FILE) || wget --passive-ftp $(UNICODE_DATA_URL) - $(AWK_BIN) -f $(top_srcdir)/src/Unicode/unicodedata.awk $(UNICODE_DATA_FILE) >unicodedata.h +$(UNICODE_DATA_FILE): + wget --passive-ftp $(UNICODE_DATA_URL) -UNICODE_CLEAN_FILES = $(UNICODE_DATA_FILE) $(SOURCES_GEN) +$(SOURCES_GEN): $(UNICODE_DATA_FILE) + $(AWK_BIN) -f $(top_srcdir)/src/Unicode/unicodedata.awk $(UNICODE_DATA_FILE) >unicodedata.h -clean-unicode: - $(call toc_clean_files $(UNICODE_CLEAN_FILES)) +UNICODE_CLEAN_FILES = $(SOURCES_GEN) -ifeq (,$(wildcard $(UNICODE_DATA_FILE))) +ifneq (,$(wildcard $(UNICODE_DATA_FILE))) +CLEAN_FILES += $(UNICODE_CLEAN_FILES) # we can afford this if we don't need to download the data file -clean: clean-unicode endif -# distclean: clean-unicode - +STATIC_LIBS: $(SOURCES_GEN) +SHARED_LIBS: STATIC_LIBS all: STATIC_LIBS SHARED_LIBS + |
From: Christian P. <cp...@us...> - 2004-12-23 05:56:27
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31672/src/System Modified Files: File.posix.cpp Pipe.posix.cpp Log Message: Converted File::_handle, Pipe::_handle to unsigned long type. Added std::string support to File. Index: File.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/File.posix.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- File.posix.cpp 23 Dec 2004 05:24:47 -0000 1.3 +++ File.posix.cpp 23 Dec 2004 05:56:10 -0000 1.4 @@ -30,28 +30,82 @@ namespace System { +int OpenMode2Flags(File::OpenMode omode) +{ + int flags = 0; + switch(omode) + { + case File::OpenCreate: + flags |= O_CREAT; + break; + + case File::CreateFail: + flags |= O_CREAT|O_EXCL; + break; + + case File::OpenFail: + break; + } + + return flags; +} + +int AccessMode2Flags(File::AccessMode amode) +{ + int flags = 0; + + switch(amode) + { + case File::None: + break; + + case File::Read: + flags |= O_RDONLY; + break; + + case File::Write: + flags |= O_WRONLY; + break; + + case File::ReadWrite: + flags |= O_RDWR; + break; + } + + return flags; +} + File::File() throw() -: _handle(0) +: _handle((unsigned long)-1) { } File::File(const File& f) throw(IO::IOError) -: IODevice(f), _handle(0) +: IODevice(f), _handle((unsigned long)-1) { int handle = ::dup((int)f._handle); if(handle == -1) throw IO::IOError(errno, "Could not duplicate file handle", P_SOURCEINFO); - _handle = (Handle*)handle; + _handle = (unsigned long)handle; } -File::File(const char* name, OpenMode omode, AccessMode amode, +File::File(const Unicode::String& name, OpenMode omode, AccessMode amode, ShareMode smode) throw(IO::IOError) -: _handle(0) +: _handle((unsigned long)-1) { open(name,omode,amode,smode); } +#ifdef PCLASSES_WITH_STL +File::File(const std::string& name, OpenMode omode, AccessMode amode, + ShareMode smode) throw(IO::IOError) +: _handle((unsigned long)-1) +{ + open(name,omode,amode,smode); +} +#endif + File::~File() throw() { if(valid()) @@ -60,56 +114,51 @@ } } -void File::open(const char* name, OpenMode omode, AccessMode amode, +void File::open(const Unicode::String& name, OpenMode omode, AccessMode amode, ShareMode smode) throw(LogicError, IO::IOError) { if(!valid()) { - int flags = 0; - switch(omode) - { - case OpenCreate: - flags |= O_CREAT; - break; - - case CreateFail: - flags |= O_CREAT|O_EXCL; - break; + int flags = OpenMode2Flags(omode) | AccessMode2Flags(amode); - case OpenFail: - break; - } + /*@fixme int handle = ::open(name.utf8(), flags); + if(handle == -1) + throw IO::IOError(errno, "Could not open file", P_SOURCEINFO); - switch(amode) - { - case None: - break; + _handle = (unsigned long)handle; + IODevice::setAccess(amode); + IODevice::setValid(true); + IODevice::setEof(false);*/ - case Read: - flags |= O_RDONLY; - break; + return; + } - case Write: - flags |= O_WRONLY; - break; + throw LogicError("File is already open", P_SOURCEINFO); +} - case ReadWrite: - flags |= O_RDWR; - break; - } +#ifdef PCLASSES_WITH_STL +void File::open(const std::string& name, OpenMode omode, AccessMode amode, + ShareMode smode) throw(LogicError, IO::IOError) +{ + if(!valid()) + { + int flags = OpenMode2Flags(omode) | AccessMode2Flags(amode); - int handle = ::open(name, flags); + int handle = ::open(name.c_str(), flags); if(handle == -1) throw IO::IOError(errno, "Could not open file", P_SOURCEINFO); - _handle = (Handle*)handle; + _handle = (unsigned long)handle; IODevice::setAccess(amode); IODevice::setValid(true); IODevice::setEof(false); + + return; } throw LogicError("File is already open", P_SOURCEINFO); } +#endif void File::close() throw(LogicError, IO::IOError) { @@ -118,8 +167,10 @@ if(::close((int)_handle) == -1) throw IO::IOError(errno, "Could not close file", P_SOURCEINFO); + _handle = (unsigned long)-1; IODevice::setAccess(None); IODevice::setValid(false); + return; } throw LogicError("File is not open", P_SOURCEINFO); @@ -257,7 +308,7 @@ } IODevice::operator=(f); - _handle = (Handle*)handle; + _handle = (unsigned long)handle; return *this; } Index: Pipe.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Pipe.posix.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Pipe.posix.cpp 23 Dec 2004 04:32:18 -0000 1.2 +++ Pipe.posix.cpp 23 Dec 2004 05:56:11 -0000 1.3 @@ -29,7 +29,7 @@ namespace System { -Pipe::Pipe(Handle* h, bool readEnd) throw() +Pipe::Pipe(unsigned long h, bool readEnd) throw() : _handle(h) { IODevice::setAccess(readEnd ? Read : Write); @@ -38,13 +38,13 @@ } Pipe::Pipe(const Pipe& p) throw(IO::IOError) -: IODevice(p), _handle(0) +: IODevice(p), _handle((unsigned long)-1) { int handle = ::dup((int)p._handle); if(handle == -1) throw IO::IOError(errno, "Could not duplicate pipe handle", P_SOURCEINFO); - _handle = (Handle*)handle; + _handle = (unsigned long)handle; } Pipe::~Pipe() throw() @@ -62,8 +62,8 @@ if(pipe(fds) == -1) throw IO::IOError(errno, "Could not create pipe", P_SOURCEINFO); - Pipe readPipe((Handle*)fds[0], true); - Pipe writePipe((Handle*)fds[1], false); + Pipe readPipe((unsigned long)fds[0], true); + Pipe writePipe((unsigned long)fds[1], false); return Pair(readPipe, writePipe); } @@ -75,6 +75,7 @@ if(::close((int)_handle) == -1) throw IO::IOError(errno, "Could not close pipe", P_SOURCEINFO); + _handle = (unsigned long)-1; IODevice::setAccess(None); IODevice::setValid(false); } @@ -149,7 +150,7 @@ } IODevice::operator=(p); - _handle = (Handle*)handle; + _handle = (unsigned long)handle; return *this; } |
From: Christian P. <cp...@us...> - 2004-12-23 05:56:19
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31672/include/pclasses/System Modified Files: File.h Pipe.h Log Message: Converted File::_handle, Pipe::_handle to unsigned long type. Added std::string support to File. Index: Pipe.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/Pipe.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Pipe.h 23 Dec 2004 04:32:17 -0000 1.2 +++ Pipe.h 23 Dec 2004 05:56:09 -0000 1.3 @@ -50,10 +50,8 @@ Pipe& operator=(const Pipe& f) throw(IO::IOError); private: - struct Handle; - Handle* _handle; - - Pipe(Handle* h, bool readEnd) throw(); + unsigned long _handle; + Pipe(unsigned long h, bool readEnd) throw(); }; } // !namespace System Index: File.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/File.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- File.h 23 Dec 2004 04:32:16 -0000 1.2 +++ File.h 23 Dec 2004 05:56:09 -0000 1.3 @@ -21,8 +21,13 @@ #ifndef P_System_File_h #define P_System_File_h +#include <pclasses/Unicode/String.h> #include <pclasses/IO/IODevice.h> +#ifdef PCLASSES_WITH_STL +# include <string> +#endif + namespace P { namespace System { @@ -33,14 +38,24 @@ File(const File& f) throw(IO::IOError); - File(const char* name, OpenMode omode, AccessMode amode, + File(const Unicode::String& name, OpenMode omode, AccessMode amode, + ShareMode smode) throw(IO::IOError); + +#ifdef PCLASSES_WITH_STL + File(const std::string& name, OpenMode omode, AccessMode amode, ShareMode smode) throw(IO::IOError); +#endif ~File() throw(); - void open(const char* name, OpenMode omode, AccessMode amode, + void open(const Unicode::String& name, OpenMode omode, AccessMode amode, ShareMode smode) throw(LogicError, IO::IOError); +#ifdef PCLASSES_WITH_STL + void open(const std::string& name, OpenMode omode, AccessMode amode, + ShareMode smode) throw(LogicError, IO::IOError); +#endif + void close() throw(LogicError, IO::IOError); size_t read(char* buffer, size_t count) throw(IO::IOError); @@ -60,8 +75,7 @@ File& operator=(const File& f) throw(IO::IOError); private: - struct Handle; - Handle* _handle; + unsigned long _handle; }; } // !namespace System |
From: stephan b. <sg...@us...> - 2004-12-23 05:55:20
|
Update of /cvsroot/pclasses/pclasses2/src/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31616 Added Files: Makefile.toc Log Message: egg --- NEW FILE: Makefile.toc --- #!/usr/bin/make -f include toc.make SOURCES = IODevice.cpp \ IOError.cpp DIST_FILES += $(SOURCES) OBJECTS = IODevice.o \ IOError.o CLEAN_FILES += $(OBJECTS) build_libs = 1 LIBNAME = libpio ifeq (1,$(build_libs)) STATIC_LIBS = $(LIBNAME) SHARED_LIBS = $(STATIC_LIBS) $(LIBNAME)_a_OBJECTS = $(OBJECTS) $(LIBNAME)_so_OBJECTS = $($(LIBNAME)_a_OBJECTS) $(LIBNAME)_so_VERSION = $(PACKAGE_VERSION) # $(LIBNAME)_so_LDADD = include $(TOC_MAKESDIR)/SHARED_LIBS.make include $(TOC_MAKESDIR)/STATIC_LIBS.make # Run targets STATIC_LIBS and SHARED_LIBS build these. endif all: STATIC_LIBS SHARED_LIBS |
From: stephan b. <sg...@us...> - 2004-12-23 05:54:44
|
Update of /cvsroot/pclasses/pclasses2/src/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31493 Modified Files: IODevice.cpp Log Message: added a missing return *this from op=(IOD) Index: IODevice.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/IO/IODevice.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- IODevice.cpp 23 Dec 2004 04:32:17 -0000 1.1 +++ IODevice.cpp 23 Dec 2004 05:54:27 -0000 1.2 @@ -114,6 +114,7 @@ _valid = dev._valid; _access = dev._access; _eof = dev._eof; + return *this; } |
From: stephan b. <sg...@us...> - 2004-12-23 05:51:51
|
Update of /cvsroot/pclasses/pclasses2/src/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30991 Modified Files: Makefile.toc Log Message: builds :) Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/Makefile.toc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.toc 23 Dec 2004 00:18:54 -0000 1.1 +++ Makefile.toc 23 Dec 2004 05:51:43 -0000 1.2 @@ -1,22 +1,51 @@ -################################################### -# AUTO-GENERATED guess at a toc-aware Makefile, -# based off of the contents of directory: -# ./src/Unicode -# Created by ./toc/bin/create_makefile_stubs.sh -# Wed Dec 22 23:10:45 CET 2004 -# It must be tweaked to suit your needs. -################################################### +#!/usr/bin/make -f include toc.make -############## FLEXES: -# WARNING: FLEXES stuff only works for C++-based flexers -FLEXES = -FLEXES_ARGS = -+ -p -OBJECTS += -include $(TOC_MAKESDIR)/flex.make -# Run target FLEXES to process these. -# REMINDER: add the generated C++ files to your SOURCES, if needed. -############## /FLEXES -all: -################################################### -# end auto-generated rules -################################################### + +SOURCES = Char.cpp \ + String.cpp \ + TextStream.cpp + + +DIST_FILES += $(SOURCES) $(HEADERS) + +OBJECTS = Char.o \ + String.o \ + TextStream.o + +CLEAN_FILES += $(OBJECTS) + +build_libs = 1 +LIBNAME = punicode +ifeq (1,$(build_libs)) + STATIC_LIBS = $(LIBNAME) + SHARED_LIBS = $(STATIC_LIBS) + $(LIBNAME)_a_OBJECTS = $(OBJECTS) + $(LIBNAME)_so_OBJECTS = $($(LIBNAME)_a_OBJECTS) + $(LIBNAME)_so_VERSION = $(PACKAGE_VERSION) + include $(TOC_MAKESDIR)/SHARED_LIBS.make + include $(TOC_MAKESDIR)/STATIC_LIBS.make + # Run targets STATIC_LIBS and SHARED_LIBS build these. +endif + +SOURCES_GEN = unicodedata.h unicodedata_extra.h +UNICODE_DATA_FILE = UnicodeData.txt +UNICODE_DATA_URL = http://www.unicode.org/Public/UNIDATA/$(UNICODE_DATA_FILE) +INSTALL_HEADERS = $(SOURCES_GEN) +$(SOURCES_GEN): + test -f $(UNICODE_DATA_FILE) || wget --passive-ftp $(UNICODE_DATA_URL) + $(AWK_BIN) -f $(top_srcdir)/src/Unicode/unicodedata.awk $(UNICODE_DATA_FILE) >unicodedata.h + +UNICODE_CLEAN_FILES = $(UNICODE_DATA_FILE) $(SOURCES_GEN) + +clean-unicode: + $(call toc_clean_files $(UNICODE_CLEAN_FILES)) + +ifeq (,$(wildcard $(UNICODE_DATA_FILE))) +# we can afford this if we don't need to download the data file +clean: clean-unicode +endif + + +# distclean: clean-unicode + +all: STATIC_LIBS SHARED_LIBS |
From: stephan b. <sg...@us...> - 2004-12-23 05:51:28
|
Update of /cvsroot/pclasses/pclasses2/src/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30913 Modified Files: String.cpp Log Message: added several returns to NYI operators to please gcc. Commented out some no-op code which throws a warning. Added an ACHTUNG regarding a cast. Index: String.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/String.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- String.cpp 23 Dec 2004 04:32:18 -0000 1.1 +++ String.cpp 23 Dec 2004 05:51:19 -0000 1.2 @@ -98,10 +98,10 @@ newLength = length; } - else - { - size_t len1; - } +// else +// { +// size_t len1; +// } newData->str = (Char*)newStr; newData->size = sz; @@ -169,7 +169,11 @@ Char& String::operator[](ptrdiff_t pos) throw(OutOfMemory, OutOfBounds) { - if(pos >= _length) + if( static_cast<size_t>( pos ) + /** ACHTUNG ^^^^ cast added by stephan to avoid warning. + @Christian: how do you want to handle this case? + */ + >= _length) throw OutOfBounds("Index is out of bounds", P_SOURCEINFO); makeUnique(); @@ -238,16 +242,19 @@ bool String::operator!=(const String& str) const throw() { return !operator==(str); + return false; } bool String::operator<(const String& str) const throw() { //@todo String::operator< + return false; } bool String::operator>(const String& str) const throw() { //@todo String::operator> + return false; } bool String::operator<=(const String& str) const throw() |