dbertoni 2002/08/30 16:58:55
Modified: c/src/XalanTransformer XalanCAPI.cpp XalanCAPI.h
XalanTransformer.cpp XalanTransformer.hpp
Log:
Fixes for initialization and termination.
Revision Changes Path
1.24 +27 -7 xml-xalan/c/src/XalanTransformer/XalanCAPI.cpp
Index: XalanCAPI.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanCAPI.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- XalanCAPI.cpp 23 Feb 2002 04:20:47 -0000 1.23
+++ XalanCAPI.cpp 30 Aug 2002 23:58:54 -0000 1.24
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -81,27 +81,47 @@
#include "XalanTransformer.hpp"
+static bool fInitialized = false;
-XALAN_TRANSFORMER_EXPORT_FUNCTION(void)
+
+
+XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
XalanInitialize()
{
- // Call the static initializer for Xerces.
- XMLPlatformUtils::Initialize();
+ try
+ {
+ // Call the static initializer for Xerces.
+ XMLPlatformUtils::Initialize();
+
+ // Initialize Xalan.
+ XalanTransformer::initialize();
+
+ fInitialized = true;
+ }
+ catch(...)
+ {
+ }
- // Initialize Xalan.
- XalanTransformer::initialize();
+ return fInitialized == true ? 0 : -1;
}
XALAN_TRANSFORMER_EXPORT_FUNCTION(void)
-XalanTerminate()
+XalanTerminate(int fCleanUpICU)
{
// Terminate Xalan.
XalanTransformer::terminate();
// Call the static terminator for Xerces.
XMLPlatformUtils::Terminate();
+
+ // Call the cleanup function for the ICU,
+ // if requested.
+ if (fCleanUpICU)
+ {
+ XalanTransformer::ICUCleanUp();
+ }
}
1.18 +30 -7 xml-xalan/c/src/XalanTransformer/XalanCAPI.h
Index: XalanCAPI.h
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanCAPI.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- XalanCAPI.h 3 Oct 2001 18:49:05 -0000 1.17
+++ XalanCAPI.h 30 Aug 2002 23:58:54 -0000 1.18
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -104,20 +104,39 @@
*
* Should be called only once per process before making
* any other API calls.
+ *
+ * @return 0 if successful, -1 if initialization fails.
*/
- XALAN_TRANSFORMER_EXPORT_FUNCTION(void)
+ XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
+#if defined(__cplusplus)
XalanInitialize();
+#else
+ XalanInitialize(void);
+#endif
/**
* Terminate Xalan and Xerces.
*
* Should be called only once per process after deleting all
- * instances of XalanTransformer. Once a process has called
- * this function, it cannot use the API for the remaining
- * lifetime of the process.
+ * instances of XalanTransformer.
+ *
+ * Once a process has called this function, it cannot use the
+ * API until another call to XalanInitialize has been made.
+ *
+ * Optionally, if the ICU has been integrated, this will
+ * call the ICU clean up function. This must only be done
+ * if the ICU will no longer be used by the process, since
+ * the ICU will no longer be in a usable state. See the
+ * ICU documentation for more details.
+ *
+ * This is handy when using leak-detection software, as all
+ * static data allocated by Xalan (and optionally, the ICU)
+ * will be freed.
+ *
+ * @param fCleanUpICU If true, call the ICU clean up function.
*/
XALAN_TRANSFORMER_EXPORT_FUNCTION(void)
- XalanTerminate();
+ XalanTerminate(int fCleanUpICU);
/**
* Create a XalanTransformer instance.
@@ -125,7 +144,11 @@
* @return the XalanTransformer handle
*/
XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanHandle)
+#if defined(__cplusplus)
CreateXalanTransformer();
+#else
+ CreateXalanTransformer(void);
+#endif
/**
* Delete a XalanTransformer instance.
@@ -388,7 +411,7 @@
* @return error message const character pointer.
*/
XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanCCharPtr)
- XalanGetLastError(XalanHandle theXalanHandle);
+ XalanGetLastError(XalanHandle theXalanHandle);
#if defined(__cplusplus)
}
1.60 +10 -0 xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp
Index: XalanTransformer.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- XalanTransformer.cpp 25 Aug 2002 16:05:37 -0000 1.59
+++ XalanTransformer.cpp 30 Aug 2002 23:58:54 -0000 1.60
@@ -248,6 +248,16 @@
+void
+XalanTransformer::ICUCleanUp()
+{
+#if defined(XALAN_USE_ICU)
+ ICUBridgeCleanup::cleanup();
+#endif
+}
+
+
+
static void
addTraceListeners(
const XalanTransformer::TraceListenerVectorType&
theTraceListeners,
1.42 +25 -2 xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp
Index: XalanTransformer.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- XalanTransformer.hpp 15 Aug 2002 04:40:51 -0000 1.41
+++ XalanTransformer.hpp 30 Aug 2002 23:58:55 -0000 1.42
@@ -121,19 +121,42 @@
/**
* Initialize Xalan.
+ *
* Should be called only once per process before creating any
- * instances of XalanTransformer. See class XSLTInit.
+ * instances of XalanTransformer.
*/
static void
initialize();
/**
* Terminate Xalan.
+ *
* Should be called only once per process after deleting all
- * instances of XalanTransformer. See class XSLTInit.
+ * instances of XalanTransformer.
+ *
+ * This is handy when using leak-detection software, as all
+ * static data allocated by Xalan is freed.
+ *
*/
static void
terminate();
+
+ /**
+ * Clean up the ICU, if ICU integration is enabled.
+ *
+ * This should be called only once per process after calling
+ * XalanTransformer::terminate() and XMLPlatformUtils::Terminate.
+ *
+ * This must only be done if the ICU will no longer be used by
+ * the process, since the ICU will no longer be in a usable state.
+ * See the ICU documentation for more details.
+ *
+ * This is handy when using leak-detection software, as all
+ * static data allocated by the ICU is freed.
+ *
+ */
+ static void
+ ICUCleanUp();
/**
* Transform will apply the stylesheet source to the parsed xml source
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]