Mailing List Archive

cvs commit: embperl epcomp.c epdom.c epdom.h epparse.c
richter 00/05/08 12:40:49

Modified: . Tag: Embperl2 epcomp.c epdom.c epdom.h epparse.c
Log:
Embperl 2 - DOM & Compile

Revision Changes Path
No revision


No revision


1.1.2.2 +130 -2 embperl/Attic/epcomp.c

Index: epcomp.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epcomp.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- epcomp.c 2000/05/08 18:16:27 1.1.2.1
+++ epcomp.c 2000/05/08 19:40:45 1.1.2.2
@@ -4,7 +4,6 @@
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
-# For use with Apache httpd and mod_perl, see also Apache copyright.
#
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
@@ -17,10 +16,139 @@
#include "epmacro.h"
#include "epdom.h"

+struct tEmbperlCmd
+ {
+ const char * sPerlCode ;
+ } ;
+
+
+
+tStringIndex nMaxEmbperlCmd ;
+struct tEmbperlCmd * * pEmbperlCmds ;
+
+
+/* ------------------------------------------------------------------------ */
+/* */
+/* embperl_CompileInit */
+/* */
+/* */
+/* */
+/* ------------------------------------------------------------------------ */
+
+
+int embperl_CompileInit
+
+ {
+ ArrayNew (&pEmbperlCmds, 256, sizeof (struct tNodeData *)) ;
+ ArrayAdd (&pEmbperlCmds, 1) ;
+ pEmbperlCmds[0] = NULL ;
+ nMaxEmbperlCmd = 1 ;
+ }
+


-embperl_compile (/*in*/ tNode xDocument)
+/* ------------------------------------------------------------------------ */
+/* */
+/* embperl_CompileNode */
+/* */
+/* Compile one node and his childs */
+/* */
+/* ------------------------------------------------------------------------ */


+embperl_CompileNode (/*in*/ tNode xNode)
+
+
{
+ tNode xChildNode ;
+
+ tNodeData * pNode = Node_self (xNode) ;
+ tStringIndex nNdx = Node_selfNodeNameNdx (pNode) ;
+
+ if (nNdx < nMaxEmbperlCmd)
+ {
+ struct tEmbperlCmd * pCmd = pEmbperlCmds[nNdx] ;
+ if (pCmd)
+ {
+ const char * sPerlCode ;
+ const char * p ;
+ const char * q ;
+
+ if ((sPerlCode = pCmd -> sPerlCode))
+ {
+ p = strchr (sPerlCode, '%') ;
+ while (p)
+ {
+ int n = p - sPerlCode ;
+ printf ("%*.*s", n, n, sPerlCode) ;
+ q = strchr (p, '%') ;
+ if (q)
+ {
+ if (p[1] == '#')
+ {
+ int nChildNo = atoi (p[2]) ;
+ struct tNodeData * pChildNode = Node_selfNthChild (pNode, nChildNo) ;
+
+ if (pChildNode)
+ puts (Node_selfNodeName(pChildNode)) ;
+ else
+ mydie ("missing child") ;
+ }
+ else
+ {
+ const char * sVal = Element_selfGetAttribut (pNode, p, p - q - 1) ;
+
+ puts (sVal) ;
+ }
+
+ sPerlCode = q + 1 ;
+ p = strchr (sPerlCode, '%') ;
+ }
+ else
+ {
+ sPerlCode = p ;
+ p = NULL ;
+ }
+ }
+ puts (sPerlCode) ;
+ }
+ }
+ }
+
+
+
+
+ tNode xChildNode = Node_firstChild (xNode) ;
+
+ while (xChildNode)
+ {
+ embperl_CompileNode (xChildNode) ;
+
+ xChildNode = Node_nextSibling (xChildNode) ;
+ }
+
+ }
+
+/* ------------------------------------------------------------------------ */
+/* */
+/* embperl_CompileDocument */
+/* */
+/* Compile the whole document */
+/* */
+/* ------------------------------------------------------------------------ */
+
+
+embperl_CompileDocument (/*in*/ tNode xDocument)
+
+
+ {
+ tNode xNode = Node_firstChild (xDocument) ;
+
+ while (xNode)
+ {
+ embperl_CompileNode (xNode) ;
+
+ xNode = Node_nextSibling (xNode) ;
+ }

+ }
\ No newline at end of file



