From: Fred L. Drake, Jr. Date: Fri, 27 Jul 2001 16:30:56 +0000 (+0000) Subject: Make sure that XMLPARSEAPI specifies the calling convention when building X-Git-Tag: R_1_95_2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58be86d815e99ee09db201ee9de40aa3a2a115b8;p=libexpat Make sure that XMLPARSEAPI specifies the calling convention when building under MSVC -- this is needed when using the pre-compiled DLL with projects built using a different calling convention. XMLPARSEAPI now takes the return type as a parameter and inserts annotations on both sides of the type to make sure the compiler is happy. A new macro, XMLCALLBACK, is used to perform similar annotation of the callback function types, which do not need the dllimport/dllexport annotations but do still need the __cdecl annotation. This closes SF bug #413653. --- diff --git a/expat/lib/expat.h.in b/expat/lib/expat.h.in index f5249057..8b220fef 100644 --- a/expat/lib/expat.h.in +++ b/expat/lib/expat.h.in @@ -10,9 +10,11 @@ See the file COPYING for copying permission. #ifndef XMLPARSEAPI # if defined(__declspec) && !defined(__BEOS__) -# define XMLPARSEAPI __declspec(dllimport) +# define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl +# define XMLCALLBACK(type) type __cdecl # else -# define XMLPARSEAPI /* nothing */ +# define XMLPARSEAPI(type) type +# define XMLCALLBACK(type) type # endif #endif /* not defined XMLPARSEAPI */ @@ -76,11 +78,11 @@ struct XML_cp { to free model when finished with it. */ -typedef void (*XML_ElementDeclHandler) (void *userData, - const XML_Char *name, - XML_Content *model); +typedef XMLCALLBACK(void) (*XML_ElementDeclHandler) (void *userData, + const XML_Char *name, + XML_Content *model); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl); @@ -94,14 +96,14 @@ XML_SetElementDeclHandler(XML_Parser parser, default is non-NULL, then this is a "#FIXED" default. */ -typedef void (*XML_AttlistDeclHandler) (void *userData, - const XML_Char *elname, - const XML_Char *attname, - const XML_Char *att_type, - const XML_Char *dflt, - int isrequired); +typedef XMLCALLBACK(void) (*XML_AttlistDeclHandler) (void *userData, + const XML_Char *elname, + const XML_Char *attname, + const XML_Char *att_type, + const XML_Char *dflt, + int isrequired); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl); @@ -114,12 +116,12 @@ XML_SetAttlistDeclHandler(XML_Parser parser, the declaration, that it was given as no, or that it was given as yes. */ -typedef void (*XML_XmlDeclHandler) (void *userData, - const XML_Char *version, - const XML_Char *encoding, - int standalone); +typedef XMLCALLBACK(void) (*XML_XmlDeclHandler) (void *userData, + const XML_Char *version, + const XML_Char *encoding, + int standalone); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl); @@ -133,7 +135,7 @@ typedef struct { /* Constructs a new parser; encoding is the encoding specified by the external protocol or null if there is none specified. */ -XMLPARSEAPI XML_Parser +XMLPARSEAPI(XML_Parser) XML_ParserCreate(const XML_Char *encoding); /* Constructs a new parser and namespace processor. Element type @@ -146,7 +148,7 @@ separator is '\0' then the namespace URI and the local part will be concatenated without any separator. When a namespace is not declared, the name and prefix will be passed through without expansion. */ -XMLPARSEAPI XML_Parser +XMLPARSEAPI(XML_Parser) XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); @@ -160,7 +162,7 @@ XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); the given suite. */ -XMLPARSEAPI XML_Parser +XMLPARSEAPI(XML_Parser) XML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, const XML_Char *namespaceSeparator); @@ -168,29 +170,29 @@ XML_ParserCreate_MM(const XML_Char *encoding, /* atts is array of name/value pairs, terminated by 0; names and values are 0 terminated. */ -typedef void (*XML_StartElementHandler)(void *userData, - const XML_Char *name, - const XML_Char **atts); +typedef XMLCALLBACK(void) (*XML_StartElementHandler)(void *userData, + const XML_Char *name, + const XML_Char **atts); -typedef void (*XML_EndElementHandler)(void *userData, - const XML_Char *name); +typedef XMLCALLBACK(void) (*XML_EndElementHandler)(void *userData, + const XML_Char *name); /* s is not 0 terminated. */ -typedef void (*XML_CharacterDataHandler)(void *userData, - const XML_Char *s, - int len); +typedef XMLCALLBACK(void) (*XML_CharacterDataHandler)(void *userData, + const XML_Char *s, + int len); /* target and data are 0 terminated */ -typedef void (*XML_ProcessingInstructionHandler)(void *userData, - const XML_Char *target, - const XML_Char *data); +typedef XMLCALLBACK(void) (*XML_ProcessingInstructionHandler)(void *userData, + const XML_Char *target, + const XML_Char *data); /* data is 0 terminated */ -typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data); +typedef XMLCALLBACK(void) (*XML_CommentHandler)(void *userData, const XML_Char *data); -typedef void (*XML_StartCdataSectionHandler)(void *userData); -typedef void (*XML_EndCdataSectionHandler)(void *userData); +typedef XMLCALLBACK(void) (*XML_StartCdataSectionHandler)(void *userData); +typedef XMLCALLBACK(void) (*XML_EndCdataSectionHandler)(void *userData); /* This is called for any characters in the XML document for which there is no applicable handler. This includes both @@ -205,23 +207,22 @@ There are no guarantees about how characters are divided between calls to the default handler: for example, a comment might be split between multiple calls. */ -typedef void (*XML_DefaultHandler)(void *userData, - const XML_Char *s, - int len); +typedef XMLCALLBACK(void) (*XML_DefaultHandler)(void *userData, + const XML_Char *s, + int len); /* This is called for the start of the DOCTYPE declaration, before any DTD or internal subset is parsed. */ -typedef void (*XML_StartDoctypeDeclHandler)(void *userData, - const XML_Char *doctypeName, - const XML_Char *sysid, - const XML_Char *pubid, - int has_internal_subset - ); +typedef XMLCALLBACK(void) (*XML_StartDoctypeDeclHandler)(void *userData, + const XML_Char *doctypeName, + const XML_Char *sysid, + const XML_Char *pubid, + int has_internal_subset); /* This is called for the start of the DOCTYPE declaration when the closing > is encountered, but after processing any external subset. */ -typedef void (*XML_EndDoctypeDeclHandler)(void *userData); +typedef XMLCALLBACK(void) (*XML_EndDoctypeDeclHandler)(void *userData); /* This is called for entity declarations. The is_parameter_entity argument will be non-zero if the entity is a parameter entity, zero @@ -239,17 +240,17 @@ typedef void (*XML_EndDoctypeDeclHandler)(void *userData); for unparsed entity declarations. */ -typedef void (*XML_EntityDeclHandler) (void *userData, - const XML_Char *entityName, - int is_parameter_entity, - const XML_Char *value, - int value_length, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); +typedef XMLCALLBACK(void) (*XML_EntityDeclHandler) (void *userData, + const XML_Char *entityName, + int is_parameter_entity, + const XML_Char *value, + int value_length, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId, + const XML_Char *notationName); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler); @@ -261,22 +262,22 @@ entity. The base argument is whatever was set by XML_SetBase. The entityName, systemId and notationName arguments will never be null. The other arguments may be. */ -typedef void (*XML_UnparsedEntityDeclHandler)(void *userData, - const XML_Char *entityName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); +typedef XMLCALLBACK(void) (*XML_UnparsedEntityDeclHandler)(void *userData, + const XML_Char *entityName, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId, + const XML_Char *notationName); /* This is called for a declaration of notation. The base argument is whatever was set by XML_SetBase. The notationName will never be null. The other arguments can be. */ -typedef void (*XML_NotationDeclHandler)(void *userData, - const XML_Char *notationName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); +typedef XMLCALLBACK(void) (*XML_NotationDeclHandler)(void *userData, + const XML_Char *notationName, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId); /* When namespace processing is enabled, these are called once for each namespace declaration. The call to the start and end element @@ -284,12 +285,12 @@ handlers occur between the calls to the start and end namespace declaration handlers. For an xmlns attribute, prefix will be null. For an xmlns="" attribute, uri will be null. */ -typedef void (*XML_StartNamespaceDeclHandler)(void *userData, - const XML_Char *prefix, - const XML_Char *uri); +typedef XMLCALLBACK(void) (*XML_StartNamespaceDeclHandler)(void *userData, + const XML_Char *prefix, + const XML_Char *uri); -typedef void (*XML_EndNamespaceDeclHandler)(void *userData, - const XML_Char *prefix); +typedef XMLCALLBACK(void) (*XML_EndNamespaceDeclHandler)(void *userData, + const XML_Char *prefix); /* This is called if the document is not standalone (it has an external subset or a reference to a parameter entity, but does not @@ -297,7 +298,7 @@ have standalone="yes"). If this handler returns 0, then processing will not continue, and the parser will return a XML_ERROR_NOT_STANDALONE error. */ -typedef int (*XML_NotStandaloneHandler)(void *userData); +typedef XMLCALLBACK(int) (*XML_NotStandaloneHandler)(void *userData); /* This is called for a reference to an external parsed general entity. The referenced entity is not automatically parsed. @@ -324,11 +325,11 @@ XML_ERROR_EXTERNAL_ENTITY_HANDLING error. Note that unlike other handlers the first argument is the parser, not userData. */ -typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser, - const XML_Char *context, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); +typedef XMLCALLBACK(int) (*XML_ExternalEntityRefHandler)(XML_Parser parser, + const XML_Char *context, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId); /* This structure is filled in by the XML_UnknownEncodingHandler to provide information to the parser about encodings that are unknown @@ -364,10 +365,10 @@ same byte that represents that character in ASCII. 2. No character may require more than 4 bytes to encode. -3. All characters encoded must have Unicode scalar values <= 0xFFFF, -(ie characters that would be encoded by surrogates in UTF-16 -are not allowed). Note that this restriction doesn't apply to -the built-in support for UTF-8 and UTF-16. +3. All characters encoded must have Unicode scalar values <= 0xFFFF, (i.e., +characters that would be encoded by surrogates in UTF-16 are not +allowed). Note that this restriction doesn't apply to the built-in +support for UTF-8 and UTF-16. 4. No Unicode character may be encoded by more than one distinct sequence of bytes. */ @@ -390,42 +391,42 @@ Otherwise it must return 0. If info does not describe a suitable encoding, then the parser will return an XML_UNKNOWN_ENCODING error. */ -typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData, - const XML_Char *name, - XML_Encoding *info); +typedef XMLCALLBACK(int) (*XML_UnknownEncodingHandler)(void *encodingHandlerData, + const XML_Char *name, + XML_Encoding *info); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, XML_EndElementHandler end); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetCharacterDataHandler(XML_Parser parser, XML_CharacterDataHandler handler); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetProcessingInstructionHandler(XML_Parser parser, XML_ProcessingInstructionHandler handler); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetCdataSectionHandler(XML_Parser parser, XML_StartCdataSectionHandler start, XML_EndCdataSectionHandler end); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetStartCdataSectionHandler(XML_Parser parser, XML_StartCdataSectionHandler start); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetEndCdataSectionHandler(XML_Parser parser, XML_EndCdataSectionHandler end); @@ -433,7 +434,7 @@ XML_SetEndCdataSectionHandler(XML_Parser parser, internal entities. The entity reference will be passed to the default handler. */ -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler); @@ -441,59 +442,59 @@ XML_SetDefaultHandler(XML_Parser parser, internal entities. The entity reference will not be passed to the default handler. */ -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start, XML_EndDoctypeDeclHandler end); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetStartDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetUnparsedEntityDeclHandler(XML_Parser parser, XML_UnparsedEntityDeclHandler handler); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetNamespaceDeclHandler(XML_Parser parser, XML_StartNamespaceDeclHandler start, XML_EndNamespaceDeclHandler end); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetStartNamespaceDeclHandler(XML_Parser parser, XML_StartNamespaceDeclHandler start); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetEndNamespaceDeclHandler(XML_Parser parser, XML_EndNamespaceDeclHandler end); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetNotStandaloneHandler(XML_Parser parser, XML_NotStandaloneHandler handler); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetExternalEntityRefHandler(XML_Parser parser, XML_ExternalEntityRefHandler handler); /* If a non-null value for arg is specified here, then it will be passed as the first argument to the external entity ref handler instead of the parser object. */ -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg); -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetUnknownEncodingHandler(XML_Parser parser, XML_UnknownEncodingHandler handler, void *encodingHandlerData); @@ -501,7 +502,7 @@ XML_SetUnknownEncodingHandler(XML_Parser parser, /* This can be called within a handler for a start element, end element, processing instruction or character data. It causes the corresponding markup to be passed to the default handler. */ -XMLPARSEAPI void +XMLPARSEAPI(void) XML_DefaultCurrent(XML_Parser parser); /* If do_nst is non-zero, and namespace processing is in effect, and @@ -515,11 +516,11 @@ XML_DefaultCurrent(XML_Parser parser); has a prefix. */ -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); /* This value is passed as the userData argument to callbacks. */ -XMLPARSEAPI void +XMLPARSEAPI(void) XML_SetUserData(XML_Parser parser, void *userData); /* Returns the last value set by XML_SetUserData or null. */ @@ -529,14 +530,14 @@ XML_SetUserData(XML_Parser parser, void *userData); to XML_ParserCreate. It must not be called after XML_Parse or XML_ParseBuffer. */ -XMLPARSEAPI int +XMLPARSEAPI(int) XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); /* If this function is called, then the parser will be passed as the first argument to callbacks instead of userData. The userData will still be accessible using XML_GetUserData. */ -void XMLPARSEAPI +XMLPARSEAPI(void) XML_UseParserAsHandlerArg(XML_Parser parser); /* Sets the base to be used for resolving relative URIs in system @@ -546,10 +547,10 @@ argument to the XML_ExternalEntityRefHandler, XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base argument will be copied. Returns zero if out of memory, non-zero otherwise. */ -XMLPARSEAPI int +XMLPARSEAPI(int) XML_SetBase(XML_Parser parser, const XML_Char *base); -XMLPARSEAPI const XML_Char * +XMLPARSEAPI(const XML_Char *) XML_GetBase(XML_Parser parser); /* Returns the number of the attribute/value pairs passed in last call @@ -558,7 +559,7 @@ rather than defaulted. Each attribute/value pair counts as 2; thus this correspondds to an index into the atts array passed to the XML_StartElementHandler. */ -XMLPARSEAPI int +XMLPARSEAPI(int) XML_GetSpecifiedAttributeCount(XML_Parser parser); /* Returns the index of the ID attribute passed in the last call to @@ -566,19 +567,19 @@ XML_StartElementHandler, or -1 if there is no ID attribute. Each attribute/value pair counts as 2; thus this correspondds to an index into the atts array passed to the XML_StartElementHandler. */ -XMLPARSEAPI int +XMLPARSEAPI(int) XML_GetIdAttributeIndex(XML_Parser parser); /* Parses some input. Returns 0 if a fatal error is detected. The last call to XML_Parse must have isFinal true; len may be zero for this call (or any other). */ -XMLPARSEAPI int +XMLPARSEAPI(int) XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); -XMLPARSEAPI void * +XMLPARSEAPI(void *) XML_GetBuffer(XML_Parser parser, int len); -XMLPARSEAPI int +XMLPARSEAPI(int) XML_ParseBuffer(XML_Parser parser, int len, int isFinal); /* Creates an XML_Parser object that can parse an external general @@ -596,7 +597,7 @@ freed. The new parser is completely independent and may safely be used in a separate thread. The handlers and userData are initialized from the parser argument. Returns 0 if out of memory. Otherwise returns a new XML_Parser object. */ -XMLPARSEAPI XML_Parser +XMLPARSEAPI(XML_Parser) XML_ExternalEntityParserCreate(XML_Parser parser, const XML_Char *context, const XML_Char *encoding); @@ -626,7 +627,7 @@ parsing (ie without XML_DTD being defined), then XML_SetParamEntityParsing will return 0 if parsing of parameter entities is requested; otherwise it will return non-zero. */ -XMLPARSEAPI int +XMLPARSEAPI(int) XML_SetParamEntityParsing(XML_Parser parser, enum XML_ParamEntityParsing parsing); @@ -660,7 +661,7 @@ enum XML_Error { /* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode returns information about the error. */ -XMLPARSEAPI enum XML_Error +XMLPARSEAPI(enum XML_Error) XML_GetErrorCode(XML_Parser parser); /* These functions return information about the current parse location. @@ -671,14 +672,14 @@ They may also be called from any other callback called to report some parse event; in this the location is the location of the first of the sequence of characters that generated the event. */ -int XMLPARSEAPI XML_GetCurrentLineNumber(XML_Parser parser); -int XMLPARSEAPI XML_GetCurrentColumnNumber(XML_Parser parser); -long XMLPARSEAPI XML_GetCurrentByteIndex(XML_Parser parser); +XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser); +XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser); +XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser); /* Return the number of bytes in the current event. Returns 0 if the event is in an internal entity. */ -XMLPARSEAPI int +XMLPARSEAPI(int) XML_GetCurrentByteCount(XML_Parser parser); /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets @@ -691,7 +692,7 @@ XML_GetCurrentByteCount(XML_Parser parser); NOTE: The character pointer returned should not be used outside the handler that makes the call. */ -XMLPARSEAPI const char * +XMLPARSEAPI(const char *) XML_GetInputContext(XML_Parser parser, int *offset, int *size); @@ -702,15 +703,15 @@ XML_GetInputContext(XML_Parser parser, #define XML_GetErrorByteIndex XML_GetCurrentByteIndex /* Frees memory used by the parser. */ -XMLPARSEAPI void +XMLPARSEAPI(void) XML_ParserFree(XML_Parser parser); /* Returns a string describing the error. */ -XMLPARSEAPI const XML_LChar * +XMLPARSEAPI(const XML_LChar *) XML_ErrorString(int code); /* Return a string containing the version number of this expat */ -XMLPARSEAPI const XML_LChar * +XMLPARSEAPI(const XML_LChar *) XML_ExpatVersion(void); typedef struct { @@ -722,7 +723,7 @@ typedef struct { /* Return an XML_Expat_Version structure containing numeric version number information for this version of expat */ -XMLPARSEAPI XML_Expat_Version +XMLPARSEAPI(XML_Expat_Version) XML_ExpatVersionInfo(void); #define XML_MAJOR_VERSION @EXPAT_MAJOR_VERSION@ diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index cb65d804..f1d98515 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -5,20 +5,24 @@ See the file COPYING for copying permission. #ifdef COMPILED_FROM_DSP # include "winconfig.h" -# define XMLPARSEAPI __declspec(dllexport) +# define XMLPARSEAPI(type) __declspec(dllexport) type __cdecl +# define XMLCALLBACK(type) type __cdecl # include "expat.h" # undef XMLPARSEAPI +# undef XMLCALLBACK #else #include #ifdef __declspec -# define XMLPARSEAPI __declspec(dllexport) +# define XMLPARSEAPI(type) __declspec(dllexport) type __cdecl +# define XMLCALLBACK(type) type __cdecl #endif #include "expat.h" #ifdef __declspec # undef XMLPARSEAPI +# undef XMLCALLBACK #endif #endif /* ndef COMPILED_FROM_DSP */