Style & Makefile fixes for libgit2
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 05 Sep 2012 11:13:11 +0000
changeset 25 9718bd0f1028
parent 24 e7afa531abcf
child 26 bd4d0544a609
Style & Makefile fixes for libgit2
resources/examples/libgit2/Makefile
resources/examples/libgit2/styles/gccxml2def-function.xsl
resources/examples/libgit2/styles/gccxml2def-utils.xsl
resources/examples/libgit2/styles/gccxml2def.xsl
--- a/resources/examples/libgit2/Makefile	Wed Sep 05 11:12:41 2012 +0000
+++ b/resources/examples/libgit2/Makefile	Wed Sep 05 11:13:11 2012 +0000
@@ -2,7 +2,7 @@
 
 XSLTPROC=xsltproc
 
-XML2DEF_XSL=../../styles/gccxml2def.xsl
+XML2DEF_XSL=styles/gccxml2def.xsl
 
 
 
@@ -25,12 +25,15 @@
 libgit2.def:   $(LIBGIT2_DEFFILES)
 	cat $(LIBGIT2_DEFFILES) > libgit2.def
 	sed -i -e 's/^(struct-foreign git_/(struct git_/g' libgit2.def
+	sed -i -e 's/^(struct-foreign _git_oid/(struct _git_oid/g' libgit2.def
+	sed -i -e 's/^(typedef-foreign git_/(typedef git_/g' libgit2.def
+
 
 %.h.def:%.h.xml
 	$(XSLTPROC) $(XSLTPROC_FLAGS) -o $@ $(XML2DEF_XSL) $<
 
 %.h.xml: $(LIBGIT2_INCLUDE_DIR)/%.h
