Commit 6d1c465f authored by Veaceslav Munteanu's avatar Veaceslav Munteanu
Browse files

Add namespace DngXmlSdk to XMP sources, except client glue

parent be386c4f
......@@ -11,19 +11,22 @@
#include "XMPIterator.hpp"
#include "client-glue/WXMPIterator.hpp"
#if XMP_WinBuild
#pragma warning ( disable : 4101 ) // unreferenced local variable
#pragma warning ( disable : 4189 ) // local variable is initialized but not referenced
#pragma warning ( disable : 4800 ) // forcing value to bool 'true' or 'false' (performance warning)
#if XMP_DebugBuild
#pragma warning ( disable : 4297 ) // function assumed not to throw an exception but does
#endif
#pragma warning ( disable : 4101 ) // unreferenced local variable
#pragma warning ( disable : 4189 ) // local variable is initialized but not referenced
#pragma warning ( disable : 4800 ) // forcing value to bool 'true' or 'false' (performance warning)
#if XMP_DebugBuild
#pragma warning ( disable : 4297 ) // function assumed not to throw an exception but does
#endif
#endif
#if __cplusplus
extern "C" {
#endif
namespace DngXmpSdk {
// =================================================================================================
// CTor/DTor Wrappers
// ==================
......@@ -37,14 +40,14 @@ WXMPIterator_PropCTor_1 ( XMPMetaRef xmpRef,
{
XMP_ENTER_WRAPPER ( "WXMPIterator_PropCTor_1" )
if ( schemaNS == 0 ) schemaNS = "";
if ( propName == 0 ) propName = "";
if ( schemaNS == 0 ) schemaNS = "";
if ( propName == 0 ) propName = "";
const XMPMeta & xmpObj = WtoXMPMeta_Ref ( xmpRef );
XMPIterator * iter = new XMPIterator ( xmpObj, schemaNS, propName, options );
++iter->clientRefs;
XMP_Assert ( iter->clientRefs == 1 );
wResult->ptrResult = XMPIteratorRef ( iter );
const XMPMeta & xmpObj = WtoXMPMeta_Ref ( xmpRef );
XMPIterator * iter = new XMPIterator ( xmpObj, schemaNS, propName, options );
++iter->clientRefs;
XMP_Assert ( iter->clientRefs == 1 );
wResult->ptrResult = XMPIteratorRef ( iter );
XMP_EXIT_WRAPPER
}
......@@ -59,13 +62,13 @@ WXMPIterator_TableCTor_1 ( XMP_StringPtr schemaNS,
{
XMP_ENTER_WRAPPER ( "WXMPIterator_TableCTor_1" )
if ( schemaNS == 0 ) schemaNS = "";
if ( propName == 0 ) propName = "";
if ( schemaNS == 0 ) schemaNS = "";
if ( propName == 0 ) propName = "";
XMPIterator * iter = new XMPIterator ( schemaNS, propName, options );
++iter->clientRefs;
XMP_Assert ( iter->clientRefs == 1 );
wResult->ptrResult = XMPIteratorRef ( iter );
XMPIterator * iter = new XMPIterator ( schemaNS, propName, options );
++iter->clientRefs;
XMP_Assert ( iter->clientRefs == 1 );
wResult->ptrResult = XMPIteratorRef ( iter );
XMP_EXIT_WRAPPER
}
......@@ -75,15 +78,15 @@ WXMPIterator_TableCTor_1 ( XMP_StringPtr schemaNS,
void
WXMPIterator_IncrementRefCount_1 ( XMPIteratorRef iterRef )
{
WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro.
XMP_ENTER_WRAPPER ( "WXMPIterator_IncrementRefCount_1" )
WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro.
XMP_ENTER_WRAPPER ( "WXMPIterator_IncrementRefCount_1" )
XMPIterator * thiz = (XMPIterator*)iterRef;
++thiz->clientRefs;
XMP_Assert ( thiz->clientRefs > 1 );
XMPIterator * thiz = (XMPIterator*)iterRef;
XMP_EXIT_WRAPPER_NO_THROW
++thiz->clientRefs;
XMP_Assert ( thiz->clientRefs > 1 );
XMP_EXIT_WRAPPER_NO_THROW
}
// -------------------------------------------------------------------------------------------------
......@@ -91,16 +94,16 @@ WXMPIterator_IncrementRefCount_1 ( XMPIteratorRef iterRef )
void
WXMPIterator_DecrementRefCount_1 ( XMPIteratorRef iterRef )
{
WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro.
XMP_ENTER_WRAPPER ( "WXMPIterator_DecrementRefCount_1" )
WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro.
XMP_ENTER_WRAPPER ( "WXMPIterator_DecrementRefCount_1" )
XMPIterator * thiz = (XMPIterator*)iterRef;
XMP_Assert ( thiz->clientRefs > 0 );
--thiz->clientRefs;
if ( thiz->clientRefs <= 0 ) delete ( thiz );
XMPIterator * thiz = (XMPIterator*)iterRef;
XMP_EXIT_WRAPPER_NO_THROW
XMP_Assert ( thiz->clientRefs > 0 );
--thiz->clientRefs;
if ( thiz->clientRefs <= 0 ) delete ( thiz );
XMP_EXIT_WRAPPER_NO_THROW
}
// -------------------------------------------------------------------------------------------------
......@@ -108,10 +111,10 @@ WXMPIterator_DecrementRefCount_1 ( XMPIteratorRef iterRef )
void
WXMPIterator_Unlock_1 ( XMP_OptionBits options )
{
WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro.
WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro.
XMP_ENTER_WRAPPER_NO_LOCK ( "WXMPIterator_Unlock_1" )
XMPIterator::Unlock ( options );
XMPIterator::Unlock ( options );
XMP_EXIT_WRAPPER_NO_THROW
}
......@@ -133,17 +136,17 @@ WXMPIterator_Next_1 ( XMPIteratorRef iterRef,
{
XMP_ENTER_WRAPPER ( "WXMPIterator_Next_1" )
if ( schemaNS == 0 ) schemaNS = &voidStringPtr;
if ( nsSize == 0 ) nsSize = &voidStringLen;
if ( propPath == 0 ) propPath = &voidStringPtr;
if ( pathSize == 0 ) pathSize = &voidStringLen;
if ( propValue == 0 ) propValue = &voidStringPtr;
if ( valueSize == 0 ) valueSize = &voidStringLen;
if ( propOptions == 0 ) propOptions = &voidOptionBits;
if ( schemaNS == 0 ) schemaNS = &voidStringPtr;
if ( nsSize == 0 ) nsSize = &voidStringLen;
if ( propPath == 0 ) propPath = &voidStringPtr;
if ( pathSize == 0 ) pathSize = &voidStringLen;
if ( propValue == 0 ) propValue = &voidStringPtr;
if ( valueSize == 0 ) valueSize = &voidStringLen;
if ( propOptions == 0 ) propOptions = &voidOptionBits;
XMPIterator * iter = WtoXMPIterator_Ptr ( iterRef );
XMP_Bool found = iter->Next ( schemaNS, nsSize, propPath, pathSize, propValue, valueSize, propOptions );
wResult->int32Result = found;
XMPIterator * iter = WtoXMPIterator_Ptr ( iterRef );
XMP_Bool found = iter->Next ( schemaNS, nsSize, propPath, pathSize, propValue, valueSize, propOptions );
wResult->int32Result = found;
XMP_EXIT_WRAPPER_KEEP_LOCK ( found )
}
......@@ -157,8 +160,8 @@ WXMPIterator_Skip_1 ( XMPIteratorRef iterRef,
{
XMP_ENTER_WRAPPER ( "WXMPIterator_Skip_1" )
XMPIterator * iter = WtoXMPIterator_Ptr ( iterRef );
iter->Skip ( options );
XMPIterator * iter = WtoXMPIterator_Ptr ( iterRef );
iter->Skip ( options );
XMP_EXIT_WRAPPER
}
......@@ -169,17 +172,20 @@ void
WXMPUtils_UnlockIter_1 ( XMPIteratorRef iterRef,
XMP_OptionBits options )
{
WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro.
WXMP_Result * wResult = &void_wResult; // ! Needed to "fool" the EnterWrapper macro.
XMP_ENTER_WRAPPER_NO_LOCK ( "WXMPUtils_UnlockIter_1" )
XMPIterator * iter = WtoXMPIterator_Ptr ( iterRef );
iter->UnlockIter ( options );
XMPIterator * iter = WtoXMPIterator_Ptr ( iterRef );
iter->UnlockIter ( options );
XMP_EXIT_WRAPPER_NO_THROW
}
// =================================================================================================
#if __cplusplus
} /* extern "C" */
#endif
} // namespace DngXmpSdk
......@@ -15,6 +15,7 @@
// =================================================================================================
namespace DngXmpSdk {
struct IterNode;
typedef std::vector < IterNode > IterOffspring;
typedef IterOffspring::iterator IterPos;
......@@ -23,66 +24,66 @@ typedef std::pair < IterPos, IterPos > IterPosPair;
typedef std::vector < IterPosPair > IterPosStack;
enum { // Values for the visitStage field, used to decide how to proceed past a node.
kIter_BeforeVisit = 0, // Have not visited this node at all.
kIter_VisitSelf = 1, // Have visited this node and returned its value/options portion.
kIter_VisitQualifiers = 2, // In the midst of visiting this node's qualifiers.
kIter_VisitChildren = 3 // In the midst of visiting this node's children.
kIter_BeforeVisit = 0, // Have not visited this node at all.
kIter_VisitSelf = 1, // Have visited this node and returned its value/options portion.
kIter_VisitQualifiers = 2, // In the midst of visiting this node's qualifiers.
kIter_VisitChildren = 3 // In the midst of visiting this node's children.
};
struct IterNode {
XMP_OptionBits options;
XMP_VarString fullPath;
size_t leafOffset;
IterOffspring children, qualifiers;
XMP_Uns8 visitStage;
#if 0 // *** XMP_DebugBuild
XMP_StringPtr _pathPtr, _leafPtr; // *** Not working, need operator=?
#endif
IterNode() : options(0), leafOffset(0), visitStage(kIter_BeforeVisit)
{
#if 0 // *** XMP_DebugBuild
_pathPtr = _leafPtr = 0;
#endif
};
IterNode ( XMP_OptionBits _options, const XMP_VarString& _fullPath, size_t _leafOffset )
: options(_options), fullPath(_fullPath), leafOffset(_leafOffset), visitStage(kIter_BeforeVisit)
{
#if 0 // *** XMP_DebugBuild
_pathPtr = fullPath.c_str();
_leafPtr = _pathPtr + leafOffset;
#endif
};
XMP_OptionBits options;
XMP_VarString fullPath;
size_t leafOffset;
IterOffspring children, qualifiers;
XMP_Uns8 visitStage;
#if 0 // *** XMP_DebugBuild
XMP_StringPtr _pathPtr, _leafPtr; // *** Not working, need operator=?
#endif
IterNode() : options(0), leafOffset(0), visitStage(kIter_BeforeVisit)
{
#if 0 // *** XMP_DebugBuild
_pathPtr = _leafPtr = 0;
#endif
};
IterNode ( XMP_OptionBits _options, const XMP_VarString& _fullPath, size_t _leafOffset )
: options(_options), fullPath(_fullPath), leafOffset(_leafOffset), visitStage(kIter_BeforeVisit)
{
#if 0 // *** XMP_DebugBuild
_pathPtr = fullPath.c_str();
_leafPtr = _pathPtr + leafOffset;
#endif
};
};
struct IterInfo {
XMP_OptionBits options;
const XMPMeta * xmpObj;
XMP_VarString currSchema;
IterPos currPos, endPos;
IterPosStack ancestors;
IterNode tree;
#if 0 // *** XMP_DebugBuild
XMP_StringPtr _schemaPtr; // *** Not working, need operator=?
#endif
IterInfo() : options(0), xmpObj(0)
{
#if 0 // *** XMP_DebugBuild
_schemaPtr = 0;
#endif
};
IterInfo ( XMP_OptionBits _options, const XMPMeta * _xmpObj ) : options(_options), xmpObj(_xmpObj)
{
#if 0 // *** XMP_DebugBuild
_schemaPtr = 0;
#endif
};
XMP_OptionBits options;
const XMPMeta * xmpObj;
XMP_VarString currSchema;
IterPos currPos, endPos;
IterPosStack ancestors;
IterNode tree;
#if 0 // *** XMP_DebugBuild
XMP_StringPtr _schemaPtr; // *** Not working, need operator=?
#endif
IterInfo() : options(0), xmpObj(0)
{
#if 0 // *** XMP_DebugBuild
_schemaPtr = 0;
#endif
};
IterInfo ( XMP_OptionBits _options, const XMPMeta * _xmpObj ) : options(_options), xmpObj(_xmpObj)
{
#if 0 // *** XMP_DebugBuild
_schemaPtr = 0;
#endif
};
};
......@@ -90,59 +91,60 @@ struct IterInfo {
class XMPIterator {
public:
static bool
Initialize(); // ! For internal use only!
static void
Terminate() RELEASE_NO_THROW; // ! For internal use only!
static void
Unlock ( XMP_OptionBits options );
static bool
Initialize(); // ! For internal use only!
XMPIterator ( const XMPMeta & xmpObj, // Construct a property iterator.
XMP_StringPtr schemaNS,
XMP_StringPtr propName,
XMP_OptionBits options );
static void
Terminate() RELEASE_NO_THROW; // ! For internal use only!
XMPIterator ( XMP_StringPtr schemaNS, // Construct a table iterator.
XMP_StringPtr propName,
XMP_OptionBits options );
static void
Unlock ( XMP_OptionBits options );
virtual ~XMPIterator() RELEASE_NO_THROW;
XMPIterator ( const XMPMeta & xmpObj, // Construct a property iterator.
XMP_StringPtr schemaNS,
XMP_StringPtr propName,
XMP_OptionBits options );
bool
Next ( XMP_StringPtr * schemaNS,
XMP_StringLen * nsSize,
XMP_StringPtr * propPath,
XMP_StringLen * pathSize,
XMP_StringPtr * propValue,
XMP_StringLen * valueSize,
XMP_OptionBits * propOptions );
XMPIterator ( XMP_StringPtr schemaNS, // Construct a table iterator.
XMP_StringPtr propName,
XMP_OptionBits options );
void
Skip ( XMP_OptionBits options );
virtual ~XMPIterator() RELEASE_NO_THROW;
void
UnlockIter ( XMP_OptionBits options );
bool
Next ( XMP_StringPtr * schemaNS,
XMP_StringLen * nsSize,
XMP_StringPtr * propPath,
XMP_StringLen * pathSize,
XMP_StringPtr * propValue,
XMP_StringLen * valueSize,
XMP_OptionBits * propOptions );
// ! Expose so that wrappers and file static functions can see the data.
void
Skip ( XMP_OptionBits options );
XMP_Int32 clientRefs; // ! Must be signed to allow decrement from 0.
IterInfo info;
void
UnlockIter ( XMP_OptionBits options );
// ! Expose so that wrappers and file static functions can see the data.
XMP_Int32 clientRefs; // ! Must be signed to allow decrement from 0.
IterInfo info;
private:
// ! These are hidden on purpose:
XMPIterator() : clientRefs(0)
{ XMP_Throw ( "Call to hidden constructor", kXMPErr_InternalFailure ); };
XMPIterator ( const XMPIterator & /* original */ ) : clientRefs(0)
{ XMP_Throw ( "Call to hidden constructor", kXMPErr_InternalFailure ); };
void operator= ( const XMPIterator & /* rhs */ )
{ XMP_Throw ( "Call to hidden operator=", kXMPErr_InternalFailure ); };
// ! These are hidden on purpose:
XMPIterator() : clientRefs(0)
{ XMP_Throw ( "Call to hidden constructor", kXMPErr_InternalFailure ); };
XMPIterator ( const XMPIterator & /* original */ ) : clientRefs(0)
{ XMP_Throw ( "Call to hidden constructor", kXMPErr_InternalFailure ); };
void operator= ( const XMPIterator & /* rhs */ )
{ XMP_Throw ( "Call to hidden operator=", kXMPErr_InternalFailure ); };
};
// =================================================================================================
} // namespace DngXmpSdk
#endif // __XMPIterator_hpp__
......@@ -17,7 +17,7 @@
// *** May want to improve with PowerPC swapping load/store, or SSE instructions.
// =================================================================================================
namespace DngXmpSdk {
#define kLittleEndianHost (! kBigEndianHost)
#if XMP_WinBuild
#pragma warning ( disable : 4127 ) // conditional expression is constant
......@@ -417,5 +417,6 @@ PutDoubleLE ( double value, void * addr )
}
// =================================================================================================
} //namespace
#endif // __EndianUtils_hpp__
......@@ -15,36 +15,38 @@
// =================================================================================================
// Derived XML parser adapter for Expat.
// =================================================================================================
struct XML_ParserStruct; // ! Hack to avoid exposing expat.h to all clients.
typedef struct XML_ParserStruct *XML_Parser;
namespace DngXmpSdk {
#ifndef BanAllEntityUsage
#define BanAllEntityUsage 0
#define BanAllEntityUsage 0
#endif
struct XML_ParserStruct; // ! Hack to avoid exposing expat.h to all clients.
typedef struct XML_ParserStruct *XML_Parser;
class ExpatAdapter : public XMLParserAdapter {
public:
XML_Parser parser;
#if BanAllEntityUsage
bool isAborted;
#endif
#if XMP_DebugBuild
size_t elemNesting;
#endif
ExpatAdapter();
virtual ~ExpatAdapter();
void ParseBuffer ( const void * buffer, size_t length, bool last = true );
XML_Parser parser;
#if BanAllEntityUsage
bool isAborted;
#endif
#if XMP_DebugBuild
size_t elemNesting;
#endif
ExpatAdapter();
virtual ~ExpatAdapter();
void ParseBuffer ( const void * buffer, size_t length, bool last = true );
};
extern "C" ExpatAdapter * XMP_NewExpatAdapter();
// =================================================================================================
} //namespace
#endif // __ExpatAdapter_hpp__
......@@ -22,6 +22,7 @@
using namespace std;
namespace DngXmpSdk {
// =================================================================================================
// *** Look into using asm inlines, e.g. count-leading bits for multi-byte UTF-8.
......@@ -1662,4 +1663,5 @@ Done: // Set the output lengths.
} // UTF32Swp_to_UTF16Nat
} //namespace
// =================================================================================================
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment