You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(86) |
Dec
(163) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(114) |
Feb
(254) |
Mar
(166) |
Apr
(122) |
May
(131) |
Jun
(59) |
Jul
(201) |
Aug
(85) |
Sep
(80) |
Oct
(64) |
Nov
(103) |
Dec
(36) |
2005 |
Jan
(231) |
Feb
(204) |
Mar
(71) |
Apr
(54) |
May
(50) |
Jun
(120) |
Jul
(17) |
Aug
(124) |
Sep
(75) |
Oct
(154) |
Nov
(37) |
Dec
(143) |
2006 |
Jan
(346) |
Feb
(170) |
Mar
|
Apr
|
May
(273) |
Jun
(113) |
Jul
(427) |
Aug
(570) |
Sep
(212) |
Oct
(550) |
Nov
(348) |
Dec
(314) |
2007 |
Jan
(709) |
Feb
(223) |
Mar
(104) |
Apr
(24) |
May
(11) |
Jun
(3) |
Jul
(5) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:17
|
Update of /cvsroot/ccmtools/ccmtools/src-test/ccmtools/parser/cpp In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25149/src-test/ccmtools/parser/cpp Modified Files: CppTest.java Log Message: Added support for windows cl preprocessor. Index: CppTest.java =================================================================== RCS file: /cvsroot/ccmtools/ccmtools/src-test/ccmtools/parser/cpp/CppTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CppTest.java 18 Jan 2007 17:11:46 -0000 1.1 --- CppTest.java 22 Jan 2007 13:05:12 -0000 1.2 *************** *** 2,33 **** import java.io.File; import java.io.IOException; ! import java.util.Hashtable; ! import java.util.Vector; import junit.framework.Test; - import junit.framework.TestCase; import junit.framework.TestSuite; - /** - * Here we test a Java implementation of a simple C PreProcessor (cpp) stolen from - * the http://jonathan.objectweb.org/ project (org.objectweb.jonathan.tools.JPP). - * - * Bugs: - * - There must be a space between #include and "" (e.g. #include"xy.idl" is an error) - * - */ public class CppTest ! extends TestCase { private String ccmtoolsDir; private String testDir; ! ! public CppTest(String name) { super(name); ccmtoolsDir = System.getProperty("user.dir"); ! testDir = ccmtoolsDir + File.separator + "test" + File.separator + "CppGenerator"; } --- 2,34 ---- import java.io.File; + import java.io.FileNotFoundException; import java.io.IOException; ! import java.util.ArrayList; ! import java.util.List; import junit.framework.Test; import junit.framework.TestSuite; + import ccmtools.CcmtoolsException; + import ccmtools.parser.idl.ParserManager; + import ccmtools.test.CcmtoolsTestCase; + import ccmtools.ui.ConsoleDriver; + import ccmtools.ui.UserInterfaceDriver; public class CppTest ! extends CcmtoolsTestCase { private String ccmtoolsDir; private String testDir; ! ! protected UserInterfaceDriver uiDriver; ! ! ! public CppTest(String name) throws FileNotFoundException { super(name); + uiDriver = new ConsoleDriver(); ccmtoolsDir = System.getProperty("user.dir"); ! testDir = ccmtoolsDir + File.separator + "test" + File.separator + "Cpp"; } *************** *** 42,60 **** // ------------------------------------------------------------------------ ! public void testIncludeNested() throws IOException { ! String inputDir = testDir + File.separator + "include_nested"; String inputFile = inputDir + File.separator + "Hello.idl"; - String includePath = inputDir; ! Vector includes = new Vector(); ! includes.add(includePath); ! Hashtable names = new Hashtable(); ! JPP jpp = new JPP(inputFile, System.out, includes, names); ! jpp.preprocess(); } } --- 43,130 ---- // ------------------------------------------------------------------------ ! ! public void testGnuCpp() throws CcmtoolsException { ! String inputDir = testDir + File.separator + "gnu_cpp"; String inputFile = inputDir + File.separator + "Hello.idl"; ! ParserManager.parseIdlFile(uiDriver, inputFile, false); ! } ! ! public void testCnuCppWithError() ! { ! String inputDir = testDir + File.separator + "gnu_cpp"; ! String inputFile = inputDir + File.separator + "HelloWithError.idl"; ! try ! { ! ParserManager.parseIdlFile(uiDriver, inputFile, false); ! fail("Didn't handle syntax error!!!"); ! } ! catch(CcmtoolsException e) ! { ! System.out.println("> expected error: " + e.getMessage()); ! assertEquals("idl/Hello.idl line 18: Syntax error", e.getMessage()); ! } ! } ! ! ! public void testWindowsCl() throws CcmtoolsException ! { ! String inputDir = testDir + File.separator + "windows_cl"; ! String inputFile = inputDir + File.separator + "Hello.idl"; ! ParserManager.parseIdlFile(uiDriver, inputFile, false); ! } ! ! public void testWindowsClWithError() ! { ! String inputDir = testDir + File.separator + "windows_cl"; ! String inputFile = inputDir + File.separator + "HelloWithError.idl"; ! ! try ! { ! ParserManager.parseIdlFile(uiDriver, inputFile, false); ! fail("Didn't handle syntax error!!!"); ! } ! catch(CcmtoolsException e) ! { ! System.out.println("> expected error: " + e.getMessage()); ! assertEquals("Hello.idl line 18: Syntax error", e.getMessage()); ! } ! } ! ! ! public void testInternalCpp() throws IOException, CcmtoolsException ! { ! String inputDir = testDir + File.separator + "multiple_source_files" + File.separator + "idl"; ! String inputFile = inputDir + File.separator + "Hello.idl"; ! ! List<String> includes = new ArrayList<String>(); ! includes.add(inputDir); ! PreProcessor cpp = new InternalCpp(); ! cpp.process(uiDriver, inputFile, includes); ! ! ParserManager.parseIdlFile(uiDriver, inputFile); ! } + + public void testInternalCppIdl3Repo() throws IOException, CcmtoolsException + { + String inputDir = testDir + File.separator + "multiple_source_files" + File.separator + "idl3Repo"; + String inputFile = inputDir + File.separator + "component" + File.separator + "Hello.idl"; + + List<String> includes = new ArrayList<String>(); + includes.add(inputDir + File.separator + "interface"); + includes.add(inputDir + File.separator + "component"); + PreProcessor cpp = new InternalCpp(); + cpp.process(uiDriver, inputFile, includes); + ParserManager.parseIdlFile(uiDriver, inputFile); + + // Problem: Too many open files!!!!! + // There is a bug in the stolen cpp implementation + // see http://jonathan.objectweb.org/ project (org.objectweb.jonathan.tools.JPP) } + } |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:16
|
Update of /cvsroot/ccmtools/ccmtools/src/ccmtools/parser/idl In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25149/src/ccmtools/parser/idl Modified Files: ParserHelper.java ParserManager.java Log Message: Added support for windows cl preprocessor. Index: ParserManager.java =================================================================== RCS file: /cvsroot/ccmtools/ccmtools/src/ccmtools/parser/idl/ParserManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ParserManager.java 19 Jan 2007 12:06:52 -0000 1.2 --- ParserManager.java 22 Jan 2007 13:05:13 -0000 1.3 *************** *** 49,63 **** } ! public static MContainer parseIdlFile(UserInterfaceDriver uiDriver, String idlFileName) throws CcmtoolsException { try { File idlFile = new File(idlFileName); File tmpIdlFile = new File(idlFileName + ".tmp"); ! tmpIdlFile.deleteOnExit(); ! ! uiDriver.printMessage("use JFlex&Cup based IDL parser"); ParserHelper.getInstance().init(); ParserHelper.getInstance().setMainSourceFile(idlFile.getAbsolutePath()); --- 49,71 ---- } ! public static MContainer parseIdlFile(UserInterfaceDriver uiDriver, String idlFileName) throws CcmtoolsException { + return parseIdlFile(uiDriver,idlFileName, true); + } + + public static MContainer parseIdlFile(UserInterfaceDriver uiDriver, String idlFileName, boolean deleteOnExit) + throws CcmtoolsException + { try { File idlFile = new File(idlFileName); File tmpIdlFile = new File(idlFileName + ".tmp"); ! if(deleteOnExit) ! { ! tmpIdlFile.deleteOnExit(); ! } ! uiDriver.printMessage("use JFlex&Cup based IDL parser: " + tmpIdlFile); ParserHelper.getInstance().init(); ParserHelper.getInstance().setMainSourceFile(idlFile.getAbsolutePath()); Index: ParserHelper.java =================================================================== RCS file: /cvsroot/ccmtools/ccmtools/src/ccmtools/parser/idl/ParserHelper.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** ParserHelper.java 19 Jan 2007 12:06:51 -0000 1.43 --- ParserHelper.java 22 Jan 2007 13:05:13 -0000 1.44 *************** *** 2241,2245 **** { getLogger().fine("131: factory " + id + " ( "+ parameters + " ) " + exceptions); - // if(parameters == null) parameters = new ArrayList(); MFactoryDef factory = new MFactoryDefImpl(); --- 2241,2244 ---- *************** *** 2279,2283 **** line = line.substring(0, line.lastIndexOf('\n')); String[] elements = line.split(" "); ! if (elements[0].equals("#")) { if (elements.length >= 3) --- 2278,2283 ---- line = line.substring(0, line.lastIndexOf('\n')); String[] elements = line.split(" "); ! ! if (elements[0].equals("#") || elements[0].equals("#line")) { if (elements.length >= 3) |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:16
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl3Repo/component In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25149/test/Cpp/multiple_source_files/idl3Repo/component Added Files: HelloHome.idl Hello.idl.tmp Hello.idl Log Message: Added support for windows cl preprocessor. --- NEW FILE: Hello.idl --- /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ #ifndef ___HELLO__IDL__ #define ___HELLO__IDL__ #include <Console.idl> #include <Lcd.idl> component Hello { attribute string prompt; provides ::Console console; uses ::Lcd lcd; }; // This is a hack to make the CppGenerator happy !!! #include <HelloHome.idl> #endif /* ___HELLO__IDL__ */ --- NEW FILE: Hello.idl.tmp --- /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ # 10 "/home/eteinik/sandbox/workspace-development/ccmtools-trunk/test/Cpp/multiple_source_files/idl3Repo/interface/Console.idl" 1 /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ # 10 "/home/eteinik/sandbox/workspace-development/ccmtools-trunk/test/Cpp/multiple_source_files/idl3Repo/interface/Message.idl" 1 /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ struct Message { string header; string body; }; # 10 "/home/eteinik/sandbox/workspace-development/ccmtools-trunk/test/Cpp/multiple_source_files/idl3Repo/interface/Message.idl" 2 interface Console { string read_string(in ::Message m); }; # 10 "/home/eteinik/sandbox/workspace-development/ccmtools-trunk/test/Cpp/multiple_source_files/idl3Repo/interface/Console.idl" 2 # 11 "/home/eteinik/sandbox/workspace-development/ccmtools-trunk/test/Cpp/multiple_source_files/idl3Repo/interface/Lcd.idl" 1 /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ interface Lcd { long write_text(in string s2); }; # 11 "/home/eteinik/sandbox/workspace-development/ccmtools-trunk/test/Cpp/multiple_source_files/idl3Repo/interface/Lcd.idl" 2 component Hello { attribute string prompt; provides ::Console console; uses ::Lcd lcd; }; // This is a hack to make the CppGenerator happy !!! # 26 "/home/eteinik/sandbox/workspace-development/ccmtools-trunk/test/Cpp/multiple_source_files/idl3Repo/component/HelloHome.idl" 1 /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ # 10 "/home/eteinik/sandbox/workspace-development/ccmtools-trunk/test/Cpp/multiple_source_files/idl3Repo/component/Hello.idl" 1 /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ --- NEW FILE: HelloHome.idl --- /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ #ifndef ___HELLOHOME__IDL__ #define ___HELLOHOME__IDL__ #include <Hello.idl> home HelloHome manages ::Hello { }; #endif /* ___HELLOHOME__IDL__ */ |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:15
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/windows_cl In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25149/test/Cpp/windows_cl Added Files: HelloWithError.idl.tmp Hello.idl.tmp Log Message: Added support for windows cl preprocessor. --- NEW FILE: HelloWithError.idl.tmp --- #line 1 "Hello.idl" #line 1 "c:\\temp\\Console.idl" #line 1 "c:\\temp\\Message.idl" struct Message { string header; string body; }; #line 9 "c:\\temp\\Console.idl" interface Console { string read_string(in Message m); }; #line 10 "Hello.idl" #line 1 "c:\\temp\\Lcd.idl" interface Lcd { long write_text(in string s2); }; #line 11 "Hello.idl" component Hello { attribute string prompt; provides Console console; uses Lcd lcd }; home HelloHome manages Hello { }; --- NEW FILE: Hello.idl.tmp --- #line 1 "Hello.idl" #line 1 "c:\\temp\\Console.idl" #line 1 "c:\\temp\\Message.idl" struct Message { string header; string body; }; #line 9 "c:\\temp\\Console.idl" interface Console { string read_string(in Message m); }; #line 10 "Hello.idl" #line 1 "c:\\temp\\Lcd.idl" interface Lcd { long write_text(in string s2); }; #line 11 "Hello.idl" component Hello { attribute string prompt; provides Console console; uses Lcd lcd; }; home HelloHome manages Hello { }; |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:15
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl3Repo/interface In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25149/test/Cpp/multiple_source_files/idl3Repo/interface Added Files: Message.idl Console.idl Lcd.idl Log Message: Added support for windows cl preprocessor. --- NEW FILE: Message.idl --- /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ #ifndef ___MESSAGE__IDL__ #define ___MESSAGE__IDL__ struct Message { string header; string body; }; #endif /* ___MESSAGE__IDL__ */ --- NEW FILE: Console.idl --- /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ #ifndef ___CONSOLE__IDL__ #define ___CONSOLE__IDL__ #include <Message.idl> interface Console { string read_string(in ::Message m); }; #endif /* ___CONSOLE__IDL__ */ --- NEW FILE: Lcd.idl --- /* * This file was automatically generated by CCM Tools version 0.8.5 * <http://ccmtools.sourceforge.net> * DO NOT EDIT! */ #ifndef ___LCD__IDL__ #define ___LCD__IDL__ interface Lcd { long write_text(in string s2); }; #endif /* ___LCD__IDL__ */ |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:14
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25149/test/Cpp/multiple_source_files/idl Added Files: Message.idl Hello.idl Console.idl Lcd.idl Log Message: Added support for windows cl preprocessor. --- NEW FILE: Message.idl --- /** * * * */ struct Message { string header; string body; }; --- NEW FILE: Hello.idl --- /** * include test * * * ccmtools-c++-generate -p Hello *.idl * ccmtools-c++-make -p Hello */ #include "Console.idl" #include "Lcd.idl" component Hello { attribute string prompt; provides Console console; uses Lcd lcd; }; home HelloHome manages Hello { }; --- NEW FILE: Console.idl --- /** * * * */ #include "Message.idl" interface Console { string read_string(in Message m); }; --- NEW FILE: Lcd.idl --- /** * * * */ interface Lcd { long write_text(in string s2); }; |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:14
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/gnu_cpp In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25149/test/Cpp/gnu_cpp Added Files: Makefile Hello.idl.tmp HelloWithError.idl.tmp Log Message: Added support for windows cl preprocessor. --- NEW FILE: HelloWithError.idl.tmp --- # 1 "idl/Hello.idl" # 1 "<built-in>" # 1 "<command line>" # 1 "idl/Hello.idl" # 9 "idl/Hello.idl" # 1 "idl/Console.idl" 1 # 1 "idl/Message.idl" 1 struct Message { string header; string body; }; # 9 "idl/Console.idl" 2 interface Console { string read_string(in Message m); }; # 10 "idl/Hello.idl" 2 # 1 "idl/Lcd.idl" 1 interface Lcd { long write_text(in string s2); }; # 11 "idl/Hello.idl" 2 component Hello { attribute string prompt; provides Console console; uses Lcd lcd }; home HelloHome manages Hello { }; --- NEW FILE: Makefile --- all: cpp -o Hello.idl.tmp -Iidl idl/Hello.idl clean: rm Hello.idl.tmp --- NEW FILE: Hello.idl.tmp --- # 1 "idl/Hello.idl" # 1 "<built-in>" # 1 "<command line>" # 1 "idl/Hello.idl" # 9 "idl/Hello.idl" # 1 "idl/Console.idl" 1 # 1 "idl/Message.idl" 1 struct Message { string header; string body; }; # 9 "idl/Console.idl" 2 interface Console { string read_string(in Message m); }; # 10 "idl/Hello.idl" 2 # 1 "idl/Lcd.idl" 1 interface Lcd { long write_text(in string s2); }; # 11 "idl/Hello.idl" 2 component Hello { attribute string prompt; provides Console console; uses Lcd lcd; }; home HelloHome manages Hello { }; |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:10
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/windows_cl In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25079/test/Cpp/windows_cl Log Message: Directory /cvsroot/ccmtools/ccmtools/test/Cpp/windows_cl added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:09
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25079/test/Cpp Log Message: Directory /cvsroot/ccmtools/ccmtools/test/Cpp added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:08
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25079/test/Cpp/multiple_source_files Log Message: Directory /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:08
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl3Repo/interface In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25079/test/Cpp/multiple_source_files/idl3Repo/interface Log Message: Directory /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl3Repo/interface added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:08
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/gnu_cpp In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25079/test/Cpp/gnu_cpp Log Message: Directory /cvsroot/ccmtools/ccmtools/test/Cpp/gnu_cpp added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:08
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25079/test/Cpp/multiple_source_files/idl Log Message: Directory /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:08
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl3Repo In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25079/test/Cpp/multiple_source_files/idl3Repo Log Message: Directory /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl3Repo added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:08
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl3Repo/component In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25079/test/Cpp/multiple_source_files/idl3Repo/component Log Message: Directory /cvsroot/ccmtools/ccmtools/test/Cpp/multiple_source_files/idl3Repo/component added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 13:05:03
|
Update of /cvsroot/ccmtools/ccmtools/test/Cpp/gnu_cpp/idl In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25079/test/Cpp/gnu_cpp/idl Log Message: Directory /cvsroot/ccmtools/ccmtools/test/Cpp/gnu_cpp/idl added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 10:09:06
|
Update of /cvsroot/ccmtools/cpp-environment/externals In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14231/externals Modified Files: .cvsignore Log Message: Added utils/code and utils/error to the runtime lib Index: .cvsignore =================================================================== RCS file: /cvsroot/ccmtools/cpp-environment/externals/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 5 Jan 2007 14:09:33 -0000 1.1 --- .cvsignore 22 Jan 2007 10:08:59 -0000 1.2 *************** *** 9,10 **** --- 9,11 ---- autom4te.cache confix-admin + ccm-runtime-externals.repo |
From: Teiniker E. <tei...@us...> - 2007-01-22 10:09:04
|
Update of /cvsroot/ccmtools/cpp-environment/utils/error In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14231/utils/error Added Files: error_macros.h ms_eh.cc errortrace.cc errorout_ostream.cc .cvsignore errorout_ostream.h Confix2.dir error_impl.h errortrace.h doxyerror.h error.h error_impl.cc Log Message: Added utils/code and utils/error to the runtime lib --- NEW FILE: errorout_ostream.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #ifndef wx_utils_error_errorout_ostream_h #define wx_utils_error_errorout_ostream_h #include <iosfwd> #include <wamas/platform/utils/smartptr.h> namespace wamas { namespace platform { namespace utils { class Error; class ErrorNode; class ErrorTrace; void output(const SmartPtr<ErrorNode>&, std::ostream&, int offset=0); void output(const ErrorTrace&, std::ostream&, int offset=0); void output(const Error&, std::ostream&, int offset=0); inline std::ostream& operator<<(std::ostream& s, const ErrorTrace& e) { output(e, s); return s; } inline std::ostream& operator<<(std::ostream& s, const Error& e) { output(e, s); return s; } } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: doxyerror.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // namespace wamas { namespace platform { namespace utils { /** \defgroup utils_error Error Handling Several classes to be used in error handling. Supposed to be used in exception design. There is no multilinguality yet, just the same as it misses other things like error IDs and such. However, these things are supposed grow as our experience grows - so don't be upset. \ingroup utils */ } // /namespace } // /namespace } // /namespace --- NEW FILE: error.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #ifndef wx_utils_error_error_h #define wx_utils_error_error_h #include "error_impl.h" #include "errorout_ostream.h" #include "error_macros.h" #include "errortrace.h" namespace wamas { namespace platform { namespace utils { } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: errortrace.cc --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #include "errortrace.h" namespace wamas { namespace platform { namespace utils { using namespace std; static const deque<SmartPtr<ErrorNode> > empty_trace; // -------------------------------------------------------------------- void ErrorTraceImpl::append(const SmartPtr<ErrorNode>& n) { trace_.push_back(n); } // -------------------------------------------------------------------- ErrorTrace& ErrorTrace::append(const SmartPtr<ErrorNode>& n) { if (!ptr()) eat(new ErrorTraceImpl); ptr()->append(n); return *this; } const deque<SmartPtr<ErrorNode> >& ErrorTrace::trace() const { return cptr()? cptr()->trace(): empty_trace; } } // /namespace } // /namespace } // /namespace --- NEW FILE: errortrace.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #ifndef wx_utils_error_errortrace_h #define wx_utils_error_errortrace_h #include "error.h" #include <wamas/platform/utils/smartptr.h> #include <deque> namespace wamas { namespace platform { namespace utils { class ErrorTraceImpl : public RefCounted { public: void append(const SmartPtr<ErrorNode>&); const std::deque<SmartPtr<ErrorNode> >& trace() const { return trace_; } private: std::deque<SmartPtr<ErrorNode> > trace_; }; /** \ingroup utils_error \brief A list (possibly nested - a tree) of Error objects, each carrying descriptions of particular errors that have happened along execution of a code path. Supposed to be thrown as exception. For a more detailed description and examples see the documentation of class Error. */ class ErrorTrace : private SmartPtr<ErrorTraceImpl> { public: ErrorTrace() {} ErrorTrace(const ErrorTrace&); ErrorTrace& operator=(const ErrorTrace&); ErrorTrace& append(const SmartPtr<ErrorNode>&); int n() const { return trace().size(); } const std::deque<SmartPtr<ErrorNode> >& trace() const; }; inline ErrorTrace::ErrorTrace(const ErrorTrace& t) : SmartPtr<ErrorTraceImpl>(t) {} inline ErrorTrace& ErrorTrace::operator=(const ErrorTrace& t) { SmartPtr<ErrorTraceImpl>::operator=(t); return *this; } } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: error_impl.h --- //// -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #ifndef wx_utils_error_error_impl_h #define wx_utils_error_error_impl_h #include "errorout_ostream.h" #include <wamas/platform/utils/linkassert.h> #include <wamas/platform/utils/smartptr.h> #include <string> #include <sstream> #include <exception> namespace wamas { namespace platform { namespace utils { // we cannot have an ErrorTrace automatic member because errortrace.h // in turn includes this file, which would end up in circular // includes. so we have to forward declare it and manage it in the .cc // file instead. class ErrorTrace; /** \ingroup utils_error \brief Conceptually, An Error object is a description of an error that happened, either directly or indirectly. Supposed to be thrown as exception. As objects of type Error are supposed to be thrown as exceptions, it makes sense to derive from them (Error itself derives from std::exception) to emphasize a specific failure condition at a particular point in code, but still provide the common Error interface (which is described in the remainder). An Error carries a punctual description (message()) of an error that has happened. Along with this description it can (should) carry the file name and a line number (file(), line()) of the code location where it happened. An Error can own a nested ErrorTrace object, which is basically a list of Error objects. For example, a common use for this is if you are calling a function which throws an Error object as exception. Then you may want to decribe this error in your own (more high level) terms, like "Could not write this record to disk because the marshaller failed (detailed description follows)" (what follows is the marshaller's Error, contained in the trace). Here's a small example of how to use it. \code Error caught; // e.g. caught by an exception handler Error error; SmartPtr<ErrorNode> node( new ErrorNode(__FILE__,__LINE__,"My own high level description")); node->children(caught.root()); error.root(node); throw error; \endcode So, this example isn't really small as it introduces all of Error at once. Fortunately, there are helper macros which make life a lot easier. Typical uses are \code #include <wamas/platform/utils/error_macros.h> COMPOSE_ERROR_MSG(DerivedError, err, "My " << 2 << " bucks here"); \endcode which declares a variable err of type DerivedError (which, as the name suggests, is derived from class Error). Note the demonstrative use of the output operator: you compose a message just as you do with ostreams. Another typical use is \code #include <wamas/platform/utils/error_macros.h> THROW_ERROR_MSG(DerivedError, "My " << 2 << " bucks here"); \endcode which does the same as above, except that it throws the object immediately instead. */ class ErrorNode : public RefCounted { public: ErrorNode(); ErrorNode(const SmartPtr<ErrorNode>&); ErrorNode(const char *, int, const char *); ErrorNode(const char *, int, const char *, const SmartPtr<ErrorNode>&); ~ErrorNode() throw(); ErrorNode& file(const std::string& f) { file_ = f; return *this; } ErrorNode& line(int l) { line_ = l; return *this; } ErrorNode& message(const std::string& m) { message_ = m; return *this; } ErrorNode& addChild(const SmartPtr<ErrorNode>&); const std::string& file() const { return file_; } int line() const { return line_; } const std::string& message() const { return message_; } const ErrorTrace& children() const { return *children_; } ErrorNode& operator=(const ErrorNode&); private: std::string file_; int line_; std::string message_; ErrorTrace* children_; }; class Error : public std::exception { public: Error() {} Error(const SmartPtr<ErrorNode>& n) { root_ = n; } Error(const Error& e) { root_ = e.root(); } Error(Error* e) { root_ = e->root(); } ~Error() throw() {} const SmartPtr<ErrorNode>& root() const { return root_; }; Error& root(const SmartPtr<ErrorNode>& root) { root_ = root; return *this; } template<class T> void addChildren(const T& children) { if ( !this->root_ ) this->root_.eat(new ErrorNode); for ( typename T::const_iterator i=children.begin(); i != children.end(); ++i ) { this->root_->addChild(i->root()); } } Error& operator=(const Error&); bool good() const { return !root_; } operator bool() const { return !good(); } virtual const char* what() const throw (); LTA_MEMDECL(3); private: SmartPtr<ErrorNode> root_; mutable std::string what_; }; LTA_STATDEF(Error, 3); } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: error_macros.h --- #ifndef wx_utils_error_error_macros_h #define wx_utils_error_error_macros_h #include <sstream> namespace wamas { namespace platform { namespace utils { /** \def COMPOSE_ERROR(ErrorType, var) \ingroup utils_error \brief Instantiate an error of type \c ErrorType, with name \c var */ #define COMPOSE_ERROR(ErrorType, var) \ ErrorType var; \ /** \def COMPOSE_ERROR_ERROR(ErrorType, var, e) \ingroup utils_error \brief Instantiate an error of type \c ErrorType, with name \c var, which contains the nested error \c e */ #define COMPOSE_ERROR_ERROR(ErrorType, var, e) \ COMPOSE_ERROR(ErrorType, var);\ { \ wamas::platform::utils::SmartPtr<wamas::platform::utils::ErrorNode> const& child = e.root(); \ if ( child.ptr() ) { \ var.root(child);\ } \ } /** \def COMPOSE_NODE_NO_MSG \ingroup utils_error \brief Instantiate an node of type \c ErrorNode, with name \c node, contains the message \c msg. \c msg is an expression that can contain anything an \c ostream can take. */ #define COMPOSE_NODE_NO_MSG \ wamas::platform::utils::SmartPtr<wamas::platform::utils::ErrorNode> node(new wamas::platform::utils::ErrorNode); \ node->file(__FILE__); \ node->line(__LINE__); /** \def COMPOSE_NODE_MSG(msg) \ingroup utils_error \brief Instantiate an node of type \c ErrorNode, with name \c node, contains the message \c msg. \c msg is an expression that can contain anything an \c ostream can take. */ #define COMPOSE_NODE_MSG(msg) \ wamas::platform::utils::SmartPtr<wamas::platform::utils::ErrorNode> node(new wamas::platform::utils::ErrorNode); \ std::ostringstream os; \ os << msg; \ node->file(__FILE__); \ node->line(__LINE__); \ node->message(os.str()); /** \def COMPOSE_ERROR_MSG(ErrorType, var, msg) \ingroup utils_error \brief Instantiate an error of type \c ErrorType, with name \c var, which contains the message \c msg Instantiate an error of type \c ErrorType, with name \c var, which contains the message \c msg. \c msg is an expression that can contain anything an \c ostream can take. */ #define COMPOSE_ERROR_MSG_MAKE_MSG(var, msg) \ { \ COMPOSE_NODE_MSG(msg) \ var.root(node); \ } #define COMPOSE_ERROR_MSG(ErrorType, var, msg) \ COMPOSE_ERROR(ErrorType, var) \ COMPOSE_ERROR_MSG_MAKE_MSG(var, msg) \ /** \def COMPOSE_ERROR_TRACE_MSG(ErrorType, var, tr, msg) \ingroup utils_error \brief Instantiate an error of type \c ErrorType, with name \c var, which contains a nested list of errors, \c tr, and contains the message \c msg Instantiate an error of type \c ErrorType, with name \c var, which contains a nested list of errors, \c tr, and contains the message \c msg. \c msg is an expression that can contain anything an \c ostream can take. */ #define COMPOSE_ERROR_TRACE_MSG(ErrorType, var, tr, msg) \ COMPOSE_ERROR_MSG(ErrorType, var, msg) \ { \ wamas::platform::utils::SmartPtr<wamas::platform::utils::ErrorNode> root(var.root()); \ root->addChild(tr); \ } /** \def COMPOSE_ERROR_ERROR_MSG(ErrorType, var, e, msg) \ingroup utils_error \brief Instantiate an error of type \c ErrorType, with name \c var, which contains a nested error, \c e, and contains the message \c msg Instantiate an error of type \c ErrorType, with name \c var, which contains a nested error, \c e, and contains the message \c msg. \c msg is an expression that can contain anything an \c ostream can take. */ #define COMPOSE_ERROR_ERROR_MSG(ErrorType, var, e, msg) \ COMPOSE_ERROR_MSG(ErrorType, var, msg) \ {\ wamas::platform::utils::SmartPtr<wamas::platform::utils::ErrorNode> root = var.root(); \ wamas::platform::utils::SmartPtr<wamas::platform::utils::ErrorNode> const& child = e.root(); \ if ( child.ptr() ) { \ root->addChild(e.root());\ } \ } /** \def THROW_ERROR(ErrorType) \ingroup utils_error \brief Throws an error that is composed using \ref COMPOSE_ERROR */ #define THROW_ERROR(ErrorType) \ { \ COMPOSE_ERROR(ErrorType, var); \ { \ COMPOSE_NODE_NO_MSG \ var.root(node); \ }\ throw var; \ } /** \def THROW_ERROR_MSG(ErrorType, msg) \ingroup utils_error \brief Throws an error that is composed using \ref COMPOSE_ERROR_MSG */ #define THROW_ERROR_MSG(ErrorType, msg) \ { \ COMPOSE_ERROR_MSG(ErrorType, var, msg); \ throw var; \ } /** \def THROW_ERROR_TRACE_MSG(ErrorType, tr, msg) \ingroup utils_error \brief Throws an error that is composed using \ref COMPOSE_ERROR_TRACE_MSG */ #define THROW_ERROR_TRACE_MSG(ErrorType, tr, msg) \ { \ COMPOSE_ERROR_TRACE_MSG(ErrorType, var, tr, msg); \ throw var; \ } /** \def THROW_ERROR_ERROR_MSG(ErrorType, e, msg) \ingroup utils_error \brief Throws an error that is composed using \ref COMPOSE_ERROR_ERROR_MSG */ #define THROW_ERROR_ERROR_MSG(ErrorType, e, msg) \ { \ COMPOSE_ERROR_ERROR_MSG(ErrorType, var, e, msg); \ throw var; \ } /** \def THROW_ERROR_APPEND_MSG(e, msg) \ingroup utils_error \brief Throws an error that is composed using \ref COMPOSE_ERROR_ERROR_MSG */ #define THROW_ERROR_APPEND_MSG(e, msg)\ { \ COMPOSE_NODE_MSG(msg) \ node->addChild(e.root()); \ e.root(node); \ throw; \ } /** \def THROW_ERRORLIST(e, list, msg) \param e error class \param list any STL-compatible type which provides begin() and end() \param msg error message \ingroup utils_error \brief Throws a list of errors. */ #define THROW_ERRORLIST(ErrorType, list, msg) \ { \ COMPOSE_ERROR_MSG( ErrorType, var, msg); \ var.addChildren(list); \ throw var; \ } /** * \def CONVERT_UNKNOWN_ERROR(ErrorType,msg) * * \brief catches and converts unknown exceptions * * \param ErrorType error class to convert to * \param msg error message * * \ingroup utils_error */ #define CONVERT_UNKNOWN_ERROR(ErrorType, msg) \ catch(const wamas::platform::utils::Error& e) \ { THROW_ERROR_ERROR_MSG(ErrorType, e, msg); } \ catch(const std::exception& e) \ { THROW_ERROR_MSG(ErrorType, msg << '\n' << e.what()); } \ catch(...) \ { THROW_ERROR_MSG(ErrorType, msg << "\nUNKNOWN EXCEPTION"); } #define CONVERT_UNKNOWN_ERROR1(ErrorType1, msg) \ catch(const ErrorType1&) { throw; } \ CONVERT_UNKNOWN_ERROR(ErrorType1, msg) #define CONVERT_UNKNOWN_ERROR2(ErrorType1, ErrorType2, msg) \ catch(const ErrorType2&) { throw; } \ CONVERT_UNKNOWN_ERROR1(ErrorType1, msg) #define CONVERT_UNKNOWN_ERROR3(ErrorType1, ErrorType2, ErrorType3, msg) \ catch(const ErrorType3&) { throw; } \ CONVERT_UNKNOWN_ERROR2(ErrorType1, ErrorType2, msg) } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: error_impl.cc --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #include "error_impl.h" #include "errortrace.h" #include "errorout_ostream.h" #include <sstream> #if !defined(_WIN32) # include <unistd.h> #endif namespace wamas { namespace platform { namespace utils { using namespace std; static const ErrorTrace empty_trace; // -------------------------------------------------------------------- LTA_MEMDEF(Error, 3, "$Id$"); // -------------------------------------------------------------------- // class ErrorNode ErrorNode::ErrorNode() : line_(0), children_(new ErrorTrace) {} ErrorNode::ErrorNode(const SmartPtr<ErrorNode>& n) : line_(0), children_(new ErrorTrace) { children_->append(n); } ErrorNode::ErrorNode(const char*f, const int l, const char* m) : file_(f), line_(l), message_(m), children_(new ErrorTrace) {} ErrorNode::ErrorNode(const char* f, int l, const char* m, const SmartPtr<ErrorNode>& n) : file_(f), line_(l), message_(m), children_(new ErrorTrace) { children_->append(n); } ErrorNode::~ ErrorNode() throw() { try { delete children_; } catch (...) { // we caught an exception from code we assumed to be // trivial. obviously we cannot assume iostream is still ok, so // we write this message with brute raw force. static const char* msg = "ErrorNode::~ErrorNode(): caught an exception\n"; #if defined(_WIN32) fprintf(stderr,"%s",msg); #else ::write(STDERR_FILENO, msg, strlen(msg)); #endif abort(); } } ErrorNode& ErrorNode::addChild(const SmartPtr<ErrorNode>& n) { children_->append(n); return *this; } ErrorNode& ErrorNode::operator =(const ErrorNode& e) { file_ = e.file_; line_ = e.line_; message_ = e.message_; *children_ = e.children(); return *this; } // -------------------------------------------------------------------- // class Error Error& Error::operator =(const Error& e) { root(e.root()); return *this; } const char* Error::what() const throw() { try { ostringstream os; output(*this, os); what_ = os.str(); return what_.c_str(); } catch (...) { // we caught an exception from code we assumed to be // trivial. obviously we cannot assume iostream is still ok, so // we write this message with brute raw force. static const char* msg = "Error::what(): caught an exception\n"; #if defined(_WIN32) fprintf(stderr,"%s",msg); #else ::write(STDERR_FILENO, msg, strlen(msg)); #endif abort(); } } } // /namespace } // /namespace } // /namespace --- NEW FILE: Confix2.dir --- --- NEW FILE: errorout_ostream.cc --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #include "errorout_ostream.h" #include "error_impl.h" #include "errortrace.h" namespace wamas { namespace platform { namespace utils { using namespace std; // -------------------------------------------------------------------- static inline void output_offset(ostream& o, int offset) { for (int i=0; i<offset; i++) o << ' '; } void output(const SmartPtr<ErrorNode>& n, ostream& o, int offset) { output_offset(o, offset); o << n->message() << " (" << ( n->file().size() ? n->file(): "(unknown)") << ':' << n->line() << ":)\n"; } void output(const ErrorTrace& t, ostream& o, int offset) { for (int i=0; i<(int)t.trace().size(); i++) { if(i) o << '\n'; output(t.trace()[i], o, offset); if (t.trace()[i]->children().trace().size()) { output(t.trace()[i]->children(), o, offset+2); } } } void output(const Error& e, ostream& o, int offset) { SmartPtr<ErrorNode> root=e.root(); if ( root ) { output(root, o, offset); if (root->children().trace().size()) output(root->children(), o, offset+2); } } } // /namespace } // /namespace } // /namespace --- NEW FILE: ms_eh.cc --- /** @file ms_eh.cc @brief converts MS-SEH-exceptions into wamas::platform::utils::Error */ #include "error.h" #ifdef _MSC_VER #include <excpt.h> #include <windows.h> #define CONVERT_SE(SE) case SE: s= #SE ; break; namespace wamas { namespace platform { namespace utils { namespace MS_SEH { static void se_translator(unsigned int i, EXCEPTION_POINTERS* p) { std::string s; switch(i) { CONVERT_SE(EXCEPTION_ACCESS_VIOLATION) CONVERT_SE(EXCEPTION_BREAKPOINT) CONVERT_SE(EXCEPTION_DATATYPE_MISALIGNMENT) CONVERT_SE(EXCEPTION_SINGLE_STEP) CONVERT_SE(EXCEPTION_ARRAY_BOUNDS_EXCEEDED) CONVERT_SE(EXCEPTION_FLT_DENORMAL_OPERAND) CONVERT_SE(EXCEPTION_FLT_DIVIDE_BY_ZERO) CONVERT_SE(EXCEPTION_FLT_INEXACT_RESULT) CONVERT_SE(EXCEPTION_FLT_INVALID_OPERATION) CONVERT_SE(EXCEPTION_FLT_OVERFLOW) CONVERT_SE(EXCEPTION_FLT_STACK_CHECK) CONVERT_SE(EXCEPTION_FLT_UNDERFLOW) CONVERT_SE(EXCEPTION_INT_DIVIDE_BY_ZERO) CONVERT_SE(EXCEPTION_INT_OVERFLOW) CONVERT_SE(EXCEPTION_PRIV_INSTRUCTION) CONVERT_SE(EXCEPTION_NONCONTINUABLE_EXCEPTION) default: THROW_ERROR_MSG(wamas::platform::utils::Error, "MS-SE with unknown id " << i); } THROW_ERROR_MSG(wamas::platform::utils::Error, "MS-SE : " << s); } struct SetTranslator { SetTranslator() { _set_se_translator(se_translator); } }; SetTranslator GLOBAL_SE_TRANSLATOR; } // /namespace } // /namespace } // /namespace } // /namespace #endif // _MSC_VER --- NEW FILE: .cvsignore --- Makefile.am Makefile.in |
From: Teiniker E. <tei...@us...> - 2007-01-22 10:09:03
|
Update of /cvsroot/ccmtools/cpp-environment/utils/code In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14231/utils/code Added Files: DebugWriter.h indent.cc smartptr.h debug.h HashSet.h doxycode.h debug.cc StringMap.h atomic_count.h extern_c.h StringMap.cc align.h HashMap.h smartptr.cc Confix2.dir .cvsignore indent.h DebugWriterMgr.h linkassert.h CerrDebugWriter.h Log Message: Added utils/code and utils/error to the runtime lib --- NEW FILE: .cvsignore --- Makefile.am Makefile.in --- NEW FILE: StringMap.h --- // // $Id$ // #ifndef wx_utils_code_stringmap_h #define wx_utils_code_stringmap_h #include "HashMap.h" #include <string> namespace wamas { namespace platform { namespace utils { struct StringHash { std::size_t operator()(std::string const& s) const; }; /** @brief A hash-map with keys of type std::string. */ template< typename T > class StringMap : public HashMap<std::string, T, StringHash> { public: explicit StringMap(std::size_t n) : HashMap<std::string, T, StringHash>(n) {} StringMap() {} }; } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: smartptr.h --- #ifndef wx_utils_code_smartptr_h #define wx_utils_code_smartptr_h #include "atomic_count.h" #include "linkassert.h" #include <iostream> #ifdef WX_REFCOUNTED_COLLECT_NEW #include <map> #endif namespace wamas { namespace platform { namespace utils { /** \brief Base class for all classes which are supposed to be pointed to by a smart pointer. Actually doesn't do anything, but rather provides the interface. \ingroup utils_code \author Joerg Faschingbauer \b COPYING \b A \b REFERENCE \b COUNTED \b THING Copying a refcounted thing is not straightforward yet it is simple. In an ideal world you would pass a class object either by copy or by using a smart pointer. The former method does not care about anything, it just copies, whereas the latter method maintains a reference count inside the object that is being passed. Everything is fine if you don't intermix both methods (which you shouldn't unless there is need to AND you know what you're doing). It gets more complicated if, for example, \b COPY \b CONSTRUCTOR we take a copy of a smartpointed object and pass that copy around using a smart pointer: we get a smart pointer xp that points to some object, say *x. \code SmartPtr<X> xp = get_object(); \endcode Now assume that *x, after execution of that statement, has a refcount of 2 (x->refcount()==2). In other words, another smart pointer (other than xp) points to it somewhere outside our scope. We now copy that object *x (not the smart pointer xp) into another object, *y. \code X* y = new X(*xp.ptr()); \endcode The question is: what reference count must *y now have? Obviously, since the reference count reflects the number of smart pointers pointing at it (well, ideally; one can always dirtily ref() and unref() by hand), the reference count of *y must be ZERO. Otherwise, if we would pass *y around using smart pointers (which would then be responsible for cleanup), we would leak memory. \code XPtr yp = XPtr(y); pass_around(yp); // leak \endcode \b ASSIGNMENT \b OPERATOR Now for the assignment operator. Suppose we get an object *x which is pointed to by, say, 2 smart pointers (x->refcount()==2), one of them being xp. \code SmartPtr<X> xp = get_object(); \endcode Now, eagerly crying for subtle bugs, we want to replace the content of *x with that of some other object newx of class X. \code X newx(...); *xp.ptr() = newx; \endcode The question is: what must be the reference count of *x? Obviously, since the number of smart pointers pointing at it does not change, the reference count must not change, it must still be 2 as before the assignment. */ class RefCounted { public: RefCounted() : refcount_(0) {} virtual ~RefCounted() {} /** @name see the big note above for copy semantics */ //@{ RefCounted(const RefCounted&) : refcount_(0) {} RefCounted& operator=(const RefCounted&) { return *this; } //@} /// increment reference count virtual void ref(); /// decrement reference count virtual void unref(); /// return the reference count long refcount() const { return refcount_; } /** @name simple wrappers to accommodate null pointers */ //@{ static void ref(RefCounted* r) { if (r) r->ref(); } static void unref(RefCounted* r) { if (r) r->unref(); } //@} #ifdef WX_REFCOUNTED_COLLECT_NEW void* operator new (std::size_t); void operator delete (void*); typedef std::map<std::size_t, long> NewStatistics; static NewStatistics new_statistics_; #endif private: atomic_count refcount_; public: LTA_MEMDECL(20061107); }; LTA_STATDEF(RefCounted, 20061107); /** \class SmartPtr \ingroup utils_code \brief Template class which manages pointers to RefCounted objects. \author Joerg Faschingbauer Smart pointers are supposed to be used in cases where you do not want to care about memory ownerships. For example, when you pass a pointer to an object to a function, you and the function have to agree upon who is responsible for deleting the object. You use a smart pointer to automatically accomplish that. You wrap a smart pointer around the raw pointer, and pass the smart pointer instead (of course, the function must be prepared to expect a smart pointer). If you are not interested in the object after the call, you simply let the smart pointer go out of scope. The smart pointer's destructor will then decrement the reference count of the pointed-to object, and, if the reference count has become zero, delete it. If you are interested in keeping the object, you store the smart pointer somewhere. This prevents the object's reference count from becoming zero. The function, on the other hand, may decide to store the smart pointer somewhere (and keep a reference on it), or to only temporarily use it and then forget about it (let it go out of scope). */ template <class T> class SmartPtr { public: /** Default constructor. Initially a smart pointer points to nothing (i.e., has the value 0). */ SmartPtr(): ptr_(0) {} /** "Eating" constructor. The object the argument points to is now managed by the smart pointer object. Hence it must not be deleted explicitly afterwards. */ explicit SmartPtr(T* p): ptr_(p) { RefCounted::ref(ptr_); } /** Copy constructor, template version (to be able to assign derived pointees). Increments the reference count on the object by one. */ template<class RHS> SmartPtr(const SmartPtr<RHS>& p): ptr_(0) { operator=(p); } /** Copy constructor, non-template version. Increments the reference count on the object by one. Implementor's note: one would think that the emplate version of the copy ctor should be used by the compiler to generate the default copy ctor. But that's not how C++ is defined - if we do not define an explicit non-template copy ctor, we would get a real default copy ctor which only copies the pointer and does no refcounting. */ SmartPtr(const SmartPtr& p): ptr_(0) { operator=(p); } /** Destructor. Decrements the reference count by one. Deletes the object (better to say, the object deletes itself) if the reference count becomes zero. */ ~SmartPtr() { RefCounted::unref(ptr_); } /** Assignment operator, template version. Same semantics as template copy constructor. */ template<class RHS> SmartPtr& operator=( const SmartPtr<RHS>& p) { if (this->ptr() != p.ptr()) { RefCounted::ref(p.ptr()); RefCounted::unref(this->ptr()); ptr_ = p.ptr(); } return *this; } /** Assignment operator, non-template version. Same semantics as copy constructor. Implementor's note: we have to define a non-template version for the same reason why we have to define a non-template copy ctor. */ SmartPtr& operator=( const SmartPtr& p) { if (this->ptr() != p.ptr()) { RefCounted::ref(p.ptr()); RefCounted::unref(this->ptr()); ptr_ = p.ptr(); } return *this; } /** Acquire responsibility for the object (and increment its reference count). An eventual existing responsibility for a different object is canceled, and that reference is decremented. */ template<class RHS> void eat(RHS* p) { if (p == ptr_) return; RefCounted::unref(ptr_); ptr_ = p; RefCounted::ref(p); } /** Become a NULL pointer. Unreference an object that we are pointing to. */ void forget() { if (ptr_) { RefCounted::unref(ptr_); ptr_ = NULL; } } /** \name Smart pointer comparison */ //@{ operator bool() const { // Doze bullshit yells "Performance warning" if I don't cast // explicitly return static_cast<bool>(ptr_); } bool operator !() const { return !ptr_; } bool operator< (const SmartPtr& that) const { return ptr_< that.ptr_; } bool operator==(const SmartPtr& that) const { return ptr_==that.ptr_; } bool operator> (const SmartPtr& that) const { return ptr_> that.ptr_; } bool operator<=(const SmartPtr& that) const { return ptr_<=that.ptr_; } bool operator>=(const SmartPtr& that) const { return ptr_>=that.ptr_; } //@} /** A pointer to the object, modifiable. */ T* ptr() const { return ptr_; } /** A pointer to the object, modifiable, trading off for readability. */ T* operator->() { return ptr_; } /** A pointer to the object, non-modifiable. */ const T* cptr() const { return ptr_; } /** A pointer to the object, non-modifiable, trading off for readability. */ const T* operator->() const { return ptr_; } private: T* ptr_; }; } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: debug.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #ifndef wx_utils_code_debug_h #define wx_utils_code_debug_h #include <sstream> #include <string> #include "DebugWriterMgr.h" namespace wamas { namespace platform { namespace utils { /** \brief Enable/disable/select debugging. \ingroup utils_code */ class Debug { public: Debug(bool read_env=true); Debug(const std::string& levels, bool read_env=true); ~Debug(); /** Have all debugging messages printed out */ void set_global(bool b) { global_=b; } /** Check whether we output all debugging messages */ bool get_global() { return global_; } /** Have debugging messages with \c level printed out */ void add_level(const std::string& level); void parse_levels(const std::string& levelstr); /** Check whether we output debugging messages with \c level */ bool have_level(const std::string& level); int n_levels(); /** singleton */ static Debug& instance(); private: class DebugImpl* impl_; bool global_; }; /** \def LDEBUGNL(level,msg) \ingroup utils_code \brief Output a message \a msg plus newline if \a level is on. \a level is stringified by the C preprocessor, so you don't enclose it into double quotes. \a msg is anything an ostream can handle. For example, \code int n = some_number(); LDEBUGNL(MyLevel, "Here I have "<<n<<" pieces"); \endcode */ /** \def LDEBUG(level,msg) \brief Same as LDEBUGNL, but without newline \ingroup utils_code */ #ifdef WXDEBUG # define WRITE_MSG_TO_DEBUGWRITER(msg,facility,level)\ {\ std::ostringstream os;\ os << msg << std::ends;\ wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().write(__FILE__,__LINE__,facility,\ level,os.str());\ } // Trace level # define TRACE(msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(""))\ WRITE_MSG_TO_DEBUGWRITER(msg, "",wamas::platform::utils::DebugWriter::Trace)\ } # define TRACENL(msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(""))\ WRITE_MSG_TO_DEBUGWRITER(msg<<'\n',"",wamas::platform::utils::DebugWriter::Trace)\ } # define LTRACE(facility,msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(#facility))\ WRITE_MSG_TO_DEBUGWRITER(msg,#facility,wamas::platform::utils::DebugWriter::Trace)\ } # define LTRACENL(facility,msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(#facility))\ WRITE_MSG_TO_DEBUGWRITER(msg<<'\n',#facility,wamas::platform::utils::DebugWriter::Trace)\ } // Debug level # define DEBUG(msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(""))\ WRITE_MSG_TO_DEBUGWRITER(msg, "",wamas::platform::utils::DebugWriter::Debug)\ } # define DEBUGNL(msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(""))\ WRITE_MSG_TO_DEBUGWRITER(msg<<'\n',"",wamas::platform::utils::DebugWriter::Debug)\ } # define LDEBUG(facility,msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(#facility))\ WRITE_MSG_TO_DEBUGWRITER(msg,#facility,wamas::platform::utils::DebugWriter::Debug)\ } # define LDEBUGNL(facility,msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(#facility))\ WRITE_MSG_TO_DEBUGWRITER(msg<<'\n',#facility,wamas::platform::utils::DebugWriter::Debug)\ } // Notify level # define NOTIFY(msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(""))\ WRITE_MSG_TO_DEBUGWRITER(msg, "",wamas::platform::utils::DebugWriter::Notify)\ } # define NOTIFYNL(msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(""))\ WRITE_MSG_TO_DEBUGWRITER(msg<<'\n',"",wamas::platform::utils::DebugWriter::Notify)\ } # define LNOTIFY(facility,msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(#facility))\ WRITE_MSG_TO_DEBUGWRITER(msg,#facility,wamas::platform::utils::DebugWriter::Notify)\ } # define LNOTIFYNL(facility,msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(#facility))\ WRITE_MSG_TO_DEBUGWRITER(msg<<'\n',#facility,wamas::platform::utils::DebugWriter::Notify)\ } // Alert level # define ALERT(msg)\ {\ if (wamas::platform::utils::EmergWriterMgr::instance().getDebugWriter().check(""))\ WRITE_MSG_TO_DEBUGWRITER(msg, "",wamas::platform::utils::DebugWriter::Alert)\ } # define ALERTNL(msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(""))\ WRITE_MSG_TO_DEBUGWRITER(msg<<'\n',"",wamas::platform::utils::DebugWriter::Alert)\ } # define LALERT(facility,msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(#facility))\ WRITE_MSG_TO_DEBUGWRITER(msg,#facility,wamas::platform::utils::DebugWriter::Alert)\ } # define LALERTNL(facility,msg)\ {\ if (wamas::platform::utils::DebugWriterMgr::instance().getDebugWriter().check(#facility))\ WRITE_MSG_TO_DEBUGWRITER(msg<<'\n',#facility,wamas::platform::utils::DebugWriter::Alert)\ } #else # define TRACE(msg) # define TRACENL(msg) # define LTRACE(facility,msg) # define LTRACENL(facility,msg) # define DEBUG(msg) # define DEBUGNL(msg) # define LDEBUG(facility,msg) # define LDEBUGNL(facility,msg) # define NOTIFY(msg) # define NOTIFYNL(msg) # define LNOTIFY(facility,msg) # define LNOTIFYNL(facility,msg) # define ALERT(msg) # define ALERTNL(msg) # define LALERT(facility,msg) # define LALERTNL(facility,msg) #endif } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: doxycode.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // namespace wamas { namespace platform { namespace utils { /** \defgroup utils_code Little cuties \ingroup utils */ } // /namespace } // /namespace } // /namespace --- NEW FILE: align.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #ifndef wx_utils_code_align_h #define wx_utils_code_align_h namespace wamas { namespace platform { namespace utils { // FIXME: is this ALIGNMENT calculation correct? >>> struct _al { void* p ; char c ; } ; static const size_t ALIGNMENT = sizeof(_al) - sizeof(void*); } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: DebugWriter.h --- // // $Id$ // #ifndef wx_utils_DebugWriter_h #define wx_utils_DebugWriter_h #include <string> namespace wamas { namespace platform { namespace utils { class DebugWriter { public: // Debug levels enum { Emerg, Alert, Error, Notify, Debug, Trace }; virtual int write(const char* file, int line, const std::string& facility, const int level, const std::string& msg)=0; virtual bool check(const std::string& facility)=0; virtual ~DebugWriter() {}; }; } // /namespace } // /namespace } // /namespace #endif // end of wx_utils_DebugWriter_h --- NEW FILE: atomic_count.h --- #ifndef wx__utils__atomic_count #define wx__utils__atomic_count #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef HAVE_BOOST #ifndef BOOST_DISABLE_THREADS #include <boost/detail/atomic_count.hpp> #ifdef BOOST_HAS_THREADS #define WX_ATOMIC_COUNT_WITH_BOOST 1 #endif // BOOST_HAS_THREADS #endif // ! BOOST_DISABLE_THREADS #endif // HAVE_BOOST #ifdef WX_ATOMIC_COUNT_WITH_BOOST namespace wamas { namespace platform { namespace utils { typedef boost::detail::atomic_count atomic_count; } // /namespace } // /namespace } // /namespace #else // ! WX_ATOMIC_COUNT_WITH_BOOST #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #include <windows.h> namespace wamas {namespace platform {namespace utils { // stolen from boost/detail/atomic_count_win32.hpp class atomic_count { public: explicit atomic_count( long v ) : value_( v ) {} long operator++() { return ::InterlockedIncrement( &value_ ); } long operator--() { return ::InterlockedDecrement( &value_ ); } operator long() const { return static_cast<long const volatile &>( value_ ); } private: atomic_count( atomic_count const & ); atomic_count & operator=( atomic_count const & ); long value_; }; }}} #else // !WIN32 namespace wamas {namespace platform {namespace utils { typedef long atomic_count; }}} #endif // WIN32 #endif // WX_ATOMIC_COUNT_WITH_BOOST #endif // wx__utils__atomic_count --- NEW FILE: HashSet.h --- // // $Id$ // #ifndef wx_utils_code_hashset_h #define wx_utils_code_hashset_h #ifdef HAVE_CONFIG_H # include <config.h> #endif #ifdef HAVE_HASH_MAP # include <ext/hash_set> #else # include <set> #endif namespace wamas { namespace platform { namespace utils { /** @brief Hash-set; a normal set for older C++ compilers. */ template< typename VALUE, typename HASHFUNC > class HashSet #ifdef HAVE_HASH_MAP : public HASH_MAP_NAMESPACE::hash_set<VALUE, HASHFUNC> { public: explicit HashSet(std::size_t n) : HASH_MAP_NAMESPACE::hash_set<VALUE, HASHFUNC>(n) {} HashSet() {} }; #else : public std::set<VALUE> { public: explicit HashSet(std::size_t) {} HashSet() {} }; #endif } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: smartptr.cc --- #include "smartptr.h" namespace wamas { namespace platform { namespace utils { LTA_MEMDEF(RefCounted, 20061107, "$Id$"); void RefCounted::ref() { ++refcount_; } void RefCounted::unref() { if (!--refcount_) delete this; } #ifdef WX_REFCOUNTED_COLLECT_NEW RefCounted::NewStatistics RefCounted::new_statistics_; void* RefCounted::operator new (std::size_t s) { NewStatistics::iterator pos = new_statistics_.find(s); if(pos==new_statistics_.end()) new_statistics_[s] = 1; else ++(pos->second); return malloc(s); } void RefCounted::operator delete (void* p) { free(p); } #endif // WX_REFCOUNTED_COLLECT_NEW } // /namespace } // /namespace } // /namespace --- NEW FILE: CerrDebugWriter.h --- // // $Id$ // #ifndef wx_utils_CerrDebugWriter_h #define wx_utils_CerrDebugWriter_h #include "DebugWriter.h" namespace wamas { namespace platform { namespace utils { class CerrDebugWriter : public DebugWriter { public: int write(const char* file, int line, const std::string& facility, const int level, const std::string& msg); bool check(const std::string& facility); static CerrDebugWriter& instance(); // ensures singleton private: static CerrDebugWriter* inst_; // the instance of CerrDebugWriter private: CerrDebugWriter() {}; }; } // /namespace } // /namespace } // /namespace #endif // end of wx_utils_CerrDebugWriter_h --- NEW FILE: linkassert.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #ifndef wx_utils_code_linkassert_h #define wx_utils_code_linkassert_h namespace wamas { namespace platform { namespace utils { /** \page page_utils_code_linkassert Link Time Assertions \see LTA_MEMDECL \see LTA_MEMDEF \see LTA_STATDEF \section utils_code_linkassert What is that? Best to explain the problem in C first because it is more explicit there. Suppose you have a header file containing the following declaration, plus a "member" function: \code struct foo { long l1; long l2; }; extern void foo_print_l2(const struct foo*); \endcode In the implementation (the .c file), suppose you define <tt>foo_print_l2()</tt> as follows: \code void foo_print_l2(const struct foo* f) { printf ("%ld\n", f->l2) ; } \endcode Now, you change the declaration of <tt>struct foo</tt> to read \code struct foo { long l1; long l1_5; long l2; }; \endcode (note the move of \c l2 by 1 long in the memory layout) and you do \em not recompile your .c file to tell the function <tt>foo_print_l2()</tt> to use the new offset of \c l2 from the base pointer, the function will print <tt>foo->l1_5</tt> instead of <tt>foo->l2</tt>, if it is linked with a fresh executable. (This whole thing applies to classes as well (which are structs basically)). A general precaution to this is to reference a variable from the .h file that is defined in the .c file. In C, before the change, this would read in the header file \code struct foo { long l1; long l2; }; extern int foo_version1; // you have to explicitly reference the foo_version1 so that the // compiler does not ignore the declaration and thus does not // reference it static int foo_version = foo_version1; \endcode and in the .c file \code int foo_version1; \endcode If you change the memory layout of the struct, you somehow have to force a recompile of the .c file. Do this through a change of the name of the extern variable. In the .h file write \code struct foo { long l1; long l1_5; long l2; }; extern int foo_version2; static int foo_version = foo_version2; \endcode In the .c file write \code int foo_version2; \endcode Thus, if you make the .h file publicly available, and an executable compiled with this new <tt>struct foo</tt> memory layout references the <tt>foo_print_l2()</tt> function, it must also reference the <tt>foo_version2</tt> extern variable. If the executable is linked with the old .o file, the linker won't be able to resolve the reference because the old .o file still contains the old variable <tt>foo_version1</tt>. We call this (most sophisticatedly) a <em>link time assertion</em>. In C++, this could be written as follows using static members. No matter how you view it, in C or C++, the principle is the same. The .h file: \code class Foo { public: // something ... public: static const char* version1; } ; static const char* Foo_version = Foo::version1; \endcode The .cc file: \code // we use a char* for the variable (formatted like this) because // this enables us to grep a binary for a particular class // version/revision const char* Foo::version1 = "Foo"; \endcode \section utils_code_linkassert_when When to increment the version number To summarize, the rules of thumb as to when to change the <em>link time assertion symbol</em> (e.g. increment <tt>version1</tt> to <tt>version2</tt> in the example) are: <ul> <li>You added and/or removed a member variable</li> <li>You added and/or removed a virtual method (this changes the layout of the vtable (or so))</li> <li>You added and/or removed a base class (a base class can be thought of as an implicit member)</li> <li>You added and/or removed the <tt>virtual</tt> keyword to/from a base class</li> <li>You need not increment the version if you added/removed a non-virtual method.</li> </ul> */ /** \def LTA_MEMDECL(num) \ingroup utils_code \brief Declare class member with version number \a num. You write this macro in the class definition, about where you would declare the member (in fact, the macro declares the member for you). See \ref page_utils_code_linkassert for a description. */ #define LTA_MEMDECL(num) static const char* version##num /** \def LTA_MEMDEF(class, num, rhs) \ingroup utils_code \brief Implement member of \a class with version number \a and the value \a rhs. \a rhs is a string. You write this macro in the .cc file, just where you would implement the static member you declared with LTA_MEMDECL. See \ref page_utils_code_linkassert for a description. */ #define LTA_MEMDEF(class, num, rhs) const char* class::version##num = rhs /** \def LTA_STATDEF(class, num) \ingroup utils_code \brief Reference the static member. Referencing the static member is necessary. It persuades the compiler to generate a reference to the member, and to not optimize it away. See \ref page_utils_code_linkassert for a description. */ #ifdef __PXWC__ #define LTA_STATDEF(class, num) #else #define LTA_STATDEF(class, num) static const char* class##_##version##num = class::version##num #endif } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: DebugWriterMgr.h --- // // $Id$ // #ifndef wx_utils_DebugWriterMgr_h #define wx_utils_DebugWriterMgr_h #include "CerrDebugWriter.h" namespace wamas { namespace platform { namespace utils { class DebugWriterMgr { public: DebugWriter& getDebugWriter(); void setDebugWriter(DebugWriter* debWriter); void activate(); void deactivate(); static DebugWriterMgr& instance(); private: static DebugWriterMgr* inst_; DebugWriter* defaultWriter_; DebugWriter* explicitWriter_; DebugWriter* debugWriter_; private: DebugWriterMgr(); }; } // /namespace } // /namespace } // /namespace #endif // end of wx_utils_DebugWriterMgr_h --- NEW FILE: debug.cc --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #include "debug.h" #include <set> #include <iostream> namespace wamas { namespace platform { namespace utils { using namespace std; class DebugImpl : public set<string> {}; Debug instance_; static const char* env_levels = "WX_DEBUG_LEVELS"; enum ParseState { PS_SPACE, PS_CHAR }; static inline bool is_levelchar( char c) { switch (c) { case '_': case ':': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return true; } return false; } Debug::Debug( bool read_env) { impl_ = new DebugImpl; if (read_env) { const char* envlevels = getenv(env_levels); if (envlevels) parse_levels(envlevels); } } Debug::Debug( const string& levels, bool read_env) { impl_ = new DebugImpl; parse_levels(levels); if (read_env) { const char* envlevels = getenv(env_levels); if (envlevels) parse_levels(envlevels); } } Debug::~Debug() { delete impl_; } void Debug::add_level( const string& l) { impl_->insert(l); } void Debug::parse_levels( const string& levelstr) { ParseState state = PS_SPACE; string::size_type beg; for (string::size_type i=0; i<levelstr.size(); i++) { char c = levelstr[i]; switch (state) { case PS_SPACE: { if (is_levelchar(c)) { beg = i; state = PS_CHAR; } break; } case PS_CHAR: { if (!is_levelchar(c)) { impl_->insert(levelstr.substr(beg, i-beg)); state = PS_SPACE; } break; } } } if (state == PS_CHAR) impl_->insert(levelstr.substr(beg, levelstr.size()-beg)); } bool Debug::have_level( const string& level) { DebugImpl::const_iterator pos = impl_->find(level); return pos != impl_->end(); } int Debug::n_levels() { return impl_->size(); } Debug& Debug::instance() { return instance_; } } // /namespace } // /namespace } // /namespace --- NEW FILE: Confix2.dir --- --- NEW FILE: StringMap.cc --- // // $Id$ // #include "StringMap.h" namespace wamas { namespace platform { namespace utils { std::size_t StringHash::operator()(std::string const& s) const { #ifdef HAVE_HASH_MAP HASH_MAP_NAMESPACE::hash<const char*> H; return H(s.c_str()); #else unsigned long h=0; for(std::string::const_iterator it=s.begin(); it!=s.end(); ++it) { h = 5*h + *it; } return std::size_t(h); #endif } } // /namespace } // /namespace } // /namespace --- NEW FILE: indent.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #ifndef wx_utils_code_indent_h #define wx_utils_code_indent_h #include <iostream> namespace wamas { namespace platform { namespace utils { std::ostream& indent(std::ostream&, int indent); } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: HashMap.h --- // // $Id$ // #ifndef wx_utils_code_hashmap_h #define wx_utils_code_hashmap_h #ifdef HAVE_CONFIG_H # include <config.h> #endif #ifdef HAVE_HASH_MAP # include <ext/hash_map> #else # include <map> #endif namespace wamas { namespace platform { namespace utils { /** @brief Hash-map; a normal map for older C++ compilers. */ template< typename KEY, typename VALUE, typename HASHFUNC > class HashMap #ifdef HAVE_HASH_MAP : public HASH_MAP_NAMESPACE::hash_map<KEY, VALUE, HASHFUNC> { public: explicit HashMap(std::size_t n) : HASH_MAP_NAMESPACE::hash_map<KEY, VALUE, HASHFUNC>(n) {} HashMap() {} }; #else : public std::map<KEY, VALUE> { public: explicit HashMap(std::size_t) {} HashMap() {} }; #endif /** @brief Hash-multi-map; a normal multi-map for older C++ compilers. */ template< typename KEY, typename VALUE, typename HASHFUNC > class HashMultiMap #ifdef HAVE_HASH_MAP : public HASH_MAP_NAMESPACE::hash_multimap<KEY, VALUE, HASHFUNC> { public: explicit HashMultiMap(std::size_t n) : HASH_MAP_NAMESPACE::hash_multimap<KEY, VALUE, HASHFUNC>(n) {} HashMultiMap() {} }; #else : public std::multimap<KEY, VALUE> { public: explicit HashMultiMap(std::size_t) {} HashMultiMap() {} }; #endif } // /namespace } // /namespace } // /namespace #endif --- NEW FILE: indent.cc --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #include "indent.h" namespace wamas { namespace platform { namespace utils { std::ostream& indent(std::ostream& o, int indent) { while (indent--) o << ' '; return o; } } // /namespace } // /namespace } // /namespace --- NEW FILE: extern_c.h --- // -*- mode: C++; c-basic-offset: 3 -*- // // $Id$ // #ifndef wx_utils_code_extern_c_h #define wx_utils_code_extern_c_h #ifdef __cplusplus // we use confix's fancy namespace-to-includedir mapping. as there is // nothing in this file but macros, namespaces don't apply at all, so // there's no other reason to include namespaces here. namespace wamas { namespace platform { namespace utils { #endif #ifdef __cplusplus # define BEGIN_CPLUSPLUS extern "C" { # define END_CPLUSPLUS } #else # define BEGIN_CPLUSPLUS # define END_CPLUSPLUS #endif #ifdef __cplusplus } // /namespace } // /namespace }; // /namespace #endif #endif |
From: Teiniker E. <tei...@us...> - 2007-01-22 10:09:02
|
Update of /cvsroot/ccmtools/cpp-environment/utils/values In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14231/utils/values Added Files: .cvsignore Log Message: Added utils/code and utils/error to the runtime lib --- NEW FILE: .cvsignore --- Makefile.am Makefile.in |
From: Teiniker E. <tei...@us...> - 2007-01-22 10:09:02
|
Update of /cvsroot/ccmtools/cpp-environment/utils/smartptr In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14231/utils/smartptr Removed Files: linkassert.h smartptr.h Confix2.dir smartptr.cc Log Message: Added utils/code and utils/error to the runtime lib --- linkassert.h DELETED --- --- smartptr.h DELETED --- --- Confix2.dir DELETED --- --- smartptr.cc DELETED --- |
From: Teiniker E. <tei...@us...> - 2007-01-22 10:09:01
|
Update of /cvsroot/ccmtools/cpp-environment/utils In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14231/utils Added Files: .cvsignore Log Message: Added utils/code and utils/error to the runtime lib --- NEW FILE: .cvsignore --- autom4te.cache confix-admin acinclude.m4 aclocal.m4 ccm-runtime-utils.repo config.h.in configure configure.ac Makefile.am Makefile.in |
From: Teiniker E. <tei...@us...> - 2007-01-22 10:09:01
|
Update of /cvsroot/ccmtools/cpp-environment/ccm/remote/RemoteComponents In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14231/ccm/remote/RemoteComponents Removed Files: ccmtools.h ccmtools.cc Log Message: Added utils/code and utils/error to the runtime lib --- ccmtools.h DELETED --- --- ccmtools.cc DELETED --- |
From: Teiniker E. <tei...@us...> - 2007-01-22 10:08:55
|
Update of /cvsroot/ccmtools/cpp-environment/utils/code In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14215/utils/code Log Message: Directory /cvsroot/ccmtools/cpp-environment/utils/code added to the repository |
From: Teiniker E. <tei...@us...> - 2007-01-22 10:08:55
|
Update of /cvsroot/ccmtools/cpp-environment/utils/error In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14215/utils/error Log Message: Directory /cvsroot/ccmtools/cpp-environment/utils/error added to the repository |