[antlr-interest] Antlr3 C Runtime Improvement Patches
Bot Tiger
bottiger1 at gmail.com
Sat Jan 31 19:02:39 PST 2009
Here are some patches to get the antlr3 C runtime to compile as STDCALL.
Apparently strdup is also deprecated in recent versions of visual studio.
--- antlr3defs.h (revision 1)
+++ antlr3defs.h (revision 2)
@@ -458,7 +458,7 @@
/// Default definition of ANTLR3_STRDUP. You can override this before
including
/// antlr3.h if you wish to use your own implementation.
///
-#define ANTLR3_STRDUP(instr) (pANTLR3_UINT8)(strdup
((const char *)(instr)))
+#define ANTLR3_STRDUP(instr) (pANTLR3_UINT8)(_strdup
((const char *)(instr)))
--- antlr3rewritestreams.h (revision 1)
+++ antlr3rewritestreams.h (revision 2)
@@ -152,9 +152,9 @@
/// Returns the description string if there is one available (check for
NULL).
///
void * (*getDescription) (struct
ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct * stream);
+ void (ANTLR3_CDECL *free) (struct
ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct * stream);
- void (*free) (struct
ANTLR3_REWRITE_RULE_ELEMENT_STREAM_struct * stream);
--- antlr3rewritestreams.c (revision 1)
+++ antlr3rewritestreams.c (revision 2)
@@ -54,14 +54,14 @@
static pANTLR3_BASE_TREE nextNodeToken
(pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream);
static ANTLR3_UINT32 size
(pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream);
static void * getDescription
(pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream);
-static void freeRS
(pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream);
-static void expungeRS
(pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream);
+static void ANTLR3_CDECL freeRS
(pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream);
+static void ANTLR3_CDECL expungeRS
(pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream);
// Place a now unused rewrite stream back on the rewrite stream pool
// so we can reuse it if we need to.
//
-static void
+static void ANTLR3_CDECL
freeRS (pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
{
// Before placing the stream back in the pool, we
@@ -93,10 +93,10 @@
// adding the stream memory free routine so that
// it is thrown away when the stack vector is destroyed
//
- stream->rec->state->rStreams->add(stream->rec->state->rStreams, stream,
(void(*)(void *))expungeRS);
+ stream->rec->state->rStreams->add(stream->rec->state->rStreams, stream,
/*(void(*)(void *))*/ expungeRS);
}
-static void
+static void ANTLR3_CDECL
expungeRS(pANTLR3_REWRITE_RULE_ELEMENT_STREAM stream)
{
I think this is all. I didn't put the antlr lib under source control, so
when I made the diff I had to re-download the source, which appears to have
changed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090131/5688bee6/attachment.html
More information about the antlr-interest
mailing list