1.1.2.5 +31 -13 embperl/Attic/epdom.c

Index: epdom.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epdom.c,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- epdom.c 2000/05/08 18:16:27 1.1.2.4
+++ epdom.c 2000/05/08 19:40:46 1.1.2.5
@@ -4,7 +4,6 @@
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
-# For use with Apache httpd and mod_perl, see also Apache copyright.
#
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
@@ -401,32 +400,51 @@
{
struct tNodeData * pNode = pNodeLookup [xNode] ;
struct tNodePad * pPad = (struct tNodePad * )(((tUInt8 *)pNode) - pNode -> nPadNdx) ;
- lprintf (pCurrReq, "[%d]PARSE: parentNode: %d -> %d\n", pCurrReq -> nPid, xNode, pPad -> xParent) ;
+ /* lprintf (pCurrReq, "[%d]PARSE: parentNode: %d -> %d\n", pCurrReq -> nPid, xNode, pPad -> xParent) ; */
return pPad -> xParent ;
}

-
/* ------------------------------------------------------------------------ */
/* */
-/* Node_nodeName */
+/* Node_firstChild */
/* */
-/* Get name of node */
+/* Get first child node */
/* */
/* ------------------------------------------------------------------------ */

- int i ;
- struct tNodePad * p ;
- const char * s ;

-const char * Node_nodeName (/*in*/ tNode xNode)
+tNode Node_firstChild (/*in*/ tNode xNode)

{
- i = pNodeLookup [xNode] -> nText ;
- p = pPadLookup [pNodeLookup [xNode] -> xChilds] ;
- s = pStringTableArray[pNodeLookup [xNode] -> nText] ;
- return s ;
+ struct tNodePad * pPad = pPadLookup[pNodeLookup [xNode] -> xChilds] ;
+ return ((struct tNodeData *)(pPad + 1)) -> xNdx ;
}


+/* ------------------------------------------------------------------------ */
+/* */
+/* Node_selfNthChild (pNode, nChildNo) ; */
+/* */
+/* Get first child node */
+/* */
+/* ------------------------------------------------------------------------ */
+
+
+tNodeData * Node_selfNthChild (/*in*/ tNodeData * pNode,
+ /*in*/ int nChildNo)

+ {
+ struct tNodePad * pPad = pPadLookup[pNodeLookup [xNode] -> xChilds] ;
+ int n = 0;
+ while (nChildNo > n + pPad -> numChilds && pPad -> xNext)
+ {
+ n += pPad -> numChilds ;
+ pPad = pPadLookup[pPad -> xNext] ;
+ }
+
+ if (nChildNo > n)
+ return NULL ;
+
+ return ((struct tNodeData *)(pPad + 1)) + (nChildNo - n) ;
+ }




1.1.2.2 +14 -1 embperl/Attic/epdom.h

Index: epdom.h
===================================================================
RCS file: /home/cvs/embperl/Attic/epdom.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- epdom.h 2000/05/08 18:16:28 1.1.2.1
+++ epdom.h 2000/05/08 19:40:47 1.1.2.2
@@ -4,7 +4,6 @@
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
-# For use with Apache httpd and mod_perl, see also Apache copyright.
#
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
@@ -97,4 +96,18 @@

tNode Node_parentNode (/*in*/ tNode xNode) ;

+
+
+
+
+#define Node_self(xNode) (pNodeLookup[xNode])
+
+#define Node_selfNodeNameNdx(pNode) (pNode -> nText) ;
+#define Node_selfNodeName(pNode) (pStringTableArray[pNode -> nText])
+
+
+Node_nextSibling (xChildNode) ;
+
+
+Element_selfGetAttribut (pNode, p, p - q - 1) ;




1.1.2.8 +0 -1 embperl/Attic/epparse.c

Index: epparse.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epparse.c,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- epparse.c 2000/05/08 18:16:28 1.1.2.7
+++ epparse.c 2000/05/08 19:40:47 1.1.2.8
@@ -4,7 +4,6 @@
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
-# For use with Apache httpd and mod_perl, see also Apache copyright.
#
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED