move TypedObject etc. stuff to dtool

This commit is contained in:
David Rose 2005-07-06 17:29:46 +00:00
parent eb8f9aef49
commit be6d48df86
43 changed files with 298 additions and 330 deletions

View File

@ -138,7 +138,7 @@
// What is the syntax of the STL allocator declaration? See
// LocalSetup.pp for allowable values.
#define STL_ALLOCATOR GNU
#define STL_ALLOCATOR MODERN
// The dynamic library file extension (usually .so .dll or .dylib):
#define DYNAMIC_LIB_EXT .so

View File

@ -21,8 +21,7 @@
cppSimpleType.h cppStructType.h cppTBDType.h \
cppTemplateParameterList.h cppTemplateScope.h cppToken.h \
cppType.h cppTypeDeclaration.h cppTypeParser.h \
cppTypeProxy.h cppTypedef.h cppUsing.h cppVisibility.h \
indent.h
cppTypeProxy.h cppTypedef.h cppUsing.h cppVisibility.h
#define INCLUDED_SOURCES \
cppArrayType.cxx cppClassTemplateParameter.cxx \
@ -38,6 +37,6 @@
cppTemplateParameterList.cxx cppTemplateScope.cxx \
cppToken.cxx cppType.cxx cppTypeDeclaration.cxx \
cppTypeParser.cxx cppTypeProxy.cxx cppTypedef.cxx \
cppUsing.cxx cppVisibility.cxx indent.cxx
cppUsing.cxx cppVisibility.cxx
#end static_lib_target

View File

@ -1,36 +0,0 @@
// Filename: indent.cxx
// Created by: drose (16Jan99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#include "indent.h"
////////////////////////////////////////////////////////////////////
// Function: indent
// Description: A handy function for doing text formatting. This
// function simply outputs the indicated number of
// spaces to the given output stream, returning the
// stream itself. Useful for indenting a series of
// lines of text by a given amount.
////////////////////////////////////////////////////////////////////
ostream &
indent(ostream &out, int indent_level) {
for (int i = 0; i < indent_level; ++i) {
out << ' ';
}
return out;
}

View File

@ -1,37 +0,0 @@
// Filename: indent.h
// Created by: drose (16Jan99)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#ifndef INDENT_H
#define INDENT_H
#include "dtoolbase.h"
////////////////////////////////////////////////////////////////////
// Function: indent
// Description: A handy function for doing text formatting. This
// function simply outputs the indicated number of
// spaces to the given output stream, returning the
// stream itself. Useful for indenting a series of
// lines of text by a given amount.
////////////////////////////////////////////////////////////////////
ostream &
indent(ostream &out, int indent_level);
#endif

View File

@ -6,6 +6,7 @@
dallocator.T dallocator.h \
dtoolbase.cxx dtoolbase.h dtoolbase_cc.h dtoolsymbols.h \
fakestringstream.h \
indent.I indent.h indent.cxx \
nearly_zero.h \
stl_compares.I stl_compares.h \
pallocator.T pallocator.h \
@ -15,6 +16,7 @@
cmath.I cmath.h \
dallocator.T dallocator.h \
dtoolbase.h dtoolbase_cc.h dtoolsymbols.h fakestringstream.h \
indent.I indent.h \
nearly_zero.h \
stl_compares.I stl_compares.h \
pallocator.T pallocator.h \

View File

