Re: [xml] Handling MSVC exports (was Release of libxml2-2.4.21)
- From: Aleksey Sanin <aleksey aleksey com>
- To: Igor Zlatkovic <igor stud fh-frankfurt de>
- Cc: "Vakoc Mark" <Mark_Vakoc jdedwards com>, xml gnome org
- Subject: Re: [xml] Handling MSVC exports (was Release of libxml2-2.4.21)
- Date: Thu, 02 May 2002 11:28:22 -0700
Well, I also have something: please find attached a simple perl script
that processes *.c files and strips out all preprocessor commands,
non-static functions and non-static variables. I also attached an
example of
processing tree.c file from LibXML.
It is not a "final" *.def.src file but I think it's pretty simple to
make one now
(sorry, I am not familiar enough with *.def files to do it myself).
With best regards,
Aleksey.
Igor Zlatkovic wrote:
Hi there,
I do. /Zg reports the static keyword, so those functions can be filtered
out.
What is more important a flaw, it would not export variables. In the
default configuration, xmlFree is a pointer to a function and pointers
are variables.
Yes but all exported variables are already declared as LIBXML_DLL_IMPORT.
A
simple change to the definition of that to be __declspec(dllimport) when
building against libxml2, and __declspec(dllexport) when building libxml2
takes care of the variables. No .def.src needed.
Ehemm... indeed! I wonder... am I the only one who sometimes seeks for a
solution, fails, and then feels dumb down to the iron when someone else
presents a simple one? Now, that you presented it, it sounds simple enough
so that I cannot escape the impression that I should have seen it myself
earlier :-) :-)
Mark, you have my respect and please receive my thanks. I'll check this
right away and I owe you a pint should we oneday happen to be in the same
town at the same time.
Ciao
Igor
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
/**** start of file: tree.c ****/
#define IN_LIBXML
#include "libxml.h"
#include <string.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/uri.h>
#include <libxml/entities.h>
#include <libxml/valid.h>
#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
#include <libxml/globals.h>
function: xmlNewReconciliedNs
variable: xmlStringText
variable: xmlStringTextNoenc
variable: xmlStringComment
#define UPDATE_LAST_CHILD_AND_PARENT(n) if ((n) != NULL) { \
xmlNodePtr ulccur = (n)->children; \
if (ulccur == NULL) { \
(n)->last = NULL; \
} else { \
while (ulccur->next != NULL) { \
ulccur->parent = (n); \
ulccur = ulccur->next; \
} \
ulccur->parent = (n); \
(n)->last = ulccur; \
}}
#include <libxml/hash.h>
function: xmlSetBufferAllocationScheme
function: xmlGetBufferAllocationScheme
function: xmlNewNs
function: xmlSetNs
#ifdef DEBUG_TREE
#endif
function: xmlFreeNs
#ifdef DEBUG_TREE
#endif
function: xmlFreeNsList
#ifdef DEBUG_TREE
#endif
function: xmlNewDtd
#ifdef DEBUG_TREE
#endif
function: xmlGetIntSubset
function: xmlCreateIntSubset
#ifdef DEBUG_TREE
#endif
function: xmlFreeDtd
#ifdef DEBUG_TREE
#endif
function: xmlNewDoc
function: xmlFreeDoc
#ifdef DEBUG_TREE
#endif
function: xmlStringLenGetNodeList
#ifdef DEBUG_TREE
#endif
function: xmlStringGetNodeList
#ifdef DEBUG_TREE
#endif
function: xmlNodeListGetString
#if 0
#endif
function: xmlNodeListGetRawString
#if 0
#endif
function: xmlNewProp
#ifdef DEBUG_TREE
#endif
function: xmlNewNsProp
#ifdef DEBUG_TREE
#endif
function: xmlNewDocProp
#ifdef DEBUG_TREE
#endif
function: xmlFreePropList
#ifdef DEBUG_TREE
#endif
function: xmlFreeProp
#ifdef DEBUG_TREE
#endif
function: xmlRemoveProp
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlNewPI
#ifdef DEBUG_TREE
#endif
function: xmlNewNode
#ifdef DEBUG_TREE
#endif
function: xmlNewDocNode
function: xmlNewDocRawNode
function: xmlNewDocFragment
function: xmlNewText
function: xmlNewTextChild
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlNewCharRef
function: xmlNewReference
function: xmlNewDocText
function: xmlNewTextLen
function: xmlNewDocTextLen
function: xmlNewComment
function: xmlNewCDataBlock
function: xmlNewDocComment
function: xmlSetTreeDoc
function: xmlSetListDoc
function: xmlNewChild
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlAddNextSibling
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlAddPrevSibling
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlAddSibling
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlAddChildList
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlAddChild
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlGetLastChild
#ifdef DEBUG_TREE
#endif
function: xmlFreeNodeList
#ifdef DEBUG_TREE
#endif
function: xmlFreeNode
#ifdef DEBUG_TREE
#endif
function: xmlUnlinkNode
#ifdef DEBUG_TREE
#endif
function: xmlReplaceNode
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlCopyNamespace
#ifdef DEBUG_TREE
#endif
function: xmlCopyNamespaceList
function: xmlCopyProp
function: xmlCopyPropList
#ifdef LIBXML_DOCB_ENABLED
#endif
function: xmlCopyNode
function: xmlDocCopyNode
function: xmlCopyNodeList
function: xmlCopyDtd
function: xmlCopyDoc
function: xmlGetLineNo
function: xmlGetNodePath
function: xmlDocGetRootElement
function: xmlDocSetRootElement
function: xmlNodeSetLang
#ifdef LIBXML_DOCB_ENABLED
#endif
function: xmlNodeGetLang
function: xmlNodeSetSpacePreserve
#ifdef LIBXML_DOCB_ENABLED
#endif
function: xmlNodeGetSpacePreserve
function: xmlNodeSetName
#ifdef LIBXML_DOCB_ENABLED
#endif
function: xmlNodeSetBase
#ifdef LIBXML_DOCB_ENABLED
#endif
function: xmlNodeGetBase
function: xmlNodeGetContent
#ifdef LIBXML_DOCB_ENABLED
#endif
function: xmlNodeSetContent
#ifdef DEBUG_TREE
#endif
#ifdef LIBXML_DOCB_ENABLED
#endif
function: xmlNodeSetContentLen
#ifdef DEBUG_TREE
#endif
#ifdef LIBXML_DOCB_ENABLED
#endif
function: xmlNodeAddContentLen
#ifdef DEBUG_TREE
#endif
#ifdef LIBXML_DOCB_ENABLED
#endif
function: xmlNodeAddContent
#ifdef DEBUG_TREE
#endif
function: xmlTextMerge
function: xmlGetNsList
function: xmlSearchNs
function: xmlSearchNsByHref
function: xmlNewReconciliedNs
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlReconciliateNs
function: xmlHasProp
function: xmlHasNsProp
function: xmlGetProp
function: xmlGetNsProp
function: xmlSetProp
function: xmlUnsetProp
function: xmlSetNsProp
function: xmlUnsetNsProp
function: xmlNodeIsText
function: xmlIsBlankNode
function: xmlTextConcat
#ifdef DEBUG_TREE
#endif
function: xmlBufferCreate
function: xmlBufferCreateSize
function: xmlBufferSetAllocationScheme
#ifdef DEBUG_BUFFER
#endif
function: xmlBufferFree
#ifdef DEBUG_BUFFER
#endif
function: xmlBufferEmpty
function: xmlBufferShrink
function: xmlBufferGrow
function: xmlBufferDump
#ifdef DEBUG_BUFFER
#endif
#ifdef DEBUG_BUFFER
#endif
function: xmlBufferContent
function: xmlBufferLength
function: xmlBufferResize
function: xmlBufferAdd
#ifdef DEBUG_BUFFER
#endif
#ifdef DEBUG_BUFFER
#endif
function: xmlBufferAddHead
#ifdef DEBUG_BUFFER
#endif
#ifdef DEBUG_BUFFER
#endif
function: xmlBufferCat
function: xmlBufferCCat
#ifdef DEBUG_BUFFER
#endif
#ifdef VMS
#else
#endif
function: xmlBufferWriteChar
function: xmlBufferWriteQuotedString
#ifdef DEBUG_BUFFER
#endif
function: htmlNodeDump
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#if 0
#endif
#if 0
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlNodeDump
#ifdef DEBUG_TREE
#endif
function: xmlElemDump
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef LIBXML_HTML_ENABLED
#else
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
#ifdef DEBUG_TREE
#endif
function: xmlNodeDumpOutput
#ifdef DEBUG_TREE
#endif
function: xmlDocDumpFormatMemoryEnc
function: xmlDocDumpMemory
function: xmlDocDumpFormatMemory
function: xmlDocDumpMemoryEnc
function: xmlGetCompressMode
function: xmlSetCompressMode
function: xmlDocDump
#ifdef DEBUG_TREE
#endif
function: xmlSaveFileTo
function: xmlSaveFormatFileTo
function: xmlSaveFormatFileEnc
#ifdef HAVE_ZLIB_H
#endif
function: xmlSaveFileEnc
function: xmlSaveFormatFile
function: xmlSaveFile
/**** end of file: tree.c ****/
#!/usr/bin/perl
sub replace {
my ($start, $end, $in, $out, $checkdefs, $replacement) = @_;
my $s, $e, $level = 0, $def = 0;
my $res, $updated;
open IN, $in or die "Unable to open input file $in\n";
open OUT, '>', $out or die "Unable to open output file $out\n";
while(<IN>) {
chomp;
if(($checkdefs == 1) && (($def == 1) or (/^[ ]*\#/))) {
if(/\\[ ]*$/) {
$def = 1;
} else {
$def = 0;
}
print OUT "$_\n";
} else {
$res = "";
$updated = 0;
while(1) {
$s = index $_, $start;
$e = index $_, $end;
if(($s >= 0) && (($s <= $e) || ($e < 0))) {
if($level == 0) {
$res = $res . substr($_, 0, $s) . $replacement;
$updated = 1;
}
$_ = substr $_, $s + length($start);
$level++;
} elsif(($e >= 0) && (($e < $s) || ($s < 0))) {
$_ = substr $_, $e + length($end);
$level--;
} elsif(($s < 0) && ($e < 0)) {
last;
} else {
die "replace: We should not be here ($s:$e)\n";
}
}
if($updated == 1) {
print OUT "$res";
}
if($level == 0) {
print OUT "$_";
}
print OUT "\n";
}
}
close IN;
close OUT;
}
sub parse {
my ($in, $out, $checkdefs) = @_;
my $def = 0, $res = "", $name, $type;
open IN, $in or die "Unable to open input file $in\n";
open OUT, '>', $out or die "Unable to open output file $out\n";
while(<IN>) {
chomp;
if(($checkdefs == 1) && (($def == 1) or (/^[ ]*\#/))) {
if(/\\[ ]*$/) {
$def = 1;
} else {
$def = 0;
}
print OUT "$_\n";
} else {
while(/([^\};]*)([\};])(.*)/) {
$res = " $res $1$2";
$_ = $3;
if($res =~ s/\(.*//) {
$type = 'function';
} elsif($res =~ s/[\[=;].*//) {
$type = 'variable';
} else {
$res = "";
next;
# die "parse: We should not be here ($res)\n";
}
($res, $name) = $res =~ /(.*) (.*)/;
if($res =~ / static /) {
print STDERR " static $type $name\n";
} elsif($name =~ /[a-zA-Z]/) {
print STDERR " exported $type $name\n";
print OUT "$type: $name\n";
}
$res = "";
}
$res = $res . " " . $_;
$res =~ s/ / /g;
}
}
close IN;
close OUT;
}
my $file;
my $tmp1 = "deftmp1.tmp";
my $tmp2 = "deftmp2.tmp";
print STDERR "Usage: createdef.pl <file> [<file> [<file> ... ]]]\n";
while ($file = shift @ARGV) {
print STDERR "Processing file $file...\n";
# remove comments and shrink all code blocks
replace('/*', '*/', $file, $tmp1, 0);
replace('{', '}', $tmp1, $tmp2, 1, '{}');
replace('(', ')', $tmp2, $tmp1, 1, '()');
# parse functions and variables
parse($tmp1, $tmp2, 1);
print "/**** start of file: $file ****/\n";
system "cat $tmp2";
print "/**** end of file: $file ****/\n";
}
rmdir $tmp1;
rmdir $tmp2;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]