-	$(GCC_XML) -m32 -I$(LIBGIT2_INCLUDE_DIRp) $< -fxml=$@
+	$(GCC_XML) -m32 -I$(LIBGIT2_INCLUDE_DIR) $< -fxml=$@
 
 clean:
 	rm -rf *.h.xml *.h.def
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/resources/examples/libgit2/styles/gccxml2def-function.xsl	Wed Sep 05 11:13:11 2012 +0000
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="iso-8859-2"?>
+<xsl:stylesheet 
+    version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:import href="gccxml2def-utils.xsl"/>
+
+  <xsl:template name="function">
+    <xsl:text>(function </xsl:text>
+    <xsl:call-template name="function-selector"/>
+    <xsl:text>)&#10;</xsl:text>
+  </xsl:template>
+
+	
+  <xsl:template name="function-selector">
+    <xsl:value-of select="./@name"/>
+    <xsl:text>&#10;&#09;(</xsl:text>	  
+	  
+    <xsl:for-each select="./Argument">
+	  <xsl:call-template name="function-argument"/>
+    </xsl:for-each>
+	  
+    <xsl:text>)&#10;&#09;(return </xsl:text>
+    <xsl:call-template name="c-type-string">
+      <xsl:with-param name="c-type-id" select="./@returns"/>
+    </xsl:call-template>
+    <xsl:text>)</xsl:text>
+  </xsl:template>
+
+	
+  <xsl:template name="function-argument">
+    <xsl:text>&#10;&#09;&#09;(argument (</xsl:text>
+    <xsl:call-template name="c-type-string">
+      <xsl:with-param name="c-type-id" select="./@type"/>
+    </xsl:call-template>
+    <xsl:text>) </xsl:text>
+	  
+    <xsl:if test="@name or not(@name='')">	  
+      <xsl:if test="starts-with(./@name,'_')">
+        <xsl:text>arg_</xsl:text>		  
+	  </xsl:if>			  	     
+	  <xsl:value-of select="./@name"/>
+	</xsl:if>	
+    <xsl:if test="not(@name) or @name=''">
+	  <xsl:text>arg</xsl:text>	
+	  <xsl:value-of select="position()"/>		
+	</xsl:if>	  
+		
+    <xsl:text>)</xsl:text>					  	  
+  </xsl:template>	
+	
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/resources/examples/libgit2/styles/gccxml2def-utils.xsl	Wed Sep 05 11:13:11 2012 +0000
@@ -0,0 +1,296 @@
+<?xml version="1.0" encoding="iso-8859-2"?>
+<xsl:stylesheet 
+    version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+  <xsl:template name="c-type-string">
+    <xsl:param name="c-type-id"/>
+    <xsl:param name="c-name-id" select="$c-type-id"/>
+    
+    <xsl:choose>
+      <xsl:when test="/GCC_XML/PointerType[@id = $c-type-id]">
+	<xsl:text>(pointer-to </xsl:text>
+	
+	<xsl:choose>
+	  <!-- Pointer is a part of the user defined type -->
+	  <!-- save the name that type -->
+	  <xsl:when test="/GCC_XML/Typedef[@type = $c-type-id]">
+	    <xsl:call-template name="c-type-string">
+	      <xsl:with-param name="c-type-id" select="/GCC_XML/PointerType[@id = $c-type-id]/@type"/>
+	      <xsl:with-param name="c-name-id" select="/GCC_XML/Typedef[@type = $c-type-id]/@name"/>          
+	    </xsl:call-template>            
+	  </xsl:when>
+
+	  <xsl:otherwise>
+	    <xsl:call-template name="c-type-string">
+	      <xsl:with-param name="c-type-id" select="/GCC_XML/PointerType[@id = $c-type-id]/@type"/>
+	      <xsl:with-param name="c-name-id" select="/GCC_XML/PointerType[@id = $c-type-id]/@type"/>          
+	    </xsl:call-template>            
+	  </xsl:otherwise>
+	</xsl:choose>
+	<xsl:text>)</xsl:text>        
+      </xsl:when>
+
+      <xsl:when test="/GCC_XML/CvQualifiedType[@id = $c-type-id]">
+	<xsl:if test="/GCC_XML/CvQualifiedType[@id = $c-type-id]/@const = 1"><xsl:text>const </xsl:text></xsl:if>
+	<xsl:call-template name="c-type-string">
+	  <xsl:with-param name="c-type-id" select="/GCC_XML/CvQualifiedType[@id = $c-type-id]/@type"/>	 
+	</xsl:call-template>
+      </xsl:when>
+      
+      <xsl:when test="/GCC_XML/FundamentalType[@id = $c-type-id]">
+	<xsl:value-of select="/GCC_XML/FundamentalType[@id = $c-type-id]/@name"/>
+      </xsl:when>
+
+      <xsl:when test="/GCC_XML/Typedef[@id = $c-type-id]">
+	<xsl:choose>
+	  <!-- Fundamental types are resolved -->
+	  <xsl:when test="/GCC_XML/FundamentalType[@id = /GCC_XML/Typedef[@id = $c-type-id]/@type]" >
+	    <xsl:value-of select="/GCC_XML/FundamentalType[@id = /GCC_XML/Typedef[@id = $c-type-id]/@type]/@name"/>
+	  </xsl:when>
+
+	  <!-- Pointers are resolved -->
+	  <xsl:when test="/GCC_XML/PointerType[@id = /GCC_XML/Typedef[@id = $c-type-id]/@type]" >
+	    <xsl:call-template name="c-type-string">
+	      <xsl:with-param name="c-type-id" select="/GCC_XML/Typedef[@id = $c-type-id]/@type"/>	 
+	    </xsl:call-template>
+	  </xsl:when>
+
+	  <!-- Typedefs are resolved -->
+	  <xsl:when test="/GCC_XML/Typedef[@id = /GCC_XML/Typedef[@id = $c-type-id]/@type]" >
+	    <xsl:call-template name="c-type-string">
+	      <xsl:with-param name="c-type-id" select="/GCC_XML/Typedef[@id = $c-type-id]/@type"/>	 
+	    </xsl:call-template>
+	  </xsl:when>         
+	  
+	  <!-- Function types are resolved -->
+	  <xsl:when test="/GCC_XML/FunctionType[@id = /GCC_XML/Typedef[@id = $c-type-id]/@type]">
+	    <xsl:call-template name="c-type-string">
+	      <xsl:with-param name="c-type-id" select="/GCC_XML/Typedef[@id = $c-type-id]/@type"/>
+	      <xsl:with-param name="c-name-id" select="/GCC_XML/Typedef[@id = $c-type-id]/@name"/>	 
+	    </xsl:call-template>
+	  </xsl:when>
+
+	  <!-- remaining not, possible loop in struct -->
+	  <xsl:otherwise>
+	    <xsl:value-of select="/GCC_XML/Typedef[@id = $c-type-id]/@name"/>
+	  </xsl:otherwise>
+	</xsl:choose>       	                    
+      </xsl:when>
+
+      <xsl:when test="/GCC_XML/FunctionType[@id = $c-type-id]">
+	<xsl:text>(function-type </xsl:text>        
+	<xsl:value-of select="$c-name-id"/>       
+	<xsl:text>&#10;&#09;&#09;&#09;(</xsl:text>
+
+	<xsl:for-each select="/GCC_XML/FunctionType[@id = $c-type-id]/Argument">
+	  <xsl:text>&#10;&#09;&#09;&#09;&#09;(argument (</xsl:text>
+	  <xsl:call-template name="c-type-string">
+	    <xsl:with-param name="c-type-id" select="@type"/>
+	  </xsl:call-template>
+	  <xsl:text>) </xsl:text>
+	  <xsl:value-of select="@name"/>
+	  <xsl:text>)</xsl:text>			
+	</xsl:for-each>
+	<xsl:text>)&#10;&#09;&#09;&#09;(return </xsl:text>
+	<xsl:call-template name="c-type-string">
+	  <xsl:with-param name="c-type-id" select="/GCC_XML/FunctionType[@id = $c-type-id]/@returns"/>
+	</xsl:call-template>
+	<xsl:text>))</xsl:text>
+      </xsl:when>
+
+      <xsl:when test="/GCC_XML/Enumeration[@id = $c-type-id]">
+	<xsl:value-of select="/GCC_XML/Enumeration[@id = $c-type-id]/@name"/>
+      </xsl:when>
+
+      <xsl:when test="/GCC_XML/Struct[@id = $c-type-id]">
+	<xsl:choose>
+	  <xsl:when test="/GCC_XML/Struct[@id = $c-type-id and not(@name)] or /GCC_XML/Struct[@id = $c-type-id]/@name = ''">
+	    <xsl:value-of select="/GCC_XML/Struct[@id = $c-type-id]/@id"/>  
+	  </xsl:when>
+	  <xsl:otherwise>
+	    <xsl:value-of select="/GCC_XML/Struct[@id = $c-type-id]/@name"/>
+	  </xsl:otherwise>
+	</xsl:choose>                
+      </xsl:when>
+
+      <xsl:when test="/GCC_XML/ArrayType[@id = $c-type-id]">
+	<xsl:text>(array (</xsl:text>        
+	<xsl:call-template name="c-type-string">
+	  <xsl:with-param name="c-type-id" select="/GCC_XML/ArrayType[@id = $c-type-id]/@type"/>	 
+	</xsl:call-template>
+	<xsl:text>) </xsl:text>
+	<xsl:value-of select="/GCC_XML/ArrayType[@id = $c-type-id]/@max"/>                
+	<xsl:text>)</xsl:text>                
+      </xsl:when>
+      
+      <xsl:when test="/GCC_XML/Union[@id = $c-type-id]">
+	<xsl:choose>
+	  <xsl:when test="/GCC_XML/Union[@id = $c-type-id and not(@name)] or /GCC_XML/Union[@id = $c-type-id]/@name = ''">
+	    <xsl:value-of select="/GCC_XML/Union[@id = $c-type-id]/@id"/>  
+	  </xsl:when>
+	  <xsl:otherwise>            
+	    <xsl:value-of select="/GCC_XML/Union[@id = $c-type-id]/@name"/>
+	  </xsl:otherwise>
+	</xsl:choose>        
+      </xsl:when>
+      
+      <xsl:otherwise>
+	<xsl:message>
+	  <xsl:text>&#10;#Error: --c-type-string-- Unknown C type with id </xsl:text>
+	  <xsl:value-of select="$c-type-id"/>
+	</xsl:message>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>  
+
+  
+  <!--- ========== Tokenizer ================== -->
+  <xsl:template name="tokenize">
+    <xsl:param name="string" select="''" />
+    <xsl:param name="delimiter" select="' '" />
+    <xsl:param name="indent" select="1"/>
+    <xsl:choose>
+      <xsl:when test="not($string)" />
+      <xsl:when test="not($delimiter)" />
+      <xsl:when test="$string = ''" />
+      <xsl:otherwise>
+	<xsl:call-template name="_tokenize-delimiter">
+	  <xsl:with-param name="string" select="$string" />
+	  <xsl:with-param name="delimiter" select="$delimiter" />
+	  <xsl:with-param name="indent" select="$indent" />
+	</xsl:call-template>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template name="_tokenize-delimiter">
+    <xsl:param name="string" />
+    <xsl:param name="delimiter" />
+    <xsl:param name="indent" />
+    <xsl:choose>
+      <xsl:when test="not($string)" />
+
+      <xsl:when test="contains($string, $delimiter)">
+
+	<xsl:call-template name="find-field">
+	  <xsl:with-param name="field-id" select="substring-before($string, $delimiter)"/>
+	  <xsl:with-param name="string" select="$string"/>
+	  <xsl:with-param name="indent" select="$indent" />
+	</xsl:call-template>       
+
+	<xsl:call-template name="_tokenize-delimiter">
+	  <xsl:with-param name="string"	select="substring-after($string, $delimiter)" />
+	  <xsl:with-param name="delimiter" select="$delimiter" />
+	  <xsl:with-param name="indent" select="$indent" />
+	</xsl:call-template>
+      </xsl:when>	  
+      
+      <xsl:otherwise>
+	<xsl:message>              
+	  <xsl:text>&#10;#Error: --tokenizer-- Nothing happend for string </xsl:text>            
+	  <xsl:value-of select="$string"/>
+	</xsl:message>            
+      </xsl:otherwise>
+    </xsl:choose>
+    
+  </xsl:template>
+
+  
+
+  <!--- ========== Find Field ================== -->  
+  <xsl:template name="find-field">
+    <xsl:param name="field-id"/>
+    <xsl:param name="field" select="/GCC_XML/*[@id = $field-id]"/>
+    <xsl:param name="field-type" select="/GCC_XML/*[@id = $field/@type]"/>
+    <xsl:param name="string"/>
+    <xsl:param name="indent" />
+    <xsl:choose>
+
+      <xsl:when test="not($field)">
+	<xsl:message>
+	  <xsl:text>&#10;#Error: find-field: Field with id </xsl:text>
+	  <xsl:value-of select="$field-id"/>
+	  <xsl:text> not found!</xsl:text>
+	</xsl:message>
+      </xsl:when>
+
+      <xsl:when test="local-name($field) = 'Struct'"/>
+      <xsl:when test="local-name($field) = 'Enumeration'"/>
+      <xsl:when test="local-name($field) = 'Union'"/>
+
+      <xsl:when test="$field">
+	<xsl:text>&#10;</xsl:text>
+	<xsl:call-template name="indent">
+	  <xsl:with-param name="count" select="$indent"/>
+	</xsl:call-template>	
+	<xsl:text>(field (</xsl:text>	
+	<xsl:choose>
+	  <xsl:when test="not($field-type/@name)">
+	    <xsl:text>&#10;</xsl:text>
+	    <xsl:call-template name="indent">
+	      <xsl:with-param name="count" select="$indent+1"/>
+	    </xsl:call-template>
+	    <xsl:choose>
+	      <xsl:when test="
+		   local-name($field-type) = 'PointerType'
+		or local-name($field-type) = 'FundamentalType'
+		or local-name($field-type) = 'CvQualifiedType'
+		or local-name($field-type) =  'ArrayType'
+		">
+		<xsl:call-template name="c-type-string">
+		  <xsl:with-param name="c-type-id" select="/GCC_XML/Field[@id = $field-id]/@type"/>
+		</xsl:call-template>
+	      </xsl:when>
+	      <xsl:otherwise>
+		<xsl:apply-templates select="$field-type"/>
+	      </xsl:otherwise>
+	    </xsl:choose>
+	    <xsl:text>&#10;</xsl:text>
+	  </xsl:when>
+	  <xsl:otherwise>
+	    <xsl:call-template name="c-type-string">
+	      <xsl:with-param name="c-type-id" select="/GCC_XML/Field[@id = $field-id]/@type"/>
+	    </xsl:call-template>        
+	  </xsl:otherwise>
+	</xsl:choose>
+	<xsl:text>) </xsl:text>
+	
+	<xsl:if test="/GCC_XML/Field[@id = $field-id]/@name = ''">
+	  <!-- Field has not defined name -->
+	  <xsl:text>unknown</xsl:text>
+	  <xsl:value-of select="/GCC_XML/Field[@id = $field-id]/@id"/>
+	</xsl:if>
+	<xsl:value-of select="/GCC_XML/Field[@id = $field-id]/@name"/>
+
+	<xsl:text> :offset </xsl:text>
+	<xsl:value-of select="/GCC_XML/Field[@id = $field-id]/@offset"/>
+	
+	<xsl:text>)</xsl:text>               
+      </xsl:when>
+
+      <xsl:otherwise>
+	<xsl:message>
+	  <xsl:text>&#10;#Error: find-field: Unknown error for id </xsl:text>
+	  <xsl:value-of select="$field-id"/>
+	</xsl:message>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+  
+  
+  
+  <!--- ========== indent ================== -->
+  <xsl:template name="indent">  
+    <xsl:param name="count" select="1"/>
+    
+    <xsl:if test="$count > 0">
+      <xsl:text>&#09;</xsl:text>      
+      <xsl:call-template name="indent">
+	<xsl:with-param name="count" select="$count - 1"/>
+      </xsl:call-template>
+    </xsl:if>      
+  </xsl:template>  
+  
+  
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/resources/examples/libgit2/styles/gccxml2def.xsl	Wed Sep 05 11:13:11 2012 +0000
@@ -0,0 +1,234 @@
+<?xml version="1.0" encoding="iso-8859-2"?>
+<xsl:stylesheet
+    version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:import href="gccxml2def-function.xsl"/>
+
+  <xsl:output method="text"/>
+
+  <!-- Do not copy white characters from input to output -->
+  <xsl:strip-space elements="*" />
+
+  <!-- c-header-file should be set to source C header file from command line -->
+  <xsl:param name="c-header-file" select="/GCC_XML/File[1]/@name"/>
+  <!-- get ID of source header file; file with ID = f0 is NOT always source header file -->
+  <xsl:param name="c-header-file-id" select="/GCC_XML/File[contains(@name,substring($c-header-file,1,string-length($c-header-file)-4))]/@id"/>
+  <xsl:param name="c-header-filename" select="/GCC_XML/File[@id=$c-header-file-id]/@name"/>
+
+
+  <xsl:template match="/">
+    <xsl:text>#Generated from: </xsl:text>
+      <xsl:value-of select="$c-header-filename"/>
+    <xsl:text>&#10;</xsl:text>
+<!--
+	<xsl:apply-templates select="//*[@file=$c-header-file-id]"/>
+-->
+    <xsl:apply-templates select="/GCC_XML/*[@context='_1']"/>
+  </xsl:template>
+
+
+  <!-- file has no meaning -->
+  <xsl:template match="/GCC_XML/File"/>
+
+  <!-- FunctionType has no meaning -->
+  <xsl:template match="/GCC_XML/FunctionType"/>
+
+  <!-- CvQualifiedType is processed by c-type-string template -->
+  <xsl:template match="/GCC_XML/CvQualifiedType"/>
+
+  <!-- FundamentalType is processed by c-type-string template -->
+  <xsl:template match="/GCC_XML/FundamentalType"/>
+
+  <!-- PointerType is processed by c-type-string template -->
+  <xsl:template match="/GCC_XML/PointerType"/>
+
+  <!-- ArrayType is processed by c-type-string template -->
+  <xsl:template match="/GCC_XML/ArrayType"/>
+
+  <!-- Class has no meaning -->
+  <xsl:template match="/GCC_XML/Class"/>
+
+  <!-- constructors of structures ??? -->
+  <xsl:template match="/GCC_XML/Constructor"/>
+
+  <!-- Converter has no meaning -->
+  <xsl:template match="/GCC_XML/Converter"/>
+
+  <!-- Destructor has no meaning -->
+  <xsl:template match="/GCC_XML/Destructor"/>
+
+  <!-- Method has no meaning -->
+  <xsl:template match="/GCC_XML/Method"/>
+
+  <!-- MethodType has no meaning -->
+  <xsl:template match="/GCC_XML/MethodType"/>
+
+  <!-- namespace has no meaning -->
+  <xsl:template match="/GCC_XML/Namespace"/>
+
+  <!-- NamespaceAlias has no meaning -->
+  <xsl:template match="/GCC_XML/NamespaceAlias"/>
+
+  <!-- OperatorFunction has no meaning -->
+  <xsl:template match="/GCC_XML/OperatorFunction"/>
+
+  <!-- OperatorMethod has no meaning -->
+  <xsl:template match="/GCC_XML/OperatorMethod"/>
+
+  <!-- OffsetType has no meaning -->
+  <xsl:template match="/GCC_XML/OffsetType"/>
+
+  <!-- Unimplemented has no meaning -->
+  <xsl:template match="/GCC_XML/Unimplemented"/>
+
+  <!-- ReferenceType has no meaning, it has some connection with Constructor -->
+  <xsl:template match="/GCC_XML/ReferenceType"/>
+
+  <!-- Variable has no meaning -->
+  <xsl:template match="/GCC_XML/Variable"/>
+
+  <xsl:template match="/GCC_XML/Struct">
+    <xsl:param name="id" select="@id" />
+
+      <xsl:text>(</xsl:text>
+      <xsl:text>struct</xsl:text>
+      <xsl:if test="not(@file=$c-header-file-id)">
+	<xsl:text>-foreign</xsl:text>
+      </xsl:if>
+      <xsl:text> </xsl:text>
+      <xsl:value-of select="@name"/>
+      <xsl:text> :size </xsl:text>
+      <xsl:choose>
+	<xsl:when test="@size">
+	  <xsl:value-of select="@size"/>
+	</xsl:when>
+	<xsl:otherwise>
+	  <xsl:text>0</xsl:text>
+	</xsl:otherwise>
+      </xsl:choose>
+      <xsl:call-template name="tokenize">
+	<xsl:with-param name="string" select="@members" />
+      </xsl:call-template>
+      <xsl:text>)&#10;</xsl:text>
+
+  </xsl:template>
+
+  <!-- fields of structures, processed indirectly through tokenize -->
+  <xsl:template match="/GCC_XML/Field"/>
+
+  <xsl:template match="/GCC_XML/Enumeration">
+    <xsl:param name="id" select="@id" />
+
+      <xsl:text>(</xsl:text>
+      <xsl:text>enum</xsl:text>
+      <xsl:if test="not(@file=$c-header-file-id)">
+	<xsl:text>-foreign</xsl:text>
+      </xsl:if>
+      <xsl:text> </xsl:text>
+      <xsl:value-of select="@name"/>
+
+      <xsl:for-each select="./EnumValue">
+	<xsl:text>&#10;&#09;(value (</xsl:text>
+	<xsl:value-of select="@name"/>
+	<xsl:text>) </xsl:text>
+	<xsl:value-of select="@init"/>
+	<xsl:text>)</xsl:text>
+      </xsl:for-each>
+
+      <xsl:text>)&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="/GCC_XML/Union">
+    <xsl:param name="id" select="@id" />
+
+      <xsl:text>(</xsl:text>
+      <xsl:text>union</xsl:text>
+      <xsl:if test="not(@file=$c-header-file-id)">
+	<xsl:text>-foreign</xsl:text>
+	  </xsl:if>
+      <xsl:text> </xsl:text>
+      <xsl:value-of select="@name"/>
+      <xsl:text> :size </xsl:text>
+      <xsl:choose>
+	<xsl:when test="@size">
+	  <xsl:value-of select="@size"/>
+	</xsl:when>
+	<xsl:otherwise>
+	  <xsl:text>0</xsl:text>
+	</xsl:otherwise>
+      </xsl:choose>
+
+      <xsl:text> </xsl:text>
+
+
+      <xsl:call-template name="tokenize">
+	<xsl:with-param name="string" select="@members" />
+      </xsl:call-template>
+
+      <xsl:text>)&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="/GCC_XML/Typedef">
+	  <xsl:param name="name" select="@name" />
+	  <xsl:param name="type" select="@type" />
+
+    <xsl:choose>
+      <!-- Omits Typedefs of Structs or Enumaretions with same name -->
+      <xsl:when test="/GCC_XML/Struct[@id = $type and @name = $name] or /GCC_XML/Enumeration[@id = $type and @name = $name]"/>
+
+      <!-- Omits Typedefs of Function types and pointers on function types -->
+      <xsl:when test="/GCC_XML/FunctionType[@id = $type] or /GCC_XML/FunctionType[@id = /GCC_XML/PointerType[@id = $type]/@type]"/>
+
+      <xsl:otherwise>
+	<xsl:text>(typedef</xsl:text>
+	<xsl:if test="not(@file=$c-header-file-id)">
+	  <xsl:text>-foreign</xsl:text>
+	    </xsl:if>
+	<xsl:text> </xsl:text>
+	<xsl:value-of select="@name"/>
+	<xsl:text>&#10;&#09;</xsl:text>
+
+	<xsl:call-template name="c-type-string">
+	  <xsl:with-param name="c-type-id" select="@type"/>
+	</xsl:call-template>
+
+       <xsl:text>)&#10;</xsl:text>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="/GCC_XML/Function">
+    <!--
+    <xsl:if test="@file = $c-header-file-id">
+      <xsl:call-template name="function"/>
+    </xsl:if>
+    -->
+
+    <!--
+    <xsl:message>
+      <xsl:text>&#10;#Debug: Testing function </xsl:text>
+      <xsl:value-of select="./@name"/>
+    </xsl:message>
+    -->
+
+    <xsl:if test="substring(./@name,1,4) = 'git_'">
+      <!--
+      <xsl:message>
+	<xsl:text>&#10;#Debug: OK, git function </xsl:text>
+	<xsl:value-of select="./@name"/>
+      </xsl:message>
+      -->
+
+      <xsl:call-template name="function"/>
+    </xsl:if>
+  </xsl:template>
+
+  <!-- If reaches here some element is not processed -->
+  <xsl:template match="/GCC_XML/*">
+    <xsl:message>
+      <xsl:text>&#10;#Error: No template for element </xsl:text>
+      <xsl:value-of select="local-name(.)"/>
+    </xsl:message>
+  </xsl:template>
+
+</xsl:stylesheet>