dxml: Remove TinyXML bindings

This isn't used anywhere in the Panda source anymore, and is considered out-of-scope for Panda.  Python users can use the XML parsing library that's shipped with the Python source (or any other one on PyPI), and C++ users can just pull TinyXML into their projects directly.

If there really is a strong call to bring this back, I'd rather do it as an external package.

Closes #1379
This commit is contained in:
rdb 2022-11-03 13:42:33 +01:00
parent 37f7dc285b
commit a1105f0f96
15 changed files with 2 additions and 5645 deletions

View File

@ -1,71 +0,0 @@
#ifndef TINYXML_H
#define TINYXML_H
// A simple header to mirror the subset of the tinyxml interface we
// wish to expose to interrogate. This is intended to protect us from
// having to run interrogate directly on the tinyxml.h header file.
class TiXmlBase;
class TiXmlNode;
class TiXmlElement;
class TiXmlDocument;
class TiXmlBase {
};
class TiXmlNode : public TiXmlBase {
public:
const char *Value() const;
void SetValue(const char *_value);
TiXmlNode *InsertEndChild(const TiXmlNode &addThis);
bool RemoveChild( TiXmlNode* removeThis );
const TiXmlElement *NextSiblingElement() const;
TiXmlElement *NextSiblingElement();
const TiXmlElement* NextSiblingElement(const char *) const;
TiXmlElement* NextSiblingElement(const char *_next);
const TiXmlElement* FirstChildElement() const;
TiXmlElement* FirstChildElement();
const TiXmlElement* FirstChildElement( const char * _value ) const;
TiXmlElement* FirstChildElement( const char * _value );
virtual TiXmlNode* Clone() const;
};
class TiXmlElement : public TiXmlNode {
public:
TiXmlElement(const char * in_value);
TiXmlElement( const TiXmlElement& );
const char* Attribute( const char* name ) const;
void SetAttribute( const char* name, const char * _value );
void RemoveAttribute( const char * name );
};
class TiXmlDeclaration : public TiXmlNode {
public:
TiXmlDeclaration(const char* _version,
const char* _encoding,
const char* _standalone);
};
class TiXmlDocument : public TiXmlNode {
public:
TiXmlDocument();
TiXmlDocument(const char * documentName);
bool LoadFile();
bool SaveFile() const;
bool LoadFile(const char * filename);
bool SaveFile(const char * filename) const;
};
#endif

View File

@ -3251,7 +3251,6 @@ if not PkgSkip("PANDAPHYSICS"):
CopyAllHeaders('panda/src/physics')
if not PkgSkip("PANDAPARTICLESYSTEM"):
CopyAllHeaders('panda/src/particlesystem')
CopyAllHeaders('panda/src/dxml')
CopyAllHeaders('panda/metalibs/panda')
CopyAllHeaders('panda/src/audiotraits')
CopyAllHeaders('panda/src/audiotraits')
@ -4067,24 +4066,6 @@ IGATEFILES=GetDirectoryContents('panda/src/recorder', ["*.h", "*_composite*.cxx"
TargetAdd('libp3recorder.in', opts=OPTS, input=IGATEFILES)
TargetAdd('libp3recorder.in', opts=['IMOD:panda3d.core', 'ILIB:libp3recorder', 'SRCDIR:panda/src/recorder'])
#
# DIRECTORY: panda/src/dxml/
#
DefSymbol("TINYXML", "TIXML_USE_STL", "")
OPTS=['DIR:panda/src/dxml', 'TINYXML']
TargetAdd('tinyxml_composite1.obj', opts=OPTS, input='tinyxml_composite1.cxx')
TargetAdd('libp3tinyxml.ilb', input='tinyxml_composite1.obj')
OPTS=['DIR:panda/src/dxml', 'BUILDING:PANDA', 'TINYXML']
TargetAdd('p3dxml_composite1.obj', opts=OPTS, input='p3dxml_composite1.cxx')
OPTS=['DIR:panda/src/dxml', 'TINYXML']
IGATEFILES=GetDirectoryContents('panda/src/dxml', ["*.h", "p3dxml_composite1.cxx"])
TargetAdd('libp3dxml.in', opts=OPTS, input=IGATEFILES)
TargetAdd('libp3dxml.in', opts=['IMOD:panda3d.core', 'ILIB:libp3dxml', 'SRCDIR:panda/src/dxml'])
#
# DIRECTORY: panda/metalibs/panda/
#
@ -4160,7 +4141,6 @@ TargetAdd('libpanda.dll', input='p3net_composite2.obj')
TargetAdd('libpanda.dll', input='p3nativenet_composite1.obj')
TargetAdd('libpanda.dll', input='p3pandabase_pandabase.obj')
TargetAdd('libpanda.dll', input='libpandaexpress.dll')
TargetAdd('libpanda.dll', input='p3dxml_composite1.obj')
TargetAdd('libpanda.dll', input='libp3dtoolconfig.dll')
TargetAdd('libpanda.dll', input='libp3dtool.dll')
@ -4205,7 +4185,6 @@ PyTargetAdd('core_module.obj', input='libp3nativenet.in')
PyTargetAdd('core_module.obj', input='libp3net.in')
PyTargetAdd('core_module.obj', input='libp3pgui.in')
PyTargetAdd('core_module.obj', input='libp3movies.in')
PyTargetAdd('core_module.obj', input='libp3dxml.in')
if PkgSkip("FREETYPE")==0:
PyTargetAdd('core_module.obj', input='libp3pnmtext.in')
@ -4250,7 +4229,6 @@ PyTargetAdd('core.pyd', input='libp3audio_igate.obj')
PyTargetAdd('core.pyd', input='libp3pgui_igate.obj')
PyTargetAdd('core.pyd', input='libp3net_igate.obj')
PyTargetAdd('core.pyd', input='libp3nativenet_igate.obj')
PyTargetAdd('core.pyd', input='libp3dxml_igate.obj')
if PkgSkip("FREETYPE")==0:
PyTargetAdd('core.pyd', input="libp3pnmtext_igate.obj")
@ -4266,8 +4244,6 @@ PyTargetAdd('core.pyd', input='p3display_ext_composite.obj')
PyTargetAdd('core.pyd', input='p3collide_ext_composite.obj')
PyTargetAdd('core.pyd', input='core_module.obj')
if not GetLinkAllStatic() and GetTarget() != 'emscripten':
PyTargetAdd('core.pyd', input='libp3tinyxml.ilb')
PyTargetAdd('core.pyd', input='libp3interrogatedb.dll')
PyTargetAdd('core.pyd', input=COMMON_PANDA_LIBS)
PyTargetAdd('core.pyd', opts=['WINSOCK2'])

View File

@ -18,7 +18,6 @@ add_subdirectory(src/distort)
add_subdirectory(src/downloader)
add_subdirectory(src/downloadertools)
add_subdirectory(src/dxgsg9)
add_subdirectory(src/dxml)
add_subdirectory(src/egg)
add_subdirectory(src/egg2pg)
add_subdirectory(src/egldisplay)
@ -82,7 +81,7 @@ add_subdirectory(metalibs/pandaphysics)
# Now add the Python modules:
set(CORE_MODULE_COMPONENTS
p3chan p3char p3collide p3cull p3device p3dgraph p3display
p3downloader p3dxml p3event p3express p3gobj p3grutil p3gsgbase p3linmath
p3downloader p3event p3express p3gobj p3grutil p3gsgbase p3linmath
p3mathutil p3movies p3parametrics p3pgraph p3pgraphnodes p3pgui
p3pipeline p3pnmimage p3pstatclient p3putil p3recorder p3text p3tform
p3prc p3dtoolutil p3dtoolbase

View File

@ -1,5 +1,5 @@
set(PANDA_LINK_TARGETS
p3chan p3char p3collide p3cull p3device p3dgraph p3display p3dxml
p3chan p3char p3collide p3cull p3device p3dgraph p3display
p3event p3gobj p3grutil p3gsgbase p3linmath p3mathutil
p3movies p3parametrics p3pgraph p3pgraphnodes p3pgui p3pipeline
p3pnmimage p3pnmimagetypes p3pstatclient p3putil p3recorder p3text p3tform

View File

@ -1,28 +0,0 @@
set(P3DXML_HEADERS
config_dxml.h
tinyxml.h
)
set(P3DXML_SOURCES
config_dxml.cxx
tinyxml.cpp
tinyxmlerror.cpp
tinyxmlparser.cpp
)
composite_sources(p3dxml P3DXML_SOURCES)
add_definitions(-DTIXML_USE_STL)
add_component_library(p3dxml SYMBOL BUILDING_PANDA_DXML
${P3DXML_HEADERS} ${P3DXML_SOURCES})
target_link_libraries(p3dxml pandaexpress)
target_interrogate(p3dxml ALL)
if(NOT BUILD_METALIBS)
install(TARGETS p3dxml
EXPORT Core COMPONENT Core
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d
ARCHIVE COMPONENT CoreDevel)
endif()
install(FILES ${P3DXML_HEADERS} COMPONENT CoreDevel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d)

View File

@ -1,8 +0,0 @@
forcetype TiXmlBase
forcetype TiXmlDeclaration
forcetype TiXmlDocument
forcetype TiXmlElement
forcetype TiXmlNode
# This method can't be exported, because it steals ownership of the pointer.
ignoremember LinkEndChild

View File

@ -1,106 +0,0 @@
/**
* 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."
*
* @file config_dxml.cxx
* @author drose
* @date 2009-08-08
*/
#include "config_dxml.h"
#include "dconfig.h"
#include <stdio.h>
BEGIN_PUBLISH
#include "tinyxml.h"
END_PUBLISH
#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DXML)
#error Buildsystem error: BUILDING_PANDA_DXML not defined
#endif
Configure(config_dxml);
NotifyCategoryDef(dxml, "");
ConfigureFn(config_dxml) {
init_libdxml();
}
/**
* Initializes the library. This must be called at least once before any of
* the functions or classes in this library can be used. Normally it will be
* called by the static initializers and need not be called explicitly, but
* special cases exist.
*/
void
init_libdxml() {
static bool initialized = false;
if (initialized) {
return;
}
initialized = true;
}
BEGIN_PUBLISH
/**
* Reads an XML document from the indicated stream.
* @returns the document, or NULL on error.
*/
TiXmlDocument *
read_xml_stream(std::istream &in) {
TiXmlDocument *doc = new TiXmlDocument;
in >> *doc;
if (in.fail() && !in.eof()) {
delete doc;
return nullptr;
}
return doc;
}
END_PUBLISH
BEGIN_PUBLISH
/**
* Writes an XML document to the indicated stream.
*/
void
write_xml_stream(std::ostream &out, TiXmlDocument *doc) {
out << *doc;
}
END_PUBLISH
BEGIN_PUBLISH
/**
* Writes an XML object to stdout, with formatting.
*/
void
print_xml(TiXmlNode *xnode) {
xnode->Print(stdout, 0);
}
END_PUBLISH
BEGIN_PUBLISH
/**
* Writes an XML object to the indicated file, with formatting. Unfortunately
* the VFS cannot be supported; the file must be a real filename on disk.
*/
void
print_xml_to_file(const Filename &filename, TiXmlNode *xnode) {
std::string os_name = filename.to_os_specific();
#ifdef _WIN32
FILE *file;
if (fopen_s(&file, os_name.c_str(), "w") != 0) {
#else
FILE *file = fopen(os_name.c_str(), "w");
if (file == nullptr) {
#endif
dxml_cat.error() << "Failed to open " << filename << " for writing\n";
}
xnode->Print(file, 0);
fclose(file);
}
END_PUBLISH

View File

@ -1,44 +0,0 @@
/**
* 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."
*
* @file config_dxml.h
* @author drose
* @date 2009-08-08
*/
#ifndef CONFIG_DXML_H
#define CONFIG_DXML_H
#include "pandabase.h"
#include "notifyCategoryProxy.h"
#include "dconfig.h"
// The purpose of this directory is to expose tinyxml interfaces to
// Python via interrogate.
// tinyxml.h requires having the symbol TIXML_USE_STL already defined
// before you include it.
#ifndef TIXML_USE_STL
#define TIXML_USE_STL
#endif
NotifyCategoryDecl(dxml, EXPCL_PANDA_DXML, EXPTP_PANDA_DXML);
extern EXPCL_PANDA_DXML void init_libdxml();
class TiXmlDocument;
class TiXmlNode;
BEGIN_PUBLISH
EXPCL_PANDA_DXML TiXmlDocument *read_xml_stream(std::istream &in);
EXPCL_PANDA_DXML void write_xml_stream(std::ostream &out, TiXmlDocument *doc);
EXPCL_PANDA_DXML void print_xml(TiXmlNode *xnode);
EXPCL_PANDA_DXML void print_xml_to_file(const Filename &filename, TiXmlNode *xnode);
END_PUBLISH
#endif

View File

@ -1,2 +0,0 @@
#include "config_dxml.cxx"
#include "tinyxml_composite1.cxx"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +0,0 @@
#include "tinyxml.cpp"
#include "tinyxmlerror.cpp"
#include "tinyxmlparser.cpp"

View File

@ -1,52 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxml.h"
// The goal of the seperate error file is to make the first
// step towards localization. tinyxml (currently) only supports
// english error messages, but the could now be translated.
//
// It also cleans up the code a bit.
//
const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
{
"No error",
"Error",
"Failed to open file",
"Error parsing Element.",
"Failed to read Element name",
"Error reading Element value.",
"Error reading Attributes.",
"Error: empty tag.",
"Error reading end tag.",
"Error parsing Unknown.",
"Error parsing Comment.",
"Error parsing Declaration.",
"Error document empty.",
"Error null (0) or unexpected EOF found in input stream.",
"Error parsing CDATA.",
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
};

File diff suppressed because it is too large Load Diff

View File

@ -72,7 +72,6 @@
#define BUILDING_PANDA_DEVICE
#define BUILDING_PANDA_DGRAPH
#define BUILDING_PANDA_DISPLAY
#define BUILDING_PANDA_DXML
#define BUILDING_PANDA_EVENT
#define BUILDING_PANDA_GOBJ
#define BUILDING_PANDA_GRUTIL
@ -211,14 +210,6 @@
#define EXPTP_PANDA_DOWNLOADER IMPORT_TEMPL
#endif
#ifdef BUILDING_PANDA_DXML
#define EXPCL_PANDA_DXML EXPORT_CLASS
#define EXPTP_PANDA_DXML EXPORT_TEMPL
#else
#define EXPCL_PANDA_DXML IMPORT_CLASS
#define EXPTP_PANDA_DXML IMPORT_TEMPL
#endif
#ifdef BUILDING_PANDA_EGG
#define EXPCL_PANDA_EGG EXPORT_CLASS
#define EXPTP_PANDA_EGG EXPORT_TEMPL