From cbfa38d2b50ce144ad5fc4e1aa2926f8f979ffaf Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 15 Jun 2009 22:25:52 +0000 Subject: [PATCH] simplify ConfigureDecl etc. --- direct/src/dcparse/Sources.pp | 2 + direct/src/directbase/directsymbols.h | 2 +- direct/src/plugin/Sources.pp | 6 +- direct/src/showbase/showBase.N | 1 - direct/src/showbase/showBase.cxx | 3 +- direct/src/showbase/showBase.h | 3 +- dtool/src/dconfig/Sources.pp | 18 +- dtool/src/dconfig/configTable.I | 13 - dtool/src/dconfig/configTable.cxx | 15 -- dtool/src/dconfig/configTable.h | 34 --- dtool/src/dconfig/config_setup.h | 23 -- dtool/src/dconfig/dconfig.I | 30 ++- dtool/src/dconfig/dconfig.cxx | 5 - dtool/src/dconfig/dconfig.h | 297 +++-------------------- dtool/src/dconfig/dconfig_composite1.cxx | 2 - dtool/src/dconfig/serialization.I | 21 -- dtool/src/dconfig/serialization.h | 184 -------------- dtool/src/dconfig/symbolEnt.I | 53 ---- dtool/src/dconfig/symbolEnt.cxx | 26 -- dtool/src/dconfig/symbolEnt.h | 77 ------ panda/src/display/displayRegion.cxx | 2 + panda/src/downloadertools/multify.cxx | 1 + panda/src/express/config_express.N | 4 +- panda/src/express/config_express.cxx | 3 +- panda/src/express/config_express.h | 3 +- panda/src/mathutil/randomizer.h | 2 + panda/src/putil/bamCache.h | 2 + 27 files changed, 80 insertions(+), 752 deletions(-) delete mode 100644 dtool/src/dconfig/configTable.I delete mode 100644 dtool/src/dconfig/configTable.cxx delete mode 100644 dtool/src/dconfig/configTable.h delete mode 100644 dtool/src/dconfig/config_setup.h delete mode 100644 dtool/src/dconfig/serialization.I delete mode 100644 dtool/src/dconfig/serialization.h delete mode 100644 dtool/src/dconfig/symbolEnt.I delete mode 100644 dtool/src/dconfig/symbolEnt.cxx delete mode 100644 dtool/src/dconfig/symbolEnt.h diff --git a/direct/src/dcparse/Sources.pp b/direct/src/dcparse/Sources.pp index b8faae05de..3ada1dd1fb 100644 --- a/direct/src/dcparse/Sources.pp +++ b/direct/src/dcparse/Sources.pp @@ -7,6 +7,7 @@ prc:c pstatclient:c pandabase:c linmath:c putil:c \ pipeline:c \ $[if $[HAVE_NET],net:c] $[if $[WANT_NATIVE_NET],nativenet:c] \ + panda:m \ pystub #define C++FLAGS -DWITHIN_PANDA @@ -17,5 +18,6 @@ #define SOURCES \ dcparse.cxx + #define WIN_SYS_LIBS shell32.lib #end bin_target diff --git a/direct/src/directbase/directsymbols.h b/direct/src/directbase/directsymbols.h index 4932a72056..6692aca23d 100644 --- a/direct/src/directbase/directsymbols.h +++ b/direct/src/directbase/directsymbols.h @@ -17,7 +17,7 @@ /* See dtoolsymbols.h for a rant on the purpose of this file. */ -#if defined(WIN32_VC) && !defined(CPPPARSER) +#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) #ifdef BUILDING_DIRECT #define EXPCL_DIRECT __declspec(dllexport) diff --git a/direct/src/plugin/Sources.pp b/direct/src/plugin/Sources.pp index e29ba804fe..92e66cd358 100644 --- a/direct/src/plugin/Sources.pp +++ b/direct/src/plugin/Sources.pp @@ -1,9 +1,9 @@ // This directory is still experimental. Define HAVE_P3D_PLUGIN in // your Config.pp to build it. -#define BUILD_DIRECTORY $[and $[HAVE_P3D_PLUGIN],$[HAVE_TINYXML],$[HAVE_OPENSSL],$[HAVE_ZLIB],$[HAVE_TAR]] +#define BUILD_DIRECTORY $[and $[HAVE_P3D_PLUGIN],$[HAVE_TINYXML],$[HAVE_OPENSSL],$[HAVE_ZLIB]] #begin lib_target - #define USE_PACKAGES tinyxml openssl zlib tar + #define USE_PACKAGES tinyxml openssl zlib #define TARGET p3d_plugin #define COMBINED_SOURCES \ @@ -58,7 +58,7 @@ #end bin_target #begin bin_target - #define USE_PACKAGES openssl zlib tar + #define USE_PACKAGES openssl zlib #define TARGET panda3d #define OTHER_LIBS \ diff --git a/direct/src/showbase/showBase.N b/direct/src/showbase/showBase.N index 95ac4ae986..e69de29bb2 100644 --- a/direct/src/showbase/showBase.N +++ b/direct/src/showbase/showBase.N @@ -1 +0,0 @@ -forcetype ConfigShowbase diff --git a/direct/src/showbase/showBase.cxx b/direct/src/showbase/showBase.cxx index 35a48033dd..4dc737edf2 100644 --- a/direct/src/showbase/showBase.cxx +++ b/direct/src/showbase/showBase.cxx @@ -49,8 +49,9 @@ throw_new_frame() { // Returns the configure object for accessing config variables from a // scripting language. -ConfigShowbase & +DConfig & get_config_showbase() { + static DConfig config_showbase; return config_showbase; } diff --git a/direct/src/showbase/showBase.h b/direct/src/showbase/showBase.h index 77205a09b5..132d853942 100644 --- a/direct/src/showbase/showBase.h +++ b/direct/src/showbase/showBase.h @@ -28,7 +28,6 @@ #include "nodePath.h" ConfigureDecl(config_showbase, EXPCL_DIRECT, EXPTP_DIRECT); -typedef Config::Config ConfigShowbase; class CollisionTraverser; class Camera; @@ -40,7 +39,7 @@ EXPCL_DIRECT ConfigVariableSearchPath &get_particle_path(); EXPCL_DIRECT void throw_new_frame(); -EXPCL_DIRECT ConfigShowbase &get_config_showbase(); +EXPCL_DIRECT DConfig &get_config_showbase(); // klunky interface since we cant pass array from python->C++ diff --git a/dtool/src/dconfig/Sources.pp b/dtool/src/dconfig/Sources.pp index 871fcdc2ab..5c87f6adcf 100644 --- a/dtool/src/dconfig/Sources.pp +++ b/dtool/src/dconfig/Sources.pp @@ -6,21 +6,15 @@ #define COMBINED_SOURCES $[TARGET]_composite1.cxx #define SOURCES \ - configTable.I configTable.h \ - config_dconfig.h config_setup.h \ - dconfig.I dconfig.h \ - serialization.I serialization.h \ - symbolEnt.I symbolEnt.h + config_dconfig.h \ + dconfig.I dconfig.h #define INCLUDED_SOURCES \ - configTable.cxx config_dconfig.cxx dconfig.cxx \ - symbolEnt.cxx + config_dconfig.cxx dconfig.cxx - #define INSTALL_HEADERS \ - configTable.I configTable.h config_dconfig.h config_setup.h \ - dconfig.I dconfig.h \ - serialization.I serialization.h \ - symbolEnt.I symbolEnt.h + #define INSTALL_HEADERS \ + config_dconfig.h \ + dconfig.I dconfig.h #end lib_target diff --git a/dtool/src/dconfig/configTable.I b/dtool/src/dconfig/configTable.I deleted file mode 100644 index bec7f7e59e..0000000000 --- a/dtool/src/dconfig/configTable.I +++ /dev/null @@ -1,13 +0,0 @@ -// Filename: configTable.I -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// diff --git a/dtool/src/dconfig/configTable.cxx b/dtool/src/dconfig/configTable.cxx deleted file mode 100644 index c62decec65..0000000000 --- a/dtool/src/dconfig/configTable.cxx +++ /dev/null @@ -1,15 +0,0 @@ -// Filename: configTable.cxx -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#include "configTable.h" diff --git a/dtool/src/dconfig/configTable.h b/dtool/src/dconfig/configTable.h deleted file mode 100644 index 900cf7a54e..0000000000 --- a/dtool/src/dconfig/configTable.h +++ /dev/null @@ -1,34 +0,0 @@ -// Filename: configTable.h -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#ifndef CONFIGTABLE_H -#define CONFIGTABLE_H - -#include "dtoolbase.h" - -#include "symbolEnt.h" - -namespace Config { - -class EXPCL_DTOOLCONFIG ConfigTable { -public: - typedef SymbolEnt SymEnt; - typedef vector_SymbolEnt Symbol; -}; - -#include "configTable.I" - -} // close Config namespace - -#endif diff --git a/dtool/src/dconfig/config_setup.h b/dtool/src/dconfig/config_setup.h deleted file mode 100644 index e1b8e5a98c..0000000000 --- a/dtool/src/dconfig/config_setup.h +++ /dev/null @@ -1,23 +0,0 @@ -// Filename: config_setup.h -// Created by: cary (20Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#ifndef __CONFIG_SETUP_H__ -#define __CONFIG_SETUP_H__ - -#include - -// use 8-bit chars for now. Change this line to make config switch to wchar -typedef std::string ConfigString; - -#endif /* __CONFIG_SETUP_H__ */ diff --git a/dtool/src/dconfig/dconfig.I b/dtool/src/dconfig/dconfig.I index 6e7ce844f8..c7575db59e 100644 --- a/dtool/src/dconfig/dconfig.I +++ b/dtool/src/dconfig/dconfig.I @@ -13,14 +13,32 @@ //////////////////////////////////////////////////////////////////// -INLINE double get_total_time_config_init() { - return (double)total_time_config_init / (double)CLOCKS_PER_SEC; +bool DConfig:: +GetBool(const string &sym, bool def) { + ConfigVariableBool var(sym, def, "DConfig", ConfigFlags::F_dconfig); + return var.get_value(); } -INLINE double get_total_time_external_init() { - return (double)total_time_external_init / (double)CLOCKS_PER_SEC; +int DConfig:: +GetInt(const string &sym, int def) { + ConfigVariableInt var(sym, def, "DConfig", ConfigFlags::F_dconfig); + return var.get_value(); } -INLINE double get_total_num_get() { - return total_num_get; +float DConfig:: +GetFloat(const string &sym, float def) { + ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig); + return var.get_value(); +} + +double DConfig:: +GetDouble(const string &sym, double def) { + ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig); + return var.get_value(); +} + +string DConfig:: +GetString(const string &sym, const string &def) { + ConfigVariableString var(sym, def, "DConfig", ConfigFlags::F_dconfig); + return var.get_value(); } diff --git a/dtool/src/dconfig/dconfig.cxx b/dtool/src/dconfig/dconfig.cxx index 7e514b498a..951e42cffd 100644 --- a/dtool/src/dconfig/dconfig.cxx +++ b/dtool/src/dconfig/dconfig.cxx @@ -13,8 +13,3 @@ //////////////////////////////////////////////////////////////////// #include "dconfig.h" - -clock_t Config::total_time_config_init = 0; -clock_t Config::total_time_external_init = 0; -int Config::total_num_get = 0; - diff --git a/dtool/src/dconfig/dconfig.h b/dtool/src/dconfig/dconfig.h index eb4d168983..819d9897ba 100644 --- a/dtool/src/dconfig/dconfig.h +++ b/dtool/src/dconfig/dconfig.h @@ -17,10 +17,7 @@ #include "dtoolbase.h" -#include "config_setup.h" #include "config_dconfig.h" -#include "configTable.h" -#include "executionEnvironment.h" #include "configVariableString.h" #include "configVariableBool.h" #include "configVariableInt.h" @@ -28,290 +25,56 @@ #include "configVariableList.h" #include "configFlags.h" -#include -#include -#include - -namespace Config { - -// Config is, itself, configurable. The things that can be set are: -// path separator ( ': ' ) [pathsep] -// filename separator ( / ) [filesep] -// config filename ( Configrc ) [configname] -// config file suffix ( ) [configsuffix] -// config file path ( $CONFIG_PATH ) [configpath] -// (can be multiple of these) -// config file comment ( '#' ) [configcmt] -// 'args' suffix ( _ARGS ) [argsuffix] -// command arg env ( CONFIG + _____ ) [commandstub] -// debugging output ( false ) [configdbg] -// read commandline ( true ) [readargs] -// read environment ( true ) [readenv] -// all of these can be set from the one unconfigurable thing in config, the -// environment variable called CONFIG_CONFIG. The format is: -// separator_char{{field_id}={field_value}separator_char}* - -// Call these functions to get stats on how Config is spending its -// time. -EXPCL_DTOOLCONFIG INLINE double get_total_time_config_init(); -EXPCL_DTOOLCONFIG INLINE double get_total_time_external_init(); -EXPCL_DTOOLCONFIG INLINE double get_total_num_get(); - -// These globals are intended for internal bookkeeping by Config to -// compute the above functions' return values. -EXPCL_DTOOLCONFIG extern clock_t total_time_config_init; -EXPCL_DTOOLCONFIG extern clock_t total_time_external_init; -EXPCL_DTOOLCONFIG extern int total_num_get; - -template -class Config { -public: - Config(); - ~Config(); - static bool AmInitializing(); - static ConfigString Name(); - static bool Flag(); - static void Init(); - static bool Defined(const ConfigString& sym); - static ConfigString Get(const ConfigString sym); - static ConfigTable::Symbol& GetAll(const ConfigString, - ConfigTable::Symbol&); +//////////////////////////////////////////////////////////////////// +// Class : DConfig +// Description : This class emulates the old dconfig-style interface +// to our Panda config system. It exists only to +// provide backward-compatible support, and it is used +// primarily by Python code. For modern code, use the +// new ConfigVariable* interface instead of this +// deprecated interface. +//////////////////////////////////////////////////////////////////// +class EXPCL_DTOOLCONFIG DConfig { PUBLISHED: - static bool GetBool(const ConfigString sym, bool def = false); - static int GetInt(const ConfigString sym, int def = 0); - static float GetFloat(const ConfigString sym, float def = 0.); - static double GetDouble(const ConfigString sym, double def = 0.); - static ConfigString GetString(const ConfigString sym, - const ConfigString def = ""); -protected: - static void ConfigFunc(); - static void Flag(bool); + static INLINE bool GetBool(const string &sym, bool def = false); + static INLINE int GetInt(const string &sym, int def = 0); + static INLINE float GetFloat(const string &sym, float def = 0.); + static INLINE double GetDouble(const string &sym, double def = 0.); + static INLINE string GetString(const string &sym, const string &def = ""); }; -// Implementation follows - -template -void Config::ConfigFunc() { - GetConfig::config_func(); -} - -template -bool Config::AmInitializing() { - return false; -} - -template -ConfigString Config::Name() { - return GetConfig::get_name(); -} - -template -bool Config::Flag() { - return GetConfig::_flag; -} - -template -void Config::Flag(bool f) { - GetConfig::_flag = f; -} - -template -void Config::Init() { - if (Flag()) - return; - - Flag(true); - - ConfigFunc(); -} - -template -Config::Config() { - Init(); -} - -template -Config::~Config() { -} - -template -bool Config::Defined(const ConfigString& sym) -{ - Init(); - return true; -} - -template -ConfigString Config::Get(ConfigString sym) -{ - Init(); - ConfigVariableString var(sym); - return var.get_value(); -} - -template -ConfigTable::Symbol& Config::GetAll(const ConfigString sym, - ConfigTable::Symbol& s) -{ - Init(); - ConfigVariableList var(sym, "DConfig", ConfigFlags::F_dconfig); - - int num_values = var.get_num_values(); - for (int i = 0; i < num_values; ++i) { - string value = var.get_string_value(i); - s.push_back(SymbolEnt(SymbolEnt::ConfigFile, value)); - } - - return s; -} - -template -bool Config::GetBool(const ConfigString sym, bool def) -{ - Init(); - ConfigVariableBool var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); -} - -template -int Config::GetInt(const ConfigString sym, int def) -{ - Init(); - ConfigVariableInt var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); -} - -template -float Config::GetFloat(const ConfigString sym, float def) -{ - Init(); - ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); -} - -template -double Config::GetDouble(const ConfigString sym, double def) -{ - Init(); - ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); -} - -template -ConfigString Config::GetString(const ConfigString sym, - const ConfigString def) -{ - Init(); - ConfigVariableString var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); -} - #include "dconfig.I" -} // close Config namespace +// These macros are used in each directory to call an initialization +// function at static-init time. These macros may eventually be +// phased out in favor of a simpler interface that does not require +// static init. -// Finally, here is a set of handy macros to define and reference a -// Configure object in each package. +// This macro should appear in the config_*.h file. -// This macro defines an external reference to a suitable Configure -// object; it should appear in the config_*.h file. The config object -// will be named name. +#define ConfigureDecl(name, expcl, exptp) -#if defined(WIN32_VC) && !defined(CPPPARSER) +// This macro defines the actual declaration of the object defined +// above; it should appear in the config_*.cxx file. -#define ConfigureDecl(name, expcl, exptp) \ - class expcl ConfigureGetConfig_ ## name { \ - public: \ - static const char *get_name(); \ - static void config_func(); \ - static bool _flag; \ - }; \ - exptp template class expcl Config::Config; \ - extern expcl Config::Config name; - -#else // WIN32_VC - -#define ConfigureDecl(name, expcl, exptp) \ - class expcl ConfigureGetConfig_ ## name { \ - public: \ - static const char *get_name(); \ - static void config_func(); \ - static bool _flag; \ - }; \ - extern expcl Config::Config name; - -#endif // WIN32_VC - -// This macro defines the actual declaration of the Configure object -// defined above; it should appear in the config_*.C file. - -#if defined(PENV_OSX) #define ConfigureDef(name) \ - Config::Config name; \ - bool ConfigureGetConfig_ ## name::_flag = false; \ - int FILE_SYM_NAME = 0; \ - const char *ConfigureGetConfig_ ## name:: \ - get_name() { \ - return #name; \ - } -#else /* PENV_OSX */ -#define ConfigureDef(name) \ - Config::Config name; \ - bool ConfigureGetConfig_ ## name::_flag = false; \ - const char *ConfigureGetConfig_ ## name:: \ - get_name() { \ - return #name; \ - } -#endif /* PENV_OSX */ + class StaticInitializer_ ## name { \ + public: \ + StaticInitializer_ ## name(); \ + }; \ + static StaticInitializer_ ## name name; // This macro can be used in lieu of the above two when the Configure // object does not need to be visible outside of the current C file. -#if defined(PENV_OSX) -#define Configure(name) \ - class ConfigureGetConfig_ ## name { \ - public: \ - static const char *get_name(); \ - static void config_func(); \ - static bool _flag; \ - }; \ - static Config::Config name; \ - bool ConfigureGetConfig_ ## name::_flag = false; \ - int FILE_SYM_NAME = 0; \ - const char *ConfigureGetConfig_ ## name:: \ - get_name() { \ - return #name; \ - } -#else /* PENV_OSX */ -#define Configure(name) \ - class ConfigureGetConfig_ ## name { \ - public: \ - static const char *get_name(); \ - static void config_func(); \ - static bool _flag; \ - }; \ - static Config::Config name; \ - bool ConfigureGetConfig_ ## name::_flag = false; \ - const char *ConfigureGetConfig_ ## name:: \ - get_name() { \ - return #name; \ - } -#endif /* PENV_OSX */ +#define Configure(name) ConfigureDef(name) // This one defines a block of code that will be executed at static // init time. It must always be defined (in the C file), even if no // code is to be executed. #define ConfigureFn(name) \ - void ConfigureGetConfig_ ## name::config_func() - -#if defined(PENV_OSX) -// This is a hack to provide a unique locatable symbol in each lib. -#define ConfigureLibSym \ - char LIB_SYMBOL_NAME[] = ALL_FILE_SYMS_NAME ; -#else -#define ConfigureLibSym -#endif /* PENV_OSX */ + StaticInitializer_ ## name::StaticInitializer_ ## name() #endif /* __CONFIG_H__ */ diff --git a/dtool/src/dconfig/dconfig_composite1.cxx b/dtool/src/dconfig/dconfig_composite1.cxx index 3250cad91f..f35232700b 100644 --- a/dtool/src/dconfig/dconfig_composite1.cxx +++ b/dtool/src/dconfig/dconfig_composite1.cxx @@ -1,5 +1,3 @@ #include "config_dconfig.cxx" #include "dconfig.cxx" -#include "configTable.cxx" -#include "symbolEnt.cxx" diff --git a/dtool/src/dconfig/serialization.I b/dtool/src/dconfig/serialization.I deleted file mode 100644 index 07f4fae292..0000000000 --- a/dtool/src/dconfig/serialization.I +++ /dev/null @@ -1,21 +0,0 @@ -// Filename: serialization.I -// Created by: cary (20Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -INLINE int Length(char) { - return 1; -} - -INLINE int Length(char* x) { - return strlen(x); -} diff --git a/dtool/src/dconfig/serialization.h b/dtool/src/dconfig/serialization.h deleted file mode 100644 index f3c87abe57..0000000000 --- a/dtool/src/dconfig/serialization.h +++ /dev/null @@ -1,184 +0,0 @@ -// Filename: serialization.h -// Created by: cary (26Aug98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#ifndef __SERIALIZATION_H__ -#define __SERIALIZATION_H__ - -#include "dtoolbase.h" - -#include "config_setup.h" - -namespace Serialize { - -template -class StdIns { - public: - INLINE ConfigString operator()(const X& val) { - ostringstream oss; - oss << val; - return oss.str(); - } -}; - -template -class StdExt { - public: - INLINE X operator()(ConfigString S) { - istringstream iss(S); - X ret; - iss >> ret; - return ret; - } -}; - -template -INLINE int Length(X c) { - return c.length(); -} - -template > -class Serializer { - private: - ConfigString _result; - - ConfigString SerializeToString(const Collection&, const ConfigString&); - Serializer() {} - public: - Serializer(const Collection& C, ConfigString Delim = ":") : - _result(Serializer::SerializeToString(C, Delim)) {} - Serializer(const Serializer& c) : - _result(c._result) {} - ~Serializer() {} - INLINE ConfigString operator()() { return _result; } - INLINE ConfigString operator()(const Collection& C, - const ConfigString& Delim = ":") { - _result = SerializeToString(C, Delim); - return _result; - } - INLINE operator ConfigString() { return _result; } -}; - -template -ConfigString -Serializer::SerializeToString(const Collection& C, - const ConfigString& Delim) -{ - ConfigString ret; - Inserter in; - - for (TYPENAME Collection::const_iterator i=C.begin(); i!=C.end(); ++i) { - if (i != C.begin()) - ret += Delim; - ret += in(*i); - } - return ret; -} - -template > -class Deserializer { - private: - Collection _result; - - INLINE void Clear() { _result.erase(_result.begin(), _result.end()); } - template - int FindFirstOfInString(ConfigString S, ForwardIterator DelimBegin, - ForwardIterator DelimEnd) { - int i = ConfigString::npos; - ForwardIterator j = DelimBegin; - - while (j != DelimEnd) { - int k = S.find(*j); - if (k != ConfigString::npos) - if ((i == ConfigString::npos) || (i > k)) - i = k; - ++j; - } - return i; - } - template - int FindFirstNotOfInString(ConfigString S, ForwardIterator DelimBegin, - ForwardIterator DelimEnd) { - int i = ConfigString::npos; - ForwardIterator j = DelimBegin; - ForwardIterator k = DelimBegin; - - while (j != DelimEnd) { - int l = S.find(*j); - if (l != ConfigString::npos) - if ((i == ConfigString::npos) || (i > l)) { - i = l; - k = j; - } - ++j; - } - if (i != ConfigString::npos) { - i += Serialize::Length(*k); - if (i >= S.length()) - i = ConfigString::npos; - } - return i; - } - template - void DeserializeFromString(ConfigString S, ForwardIterator DelimBegin, - ForwardIterator DelimEnd) { - Clear(); - Extractor ex; - - while (!S.empty()) { - int i = FindFirstOfInString(S, DelimBegin, DelimEnd); - _result.push_back(ex(S.substr(0, i))); - S.erase(0, i); - i = FindFirstNotOfInString(S, DelimBegin, DelimEnd); - S.erase(0, i); - } - } - void DeserializeFromString(ConfigString S, ConfigString Delim) { - Clear(); - Extractor ex; - - while (!S.empty()) { - size_t i = S.find_first_of(Delim); - _result.push_back(ex(S.substr(0, i))); - if (i == ConfigString::npos) - S.erase(0, i); - else - S.erase(0, i+1); - } - } - Deserializer() {} - public: - Deserializer(ConfigString S, ConfigString Delim = ":") { - Deserializer::DeserializeFromString(S, Delim); - } - template - Deserializer(ConfigString S, ForwardIterator DelimBegin, - ForwardIterator DelimEnd) { - Deserializer::DeserializeFromString(S, DelimBegin, DelimEnd); - } - ~Deserializer() {} - INLINE const Collection& operator()() { return _result; } - template - INLINE const Collection& operator()(ConfigString S, - ForwardIterator DelimBegin, - ForwardIterator DelimEnd) { - Deserializer::DeserializeFromString(S, DelimBegin, DelimEnd); - } - INLINE operator const Collection&() { return _result; } -}; - -#include "serialization.I" - -} // close Serialize namespace - -#endif /* __SERIALIZATION_H__ */ diff --git a/dtool/src/dconfig/symbolEnt.I b/dtool/src/dconfig/symbolEnt.I deleted file mode 100644 index 5b19d5df31..0000000000 --- a/dtool/src/dconfig/symbolEnt.I +++ /dev/null @@ -1,53 +0,0 @@ -// Filename: symbolEnt.I -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - - -INLINE SymbolEnt& SymbolEnt::operator=(const SymbolEnt& c) { - _src = c._src; - _val = c._val; - _srctok = c._srctok; - _state = c._state; - return *this; -} - -INLINE bool SymbolEnt:: -operator == (const SymbolEnt &) const { - return true; -} - -INLINE bool SymbolEnt:: -operator != (const SymbolEnt &) const { - return false; -} - -INLINE bool SymbolEnt:: -operator < (const SymbolEnt &) const { - return false; -} - -INLINE ConfigString SymbolEnt::Src(void) const { - return _src; -} - -INLINE ConfigString SymbolEnt::Val(void) const { - return _val; -} - -INLINE SymbolEnt::SymbolEntSrc SymbolEnt::SrcTok(void) const { - return _srctok; -} - -INLINE bool SymbolEnt::State(void) const { - return _state; -} diff --git a/dtool/src/dconfig/symbolEnt.cxx b/dtool/src/dconfig/symbolEnt.cxx deleted file mode 100644 index b213014f63..0000000000 --- a/dtool/src/dconfig/symbolEnt.cxx +++ /dev/null @@ -1,26 +0,0 @@ -// Filename: symbolEnt.cxx -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#include "symbolEnt.h" - -#define EXPCL EXPCL_DTOOLCONFIG -#define EXPTP EXPTP_DTOOLCONFIG -#define TYPE Config::SymbolEnt -#define NAME vector_SymbolEnt -#include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/dtool/src/dconfig/symbolEnt.h b/dtool/src/dconfig/symbolEnt.h deleted file mode 100644 index 43e2861bf0..0000000000 --- a/dtool/src/dconfig/symbolEnt.h +++ /dev/null @@ -1,77 +0,0 @@ -// Filename: symbolEnt.h -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#ifndef SYMBOLENT_H -#define SYMBOLENT_H - -#include "dtoolbase.h" - -#include "config_setup.h" -#include "pvector.h" - -namespace Config { - -class EXPCL_DTOOLCONFIG SymbolEnt { - public: - enum SymbolEntSrc { ConfigFile, Environment, CommandEnv, Commandline, - Other, Invalid }; - private: - ConfigString _src; - ConfigString _val; - bool _state; - enum SymbolEntSrc _srctok; - public: - SymbolEnt() : _srctok(Invalid) {} - SymbolEnt(enum SymbolEntSrc tok, const ConfigString& val, - const ConfigString& src = "", bool state = false) - : _src(src), _val(val), _state(state), _srctok(tok) {} - SymbolEnt(const SymbolEnt& c) : _src(c._src), _val(c._val), - _state(c._state), _srctok(c._srctok) {} - INLINE SymbolEnt& operator=(const SymbolEnt&); - - // We need these so we can explicitly instantiate the vector, - // below. They're not actually used and do nothing useful. - INLINE bool operator == (const SymbolEnt &other) const; - INLINE bool operator != (const SymbolEnt &other) const; - INLINE bool operator < (const SymbolEnt &other) const; - - INLINE ConfigString Src(void) const; - INLINE ConfigString Val(void) const; - INLINE SymbolEntSrc SrcTok(void) const; - INLINE bool State(void) const; -}; - -} // close Config namespace - -#define EXPCL EXPCL_DTOOLCONFIG -#define EXPTP EXPTP_DTOOLCONFIG -#define TYPE Config::SymbolEnt -#define NAME vector_SymbolEnt -#include "vector_src.h" - -namespace Config { - -typedef ::vector_SymbolEnt vector_SymbolEnt; - -#include "symbolEnt.I" - -} // close Config namespace - - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index 4fc9508792..e37a813b2e 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -21,6 +21,8 @@ #include "dcast.h" #include "pnmImage.h" +#include + TypeHandle DisplayRegion::_type_handle; TypeHandle DisplayRegionPipelineReader::_type_handle; diff --git a/panda/src/downloadertools/multify.cxx b/panda/src/downloadertools/multify.cxx index f9880ffd3b..c8c935735f 100644 --- a/panda/src/downloadertools/multify.cxx +++ b/panda/src/downloadertools/multify.cxx @@ -23,6 +23,7 @@ #include "filename.h" #include "pset.h" #include +#include bool create = false; // -c diff --git a/panda/src/express/config_express.N b/panda/src/express/config_express.N index 9b381356eb..606bc34c77 100644 --- a/panda/src/express/config_express.N +++ b/panda/src/express/config_express.N @@ -19,9 +19,7 @@ forcetype FileStream forcetype IDecryptStream forcetype OEncryptStream -forcetype ConfigExpress -renametype ConfigExpress ConfigExpress - +forcetype DConfig forcetype ConfigFlags forcetype ConfigPage forcetype ConfigPageManager diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index dcddcc9aec..17703fe4b1 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -180,7 +180,8 @@ get_verify_dcast() { // Returns the configure object for accessing config variables from a // scripting language. -ConfigExpress & +DConfig & get_config_express() { + static DConfig config_express; return config_express; } diff --git a/panda/src/express/config_express.h b/panda/src/express/config_express.h index cb0cb4a978..15861d7347 100644 --- a/panda/src/express/config_express.h +++ b/panda/src/express/config_express.h @@ -52,8 +52,7 @@ extern EXPCL_PANDAEXPRESS ConfigVariableDouble collect_tcp_interval; // Expose the Config variable for Python access. BEGIN_PUBLISH -typedef Config::Config ConfigExpress; -EXPCL_PANDAEXPRESS ConfigExpress &get_config_express(); +EXPCL_PANDAEXPRESS DConfig &get_config_express(); END_PUBLISH extern EXPCL_PANDAEXPRESS void init_libexpress(); diff --git a/panda/src/mathutil/randomizer.h b/panda/src/mathutil/randomizer.h index 6e69d47343..6863a700ae 100644 --- a/panda/src/mathutil/randomizer.h +++ b/panda/src/mathutil/randomizer.h @@ -18,6 +18,8 @@ #include "pandabase.h" #include "mersenne.h" +#include + //////////////////////////////////////////////////////////////////// // Class : Randomizer // Description : A handy class to return random numbers. diff --git a/panda/src/putil/bamCache.h b/panda/src/putil/bamCache.h index 055e2b9aef..33d5c026f4 100644 --- a/panda/src/putil/bamCache.h +++ b/panda/src/putil/bamCache.h @@ -24,6 +24,8 @@ #include "reMutex.h" #include "reMutexHolder.h" +#include + class BamCacheIndex; ////////////////////////////////////////////////////////////////////