@ -95,6 +95,7 @@ public:
INLINE pointer allocate(size_type n, allocator<void>::const_pointer hint = 0);
INLINE void deallocate(pointer p, size_type n);
/*
#ifdef __GNUC__
template<class Subtype>
INLINE void destroy(Subtype *p) {
@ -105,6 +106,7 @@ public:
::new(p) Subtype(value);
}
#endif // __GNUC__
*/
template<class U> struct rebind {
typedef dallocator<U> other;

View File

@ -19,7 +19,7 @@
#ifndef INDENT_H
#define INDENT_H
#include "pandabase.h"
#include "dtoolbase.h"
////////////////////////////////////////////////////////////////////
// Function: indent
@ -29,7 +29,7 @@
// stream itself. Useful for indenting a series of
// lines of text by a given amount.
////////////////////////////////////////////////////////////////////
EXPCL_PANDAEXPRESS ostream &
EXPCL_DTOOL ostream &
indent(ostream &out, int indent_level);
////////////////////////////////////////////////////////////////////

View File

@ -104,6 +104,7 @@ public:
INLINE pointer allocate(size_type n, allocator<void>::const_pointer hint = 0);
INLINE void deallocate(pointer p, size_type n);
/*
#ifdef __GNUC__
// The gcc 4.0 version seems to pass any old type to construct() and
// destroy(), so we need template methods.
@ -116,6 +117,7 @@ public:
p->~Subtype();
}
#endif // __GNUC__
*/
template<class U> struct rebind {
typedef pallocator<U> other;

View File

@ -52,11 +52,11 @@
// memory.
////////////////////////////////////////////////////////////////////
template<class Key, class Value, class Compare = less<Key> >
class pmap : public map<Key, Value, Compare, pallocator<Value> > {
class pmap : public map<Key, Value, Compare, pallocator<pair<const Key, Value> > > {
public:
pmap() : map<Key, Value, Compare, pallocator<Value> >() { }
pmap(const pmap<Key, Value, Compare> &copy) : map<Key, Value, Compare, pallocator<Value> >(copy) { }
pmap(const Compare &comp) : map<Key, Value, Compare, pallocator<Value> >(comp) { }
pmap() : map<Key, Value, Compare, pallocator<pair<const Key, Value> > >() { }
pmap(const pmap<Key, Value, Compare> &copy) : map<Key, Value, Compare, pallocator<pair<const Key, Value> > >(copy) { }
pmap(const Compare &comp) : map<Key, Value, Compare, pallocator<pair<const Key, Value> > >(comp) { }
};
////////////////////////////////////////////////////////////////////
@ -67,11 +67,11 @@ public:
// memory.
////////////////////////////////////////////////////////////////////
template<class Key, class Value, class Compare = less<Key> >
class pmultimap : public multimap<Key, Value, Compare, pallocator<Value> > {
class pmultimap : public multimap<Key, Value, Compare, pallocator<pair<const Key, Value> > > {
public:
pmultimap() : multimap<Key, Value, Compare, pallocator<Value> >() { }
pmultimap(const pmultimap<Key, Value, Compare> &copy) : multimap<Key, Value, Compare, pallocator<Value> >(copy) { }
pmultimap(const Compare &comp) : multimap<Key, Value, Compare, pallocator<Value> >(comp) { }
pmultimap() : multimap<Key, Value, Compare, pallocator<pair<const Key, Value> > >() { }
pmultimap(const pmultimap<Key, Value, Compare> &copy) : multimap<Key, Value, Compare, pallocator<pair<const Key, Value> > >(copy) { }
pmultimap(const Compare &comp) : multimap<Key, Value, Compare, pallocator<pair<const Key, Value> > >(comp) { }
};
#ifdef HAVE_STL_HASH
@ -83,11 +83,11 @@ public:
// memory.
////////////////////////////////////////////////////////////////////
template<class Key, class Value, class Compare = method_hash<Key, less<Key> > >
class phash_map : public hash_map<Key, Value, Compare, pallocator<Value> > {
class phash_map : public hash_map<Key, Value, Compare, pallocator<pair<const Key, Value> > > {
public:
phash_map() : hash_map<Key, Value, Compare, pallocator<Value> >() { }
phash_map(const phash_map<Key, Value, Compare> &copy) : hash_map<Key, Value, Compare, pallocator<Value> >(copy) { }
phash_map(const Compare &comp) : hash_map<Key, Value, Compare, pallocator<Value> >(comp) { }
phash_map() : hash_map<Key, Value, Compare, pallocator<pair<const Key, Value> > >() { }
phash_map(const phash_map<Key, Value, Compare> &copy) : hash_map<Key, Value, Compare, pallocator<pair<const Key, Value> > >(copy) { }
phash_map(const Compare &comp) : hash_map<Key, Value, Compare, pallocator<pair<const Key, Value> > >(comp) { }
};
////////////////////////////////////////////////////////////////////
@ -98,11 +98,11 @@ public:
// memory.
////////////////////////////////////////////////////////////////////
template<class Key, class Value, class Compare = method_hash<Key, less<Key> > >
class phash_multimap : public hash_multimap<Key, Value, Compare, pallocator<Value> > {
class phash_multimap : public hash_multimap<Key, Value, Compare, pallocator<pair<const Key, Value> > > {
public:
phash_multimap() : hash_multimap<Key, Value, Compare, pallocator<Value> >() { }
phash_multimap(const phash_multimap<Key, Value, Compare> &copy) : hash_multimap<Key, Value, Compare, pallocator<Value> >(copy) { }
phash_multimap(const Compare &comp) : hash_multimap<Key, Value, Compare, pallocator<Value> >(comp) { }
phash_multimap() : hash_multimap<Key, Value, Compare, pallocator<pair<const Key, Value> > >() { }
phash_multimap(const phash_multimap<Key, Value, Compare> &copy) : hash_multimap<Key, Value, Compare, pallocator<pair<const Key, Value> > >(copy) { }
phash_multimap(const Compare &comp) : hash_multimap<Key, Value, Compare, pallocator<pair<const Key, Value> > >(comp) { }
};
#else // HAVE_STL_HASH

View File

@ -19,6 +19,7 @@
#include "filename.h"
#include "dSearchPath.h"
#include "executionEnvironment.h"
#include "vector_string.h"
#include <stdio.h> // For rename() and tempnam()
#include <time.h> // for clock() and time()
@ -644,7 +645,7 @@ standardize() {
return;
}
vector<string> components;
vector_string components;
// Pull off the components of the filename one at a time.
bool global = (_filename[0] == '/');
@ -1091,12 +1092,12 @@ compare_timestamps(const Filename &other,
// This file doesn't, the other one does.
return this_missing_is_old ? -1 : 1;
} else { // !other_exists
assert(!other_exists);
// This file exists, the other one doesn't.
return other_missing_is_old ? 1 : -1;
}
// !other_exists
assert(!other_exists);
// This file exists, the other one doesn't.
return other_missing_is_old ? 1 : -1;
}
////////////////////////////////////////////////////////////////////

View File

@ -14,19 +14,39 @@
interrogateFunctionWrapper.h interrogateManifest.I \
interrogateManifest.h interrogateType.I interrogateType.h \
interrogate_datafile.I interrogate_datafile.h \
interrogate_interface.h interrogate_request.h vector_int.h
interrogate_interface.h interrogate_request.h \
py_panda.h \
register_type.I register_type.h \
typedObject.I typedObject.h \
typeHandle.I typeHandle.h \
typeRegistry.I typeRegistry.h \
typeRegistryNode.I typeRegistryNode.h \
vector_int.h
#define INCLUDED_SOURCES \
config_interrogatedb.cxx indexRemapper.cxx \
config_interrogatedb.cxx \
dtool_super_base.cxx \
indexRemapper.cxx \
interrogateComponent.cxx interrogateDatabase.cxx \
interrogateElement.cxx interrogateFunction.cxx \
interrogateFunctionWrapper.cxx interrogateManifest.cxx \
interrogateType.cxx interrogate_datafile.cxx \
interrogate_interface.cxx interrogate_request.cxx \
py_panda.cxx \
register_type.cxx \
typedObject.cxx \
typeHandle.cxx \
typeRegistry.cxx typeRegistryNode.cxx \
vector_int.cxx
#define INSTALL_HEADERS \
interrogate_interface.h interrogate_request.h vector_int.h \
config_interrogatedb.h py_panda.h
config_interrogatedb.h py_panda.h \
register_type.I register_type.h \
typedObject.I typedObject.h \
typeHandle.I typeHandle.h \
typeRegistry.I typeRegistry.h \
typeRegistryNode.I typeRegistryNode.h \
#end lib_target

View File

@ -0,0 +1,95 @@
// Filename: dtool_super_base.cxx
// Created by: drose (04Jul05)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#include "py_panda.h"
class EmptyClass
{
};
Define_Module_Class_Private(dtoolconfig,DTOOL_SUPPER_BASE,EmptyClass,DTOOL_SUPPER_BASE111);
static PyObject * GetSupperBase(PyObject * self)
{
Py_INCREF(&(Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject())); // order is important .. this is used for static functions
return (PyObject *)&Dtool_DTOOL_SUPPER_BASE;
};
PyMethodDef Dtool_Methods_DTOOL_SUPPER_BASE[]= {
{ "DtoolGetSupperBase",(PyCFunction ) &GetSupperBase, METH_NOARGS,"Will Return SUPPERbase Class"},
{ NULL, NULL }
};
static long DTool_HashKey_Methods_DTOOL_SUPPER_BASE(PyObject * self)
{
void * local_this =DTOOL_Call_GetPointerThis(self);
if(local_this == NULL)
{
return -1;
};
return (long)local_this;
};
inline void Dtool_PyModuleClassInit_DTOOL_SUPPER_BASE(PyObject *module)
{
static bool initdone = false;
if(!initdone)
{
initdone = true;
Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_dict = PyDict_New();
PyDict_SetItemString(Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_dict,"DtoolClassDict",Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_dict);
// __hash__
Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_hash = &DTool_HashKey_Methods_DTOOL_SUPPER_BASE;
Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_compare = &DTOOL_PyObject_Compare;
if(PyType_Ready(&Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject()) < 0)
{
PyErr_SetString(PyExc_TypeError, "PyType_Ready(Dtool_DTOOL_SUPPER_BASE)");
return;
}
Py_INCREF(&Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject());
PyDict_SetItemString(Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_dict,"DtoolGetSupperBase",PyCFunction_New(&Dtool_Methods_DTOOL_SUPPER_BASE[0],&Dtool_DTOOL_SUPPER_BASE.As_PyObject()));
}
if(module != NULL)
{
Py_INCREF(&Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject());
PyModule_AddObject(module, "DTOOL_SUPPER_BASE",(PyObject *)&Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject());
}
}
inline void * Dtool_DowncastInterface_DTOOL_SUPPER_BASE(void *from_this, Dtool_PyTypedObject *from_type)
{
return (void *) NULL;
}
inline void * Dtool_UpcastInterface_DTOOL_SUPPER_BASE(PyObject *self, Dtool_PyTypedObject *requested_type)
{
return NULL;
}
int Dtool_Init_DTOOL_SUPPER_BASE(PyObject *self, PyObject *args, PyObject *kwds)
{
PyErr_SetString(PyExc_TypeError, "Error Can Not Init SUPPER BASE");
return -1;
}

View File

@ -1,5 +1,6 @@
#include "vector_int.cxx"
#include "dtool_super_base.cxx"
#include "config_interrogatedb.cxx"
#include "indexRemapper.cxx"
#include "interrogateComponent.cxx"

View File

@ -3,6 +3,12 @@
#include "interrogateManifest.cxx"
#include "interrogateType.cxx"
#include "interrogate_request.cxx"
#include "py_panda.cxx"
#include "register_type.cxx"
#include "typedObject.cxx"
#include "typeHandle.cxx"
#include "typeRegistry.cxx"
#include "typeRegistryNode.cxx"

View File

@ -0,0 +1,19 @@
// Filename: py_panda.cxx
// Created by: drose (04Jul05)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#include "py_panda.h"

View File

@ -34,7 +34,7 @@
#ifndef NO_RUNTIME_TYPES
#include "pandabase.h"
#include "dtoolbase.h"
#include "typedObject.h"
#include "typeRegistry.h"
@ -43,6 +43,9 @@
#ifdef HAVE_LONG_LONG
#undef HAVE_LONG_LONG
#endif
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif
#include "Python.h"
#include "structmember.h"
@ -783,94 +786,7 @@ inline int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2)
return 0;
}
#ifdef PANDA_LIBRARY_NAME_libexpress
#define DTOOL_CREATE_SUPPER_BASE
#endif
#ifdef DTOOL_CREATE_SUPPER_BASE
class EmptyClass
{
};
Define_Module_Class_Private(pandaexpress,DTOOL_SUPPER_BASE,EmptyClass,DTOOL_SUPPER_BASE111);
static PyObject * GetSupperBase(PyObject * self)
{
Py_INCREF(&(Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject())); // order is important .. this is used for static functions
return (PyObject *)&Dtool_DTOOL_SUPPER_BASE;
};
PyMethodDef Dtool_Methods_DTOOL_SUPPER_BASE[]= {
{ "DtoolGetSupperBase",(PyCFunction ) &GetSupperBase, METH_NOARGS,"Will Return SUPPERbase Class"},
{ NULL, NULL }
};
static long DTool_HashKey_Methods_DTOOL_SUPPER_BASE(PyObject * self)
{
void * local_this =DTOOL_Call_GetPointerThis(self);
if(local_this == NULL)
{
return -1;
};
return (long)local_this;
};
inline void Dtool_PyModuleClassInit_DTOOL_SUPPER_BASE(PyObject *module)
{
static bool initdone = false;
if(!initdone)
{
initdone = true;
Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_dict = PyDict_New();
PyDict_SetItemString(Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_dict,"DtoolClassDict",Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_dict);
// __hash__
Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_hash = &DTool_HashKey_Methods_DTOOL_SUPPER_BASE;
Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_compare = &DTOOL_PyObject_Compare;
if(PyType_Ready(&Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject()) < 0)
{
PyErr_SetString(PyExc_TypeError, "PyType_Ready(Dtool_DTOOL_SUPPER_BASE)");
return;
}
Py_INCREF(&Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject());
PyDict_SetItemString(Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject().tp_dict,"DtoolGetSupperBase",PyCFunction_New(&Dtool_Methods_DTOOL_SUPPER_BASE[0],&Dtool_DTOOL_SUPPER_BASE.As_PyObject()));
}
if(module != NULL)
{
Py_INCREF(&Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject());
PyModule_AddObject(module, "DTOOL_SUPPER_BASE",(PyObject *)&Dtool_DTOOL_SUPPER_BASE.As_PyTypeObject());
}
}
inline void * Dtool_DowncastInterface_DTOOL_SUPPER_BASE(void *from_this, Dtool_PyTypedObject *from_type)
{
return (void *) NULL;
}
inline void * Dtool_UpcastInterface_DTOOL_SUPPER_BASE(PyObject *self, Dtool_PyTypedObject *requested_type)
{
return NULL;
}
int Dtool_Init_DTOOL_SUPPER_BASE(PyObject *self, PyObject *args, PyObject *kwds)
{
PyErr_SetString(PyExc_TypeError, "Error Can Not Init SUPPER BASE");
return -1;
}
#else
IMPORT_THIS struct Dtool_PyTypedObject Dtool_DTOOL_SUPPER_BASE;
#endif // DTOOL_CREATE_SUPPER_BASE
EXPCL_DTOOLCONFIG extern struct Dtool_PyTypedObject Dtool_DTOOL_SUPPER_BASE;
#endif // PY_PANDA_H_

View File

@ -19,7 +19,7 @@
#ifndef REGISTER_TYPE_H
#define REGISTER_TYPE_H
#include "pandabase.h"
#include "dtoolbase.h"
#include "typeHandle.h"
#include "typeRegistry.h"
@ -85,13 +85,13 @@ register_dynamic_type(const string &name,
// A few system-wide TypeHandles are defined for some basic types.
extern TypeHandle EXPCL_PANDAEXPRESS long_type_handle;
extern TypeHandle EXPCL_PANDAEXPRESS int_type_handle;
extern TypeHandle EXPCL_PANDAEXPRESS short_type_handle;
extern TypeHandle EXPCL_PANDAEXPRESS char_type_handle;
extern TypeHandle EXPCL_PANDAEXPRESS bool_type_handle;
extern TypeHandle EXPCL_PANDAEXPRESS double_type_handle;
extern TypeHandle EXPCL_PANDAEXPRESS float_type_handle;
extern TypeHandle EXPCL_DTOOLCONFIG long_type_handle;
extern TypeHandle EXPCL_DTOOLCONFIG int_type_handle;
extern TypeHandle EXPCL_DTOOLCONFIG short_type_handle;
extern TypeHandle EXPCL_DTOOLCONFIG char_type_handle;
extern TypeHandle EXPCL_DTOOLCONFIG bool_type_handle;
extern TypeHandle EXPCL_DTOOLCONFIG double_type_handle;
extern TypeHandle EXPCL_DTOOLCONFIG float_type_handle;
extern TypeHandle long_p_type_handle;
extern TypeHandle int_p_type_handle;
@ -102,7 +102,7 @@ extern TypeHandle double_p_type_handle;
extern TypeHandle float_p_type_handle;
extern TypeHandle void_p_type_handle;
void EXPCL_PANDAEXPRESS init_system_type_handles();
void EXPCL_DTOOLCONFIG init_system_type_handles();
// The following template function and its specializations will return
// a TypeHandle for any type in the world, from a pointer to that

View File

@ -17,11 +17,6 @@
////////////////////////////////////////////////////////////////////
// In general, we use the express_cat->info() syntax in this file
// (instead of express_cat.info()), because much of this work is done at
// static init time, and we must use the arrow syntax to force
// initialization of the express_cat category.
////////////////////////////////////////////////////////////////////
// Function: TypeHandle::Constructor
// Access: Published

View File

@ -19,13 +19,11 @@
#ifndef TYPEHANDLE_H
#define TYPEHANDLE_H
#include "pandabase.h"
#include "dtoolbase.h"
#include "typeRegistry.h"
#include "notify.h"
#include "config_express.h"
#include "set"
#include <set>
// The following illustrates the convention for declaring a type that
// uses TypeHandle. In this example, ThisThingie inherits from
@ -90,7 +88,7 @@ class TypedObject;
// ancestry of a particular type may be queried, and the
// type name may be retrieved for run-time display.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAEXPRESS TypeHandle {
class EXPCL_DTOOLCONFIG TypeHandle {
PUBLISHED:
INLINE TypeHandle();
INLINE TypeHandle(const TypeHandle &copy);

View File

@ -48,32 +48,3 @@ freshen_derivations() {
_derivations_fresh = true;
}
}
////////////////////////////////////////////////////////////////////
// Function: TypeRegistry::is_derived_from
// Access: Public
// Description: Returns true if the first type is derived from the
// second type, false otherwise.
//
// The "child_object" pointer is an optional pointer to
// the TypedObject class that owns the child TypeHandle.
// It is only used in case the TypeHandle is
// inadvertently undefined.
//
// This function definition follows the definitions for
// look_up() and freshen_derivations() just to maximize
// the chance the the compiler will be able to inline
// the above functions. Yeah, a compiler shouldn't
// care, but there's a big different between "shouldn't"
// and "doesn't".
////////////////////////////////////////////////////////////////////
INLINE bool TypeRegistry::
is_derived_from(TypeHandle child, TypeHandle base,
TypedObject *child_object) {
const TypeRegistryNode *child_node = look_up(child, child_object);
const TypeRegistryNode *base_node = look_up(base, (TypedObject *)NULL);
nassertr(child_node != (TypeRegistryNode *)NULL &&
base_node != (TypeRegistryNode *)NULL, false);
freshen_derivations();
return TypeRegistryNode::is_derived_from(child_node, base_node);
}

View File

@ -17,16 +17,19 @@
////////////////////////////////////////////////////////////////////
#include "typeRegistry.h"
#include "typeRegistryNode.h"
#include "typeHandle.h"
#include "typedObject.h"
#include "indent.h"
#include "config_express.h"
#include "config_interrogatedb.h"
#include "configVariableBool.h"
#include <algorithm>
// In general, we use the express_cat->info() syntax in this file
// (instead of express_cat.info()), because much of this work is done at
// In general, we use the interrogatedb_cat->info() syntax in this file
// (instead of interrogatedb_cat.info()), because much of this work is done at
// static init time, and we must use the arrow syntax to force
// initialization of the express_cat category.
// initialization of the interrogatedb_cat category.
TypeRegistry *TypeRegistry::_global_pointer = NULL;
@ -64,9 +67,9 @@ register_type(TypeHandle &type_handle, const string &name) {
#ifdef NOTIFY_DEBUG
// This code runs at static init time, so cannot use the
// express_cat.is_spam() syntax.
if (express_cat->is_spam()) {
express_cat->spam() << "Registering type " << name << "\n";
// interrogatedb_cat.is_spam() syntax.
if (interrogatedb_cat->is_spam()) {
interrogatedb_cat->spam() << "Registering type " << name << "\n";
}
#endif
@ -101,7 +104,7 @@ register_type(TypeHandle &type_handle, const string &name) {
// at the first call to register_type(), and we got the same
// reference passed in this time, but now it's different! Bad
// juju.
express_cat->error()
interrogatedb_cat->error()
<< "Reregistering " << name << "\n";
type_handle == rnode->_handle;
return false;
@ -109,7 +112,7 @@ register_type(TypeHandle &type_handle, const string &name) {
if (type_handle != rnode->_handle) {
// Hmm, we seem to have a contradictory type registration!
express_cat->warning()
interrogatedb_cat->warning()
<< "Attempt to register type " << name << " more than once!\n";
// This is invalid, but we'll allow it anyway. It seems to happen
@ -142,9 +145,9 @@ register_dynamic_type(const string &name) {
#ifdef NOTIFY_DEBUG
// This code runs at static init time, so cannot use the
// express_cat.is_spam() syntax.
if (express_cat->is_spam()) {
express_cat->spam() << "Registering type " << name << "\n";
// interrogatedb_cat.is_spam() syntax.
if (interrogatedb_cat->is_spam()) {
interrogatedb_cat->spam() << "Registering type " << name << "\n";
}
#endif
@ -211,7 +214,7 @@ record_alternate_name(TypeHandle type, const string &name) {
NameRegistry::iterator ri =
_name_registry.insert(NameRegistry::value_type(name, rnode)).first;
if ((*ri).second != rnode) {
express_cat.warning()
interrogatedb_cat.warning()
<< "Name " << name << " already assigned to TypeHandle "
<< rnode->_name << "; cannot reassign to " << type << "\n";
}
@ -254,6 +257,35 @@ get_name(TypeHandle type, TypedObject *object) const {
return rnode->_name;
}
////////////////////////////////////////////////////////////////////
// Function: TypeRegistry::is_derived_from
// Access: Public
// Description: Returns true if the first type is derived from the
// second type, false otherwise.
//
// The "child_object" pointer is an optional pointer to
// the TypedObject class that owns the child TypeHandle.
// It is only used in case the TypeHandle is
// inadvertently undefined.
//
// This function definition follows the definitions for
// look_up() and freshen_derivations() just to maximize
// the chance the the compiler will be able to inline
// the above functions. Yeah, a compiler shouldn't
// care, but there's a big different between "shouldn't"
// and "doesn't".
////////////////////////////////////////////////////////////////////
bool TypeRegistry::
is_derived_from(TypeHandle child, TypeHandle base,
TypedObject *child_object) {
const TypeRegistryNode *child_node = look_up(child, child_object);
const TypeRegistryNode *base_node = look_up(base, (TypedObject *)NULL);
nassertr(child_node != (TypeRegistryNode *)NULL &&
base_node != (TypeRegistryNode *)NULL, false);
freshen_derivations();
return TypeRegistryNode::is_derived_from(child_node, base_node);
}
////////////////////////////////////////////////////////////////////
// Function: TypeRegistry::get_num_root_classes
// Access: Public
@ -400,7 +432,7 @@ reregister_types() {
++ri) {
TypeRegistryNode *rnode = (*ri);
if (rnode != NULL && rnode->_handle != rnode->_ref) {
express_cat->warning()
interrogatedb_cat->warning()
<< "Reregistering " << rnode->_name << "\n";
}
}
@ -439,8 +471,8 @@ TypeRegistry *TypeRegistry::
ptr() {
if (_global_pointer == NULL) {
#ifdef NOTIFY_DEBUG
if (express_cat->is_spam()) {
express_cat->spam()
if (interrogatedb_cat->is_spam()) {
interrogatedb_cat->spam()
<< "Creating global TypeRegistry\n";
}
#endif
@ -478,7 +510,13 @@ init_global_pointer() {
// Now that we've created the TypeRegistry, we can assign this
// Config variable.
TypeRegistryNode::_paranoid_inheritance = get_paranoid_inheritance();
ConfigVariableBool paranoid_inheritance
("paranoid-inheritance", true,
PRC_DESC("Set this to true to double-check the test for inheritance of "
"TypeHandles, e.g. via is_of_type(). This has no effect if NDEBUG "
"is defined."));
TypeRegistryNode::_paranoid_inheritance = paranoid_inheritance;
}
////////////////////////////////////////////////////////////////////
@ -491,7 +529,7 @@ init_global_pointer() {
void TypeRegistry::
rebuild_derivations() {
#ifdef NOTIFY_DEBUG
express_cat->debug()
interrogatedb_cat->debug()
<< "Rebuilding derivation tree.\n";
#endif
@ -575,19 +613,19 @@ look_up(TypeHandle handle, TypedObject *object) const {
handle = object->force_init_type();
if (handle._index == 0) {
// Strange.
express_cat->error()
interrogatedb_cat->error()
<< "Unable to force_init_type() on unregistered TypeHandle.\n";
nassertr(false, NULL);
}
if (handle == object->get_type()) {
// Problem solved!
express_cat->warning()
interrogatedb_cat->warning()
<< "Type " << handle << " was unregistered!\n";
} else {
// No good; it looks like the TypeHandle belongs to a class
// that defined get_type(), but didn't define
// force_init_type().
express_cat->error()
interrogatedb_cat->error()
<< "Attempt to reference unregistered TypeHandle. Type is of some\n"
<< "class derived from " << handle << " that doesn't define a good\n"
<< "force_init_type() method.\n";
@ -597,17 +635,17 @@ look_up(TypeHandle handle, TypedObject *object) const {
} else {
// We don't have a TypedObject pointer, so there's nothing we
// can do about it.
express_cat->error()
interrogatedb_cat->error()
<< "Attempt to reference unregistered TypeHandle!\n"
<< "Registered TypeHandles are:\n";
write(express_cat->error(false));
write(interrogatedb_cat->error(false));
nassertr(false, NULL);
}
}
if (handle._index < 0 ||
handle._index >= (int)_handle_registry.size()) {
express_cat->fatal()
interrogatedb_cat->fatal()
<< "Invalid TypeHandle index " << handle._index
<< "! Is memory corrupt?\n";
nassertr(false, NULL);
@ -624,7 +662,7 @@ TypeHandle TypeRegistry::find_type_by_id(int id) const
{
if (id < 0 ||id >= (int)_handle_registry.size())
{
express_cat->fatal()
interrogatedb_cat->fatal()
<< "Invalid TypeHandle index " << id
<< "! Is memory corrupt?\n";
//nassertr(false, NULL);

View File

@ -19,15 +19,18 @@
#ifndef TYPEREGISTRY_H
#define TYPEREGISTRY_H
#include "pandabase.h"
#include "typeHandle.h"
#include "typeRegistryNode.h"
#include "dtoolbase.h"
#include "notify.h"
#include "pvector.h"
#include "pmap.h"
#include <set>
class TypeHandle;
class TypeRegistryNode;
class TypedObject;
////////////////////////////////////////////////////////////////////
// Class : TypeRegistry
// Description : The TypeRegistry class maintains all the assigned
@ -37,7 +40,7 @@
// initially, and it should be migrated to shared memory
// as soon as shared memory becomes available.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAEXPRESS TypeRegistry {
class EXPCL_DTOOLCONFIG TypeRegistry {
public:
// User code shouldn't generally need to call
// TypeRegistry::register_type() or record_derivation() directly;
@ -55,8 +58,8 @@ PUBLISHED:
string get_name(TypeHandle type, TypedObject *object) const;
INLINE bool is_derived_from(TypeHandle child, TypeHandle base,
TypedObject *child_object);
bool is_derived_from(TypeHandle child, TypeHandle base,
TypedObject *child_object);
int get_num_root_classes();
TypeHandle get_root_class(int n);
@ -115,7 +118,7 @@ private:
///////////////////////////////////////////
// Helper function to allow for "C" interaction into the type system
extern "C" EXPCL_PANDAEXPRESS int get_best_parent_from_Set(int id, const std::set<int> &set);
extern "C" EXPCL_DTOOLCONFIG int get_best_parent_from_Set(int id, const std::set<int> &set);
#include "typeRegistry.I"

View File

@ -17,6 +17,7 @@
////////////////////////////////////////////////////////////////////
#include "typeRegistryNode.h"
#include "config_interrogatedb.h"
#include <algorithm>
@ -68,7 +69,7 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) {
if (_paranoid_inheritance) {
bool paranoid_derives = check_derived_from(child, base);
if (derives != paranoid_derives) {
express_cat.error()
interrogatedb_cat.error()
<< "Inheritance test for " << child->_name
<< " from " << base->_name << " failed!\n"
<< "Result: " << derives << " should have been: "
@ -133,7 +134,7 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) {
if (_paranoid_inheritance) {
bool paranoid_derives = check_derived_from(child, base);
if (derives != paranoid_derives) {
express_cat.error()
interrogatedb_cat.error()
<< "Inheritance test for " << child->_name
<< " from " << base->_name << " failed!\n"
<< "Result: " << derives << " should have been: "

View File

@ -19,7 +19,7 @@
#ifndef TYPEREGISTRYNODE_H
#define TYPEREGISTRYNODE_H
#include "pandabase.h"
#include "dtoolbase.h"
#include "typeHandle.h"
@ -32,7 +32,7 @@
// class; this class is hidden within the TypeRegistry
// accessors.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAEXPRESS TypeRegistryNode {
class EXPCL_DTOOLCONFIG TypeRegistryNode {
public:
TypeRegistryNode(TypeHandle handle, const string &name, TypeHandle &ref);

View File

@ -17,7 +17,7 @@
////////////////////////////////////////////////////////////////////
#include "typedObject.h"
#include "config_express.h"
#include "config_interrogatedb.h"
TypeHandle TypedObject::_type_handle;
@ -42,7 +42,7 @@ get_type() const {
// Normally, this function should never be called, because it is a
// pure virtual function. If it is called, you probably called
// get_type() on a recently-destructed object.
express_cat.warning()
interrogatedb_cat.warning()
<< "TypedObject::get_type() called!\n";
return _type_handle;
}

View File

@ -19,12 +19,12 @@
#ifndef TYPEDOBJECT_H
#define TYPEDOBJECT_H
#include "pandabase.h"
#include "dtoolbase.h"
#include "typeHandle.h"
#include "register_type.h"
#include "set"
#include <set>
////////////////////////////////////////////////////////////////////
// Class : TypedObject
@ -104,7 +104,7 @@
// }
//
////////////////////////////////////////////////////////////////////
class EXPCL_PANDAEXPRESS TypedObject {
class EXPCL_DTOOLCONFIG TypedObject {
public:
INLINE TypedObject();
INLINE TypedObject(const TypedObject &copy);

View File

@ -22,10 +22,7 @@
#include "dtoolbase.h"
#include "notifySeverity.h"
#include <string>
#include <vector>
#include <map>
#include "pmap.h"
class NotifyCategory;
@ -96,7 +93,7 @@ private:
bool _assert_failed;
string _assert_error_message;
typedef map<string, NotifyCategory *> Categories;
typedef pmap<string, NotifyCategory *> Categories;
Categories _categories;
static Notify *_global_ptr;

View File

@ -1,4 +1,4 @@
#define LOCAL_LIBS dtoolutil dtoolbase prc dconfig interrogatedb
#define LOCAL_LIBS pystub dtoolutil dtoolbase prc dconfig interrogatedb
#begin bin_target
#define BUILD_TARGET $[HAVE_SSL]

View File

@ -26,7 +26,7 @@
encryptStreamBuf.h encryptStreamBuf.I encryptStream.h encryptStream.I \
error_utils.h \
hashGeneratorBase.I hashGeneratorBase.h \
hashVal.I hashVal.h indent.I indent.h \
hashVal.I hashVal.h \
indirectLess.I indirectLess.h \
littleEndian.h \
memoryInfo.I memoryInfo.h \
@ -50,7 +50,6 @@
pta_uchar.h \
ramfile.I ramfile.h \
referenceCount.I referenceCount.h \
register_type.I register_type.h \
reversedNumericData.I reversedNumericData.h \
selectThreadImpl.h \
streamReader.I streamReader.h streamWriter.I streamWriter.h \
@ -60,11 +59,8 @@
threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \
threadNsprImpl.h threadNsprImpl.I threadPriority.h \
tokenBoard.I \
tokenBoard.h trueClock.I trueClock.h typeHandle.I \
typeHandle.h typedObject.I typedObject.h \
tokenBoard.h trueClock.I trueClock.h \
typedReferenceCount.I typedReferenceCount.h typedef.h \
typeRegistry.I typeRegistry.h \
typeRegistryNode.I typeRegistryNode.h \
unicodeLatinMap.h \
vector_uchar.h \
virtualFileComposite.h virtualFileComposite.I virtualFile.h \
@ -89,7 +85,7 @@
datagramSink.cxx dcast.cxx \
encryptStreamBuf.cxx encryptStream.cxx \
error_utils.cxx \
hashGeneratorBase.cxx hashVal.cxx indent.cxx \
hashGeneratorBase.cxx hashVal.cxx \
memoryInfo.cxx memoryUsage.cxx memoryUsagePointerCounts.cxx \
memoryUsagePointers.cxx multifile.cxx \
pmutex.cxx mutexHolder.cxx mutexDummyImpl.cxx mutexNsprImpl.cxx \
@ -105,16 +101,15 @@
profileTimer.cxx \
pta_uchar.cxx \
ramfile.cxx \
referenceCount.cxx register_type.cxx \
referenceCount.cxx \
reversedNumericData.cxx \
streamReader.cxx streamWriter.cxx \
stringDecoder.cxx \
subStream.cxx subStreamBuf.cxx \
textEncoder.cxx \
thread.cxx threadDummyImpl.cxx threadNsprImpl.cxx \
trueClock.cxx typeHandle.cxx \
typedObject.cxx typedReferenceCount.cxx \
typeRegistry.cxx typeRegistryNode.cxx \
trueClock.cxx \
typedReferenceCount.cxx \
unicodeLatinMap.cxx \
vector_uchar.cxx \
virtualFileComposite.cxx virtualFile.cxx virtualFileList.cxx \
@ -146,7 +141,6 @@
error_utils.h \
hashGeneratorBase.I \
hashGeneratorBase.h hashVal.I hashVal.h \
indent.I indent.h \
indirectLess.I indirectLess.h \
littleEndian.h memoryInfo.I memoryInfo.h memoryUsage.I \
memoryUsage.h memoryUsagePointerCounts.I \
@ -167,7 +161,6 @@
profileTimer.h pta_uchar.h \
ramfile.I ramfile.h \
referenceCount.I referenceCount.h \
register_type.I register_type.h \
reversedNumericData.I reversedNumericData.h \
selectThreadImpl.h \
streamReader.I streamReader.h streamWriter.I streamWriter.h \
@ -177,11 +170,9 @@
threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \
threadNsprImpl.h threadNsprImpl.I threadPriority.h \
tokenBoard.I \
tokenBoard.h trueClock.I trueClock.h typeHandle.I typeHandle.h \
typedObject.I typedObject.h typedReferenceCount.I \
tokenBoard.h trueClock.I trueClock.h \
typedReferenceCount.I \
typedReferenceCount.h typedef.h \
typeRegistry.I typeRegistry.h \
typeRegistryNode.I typeRegistryNode.h \
unicodeLatinMap.h \
vector_uchar.h \
virtualFileComposite.h virtualFileComposite.I virtualFile.h \

View File

@ -6,6 +6,9 @@ forcetype GlobPattern
forcetype Notify
forcetype NotifyCategory
forcetype NotifySeverity
forcetype TypedObject
forcetype TypeHandle
forcetype TypeRegistry
forcetype ConfigExpress
renametype ConfigExpress ConfigExpress

View File

@ -248,21 +248,6 @@ get_paranoid_clock() {
return *paranoid_clock;
}
bool
get_paranoid_inheritance() {
static ConfigVariableBool *paranoid_inheritance = NULL;
if (paranoid_inheritance == (ConfigVariableBool *)NULL) {
paranoid_inheritance = new ConfigVariableBool
("paranoid-inheritance", true,
PRC_DESC("Set this to true to double-check the test for inheritance of "
"TypeHandles, e.g. via is_of_type(). This has no effect if NDEBUG "
"is defined."));
}
return *paranoid_inheritance;
}
bool
get_verify_dcast() {
static ConfigVariableBool *verify_dcast = NULL;

View File

@ -23,6 +23,7 @@
#include "typeHandle.h"
#include "typedObject.h"
#include "config_express.h"
// The DCAST (downcast) macro is defined as a convenience for
// downcasting from some TypedObject pointer (or a PointerTo). It's

View File

@ -18,7 +18,6 @@
#include "encryptStream.cxx"
#include "hashGeneratorBase.cxx"
#include "hashVal.cxx"
#include "indent.cxx"
#include "memoryInfo.cxx"
#include "memoryUsage.cxx"
#include "memoryUsagePointerCounts.cxx"

View File

@ -9,7 +9,6 @@
#include "pta_uchar.cxx"
#include "ramfile.cxx"
#include "referenceCount.cxx"
#include "register_type.cxx"
#include "reversedNumericData.cxx"
#include "streamReader.cxx"
#include "streamWriter.cxx"
@ -21,11 +20,7 @@
#include "threadDummyImpl.cxx"
#include "threadNsprImpl.cxx"
#include "trueClock.cxx"
#include "typeHandle.cxx"
#include "typedObject.cxx"
#include "typedReferenceCount.cxx"
#include "typeRegistry.cxx"
#include "typeRegistryNode.cxx"
#include "unicodeLatinMap.cxx"
#include "vector_uchar.cxx"
#include "virtualFile.cxx"

View File

@ -138,7 +138,7 @@ private:
// Actually, it turns out that it doesn't matter, since somehow the
// pallocator gets used even though we specify dallocator here, so
// we have to make special code that handles the recursion anyway.
typedef map<void *, MemoryInfo, less<void *>, dallocator<MemoryInfo> > Table;
typedef map<void *, MemoryInfo, less<void *>, dallocator<pair<void * const, MemoryInfo> > > Table;
Table _table;
int _freeze_index;
int _count;
@ -156,7 +156,7 @@ private:
private:
// Cannot use a pmap, since that would be recursive!
typedef map<TypeHandle, MemoryUsagePointerCounts,
less<TypeHandle>, dallocator<MemoryUsagePointerCounts> > Counts;
less<TypeHandle>, dallocator<pair<const TypeHandle, MemoryUsagePointerCounts> > > Counts;
Counts _counts;
};
TypeHistogram _trend_types;

View File

@ -4200,6 +4200,7 @@ finish_modify_state() {
TexGenAttrib::Mode mode = _current_tex_gen->get_mode(stage);
switch (mode) {
case TexGenAttrib::M_off:
case TexGenAttrib::M_light_vector:
break;
case TexGenAttrib::M_eye_sphere_map: