• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Converting error codes to readable strings?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting error codes to readable strings?


  • Subject: Re: Converting error codes to readable strings?
  • From: Camillo Lugaresi <email@hidden>
  • Date: Fri, 3 Feb 2006 16:48:25 +0100

On 03/feb/06, at 14:36, Jonathan del Strother wrote:


What's with the [High Spam] in your subject, btw?

Good question. For some reason MailScanner decided your message had a high probability of being spam. Fortunately Mail.app wasn't quite so easily fooled...

Ah. BTW, your question made me realize that I wanted to print error names too, so I ended up implementing the scheme I suggested before, using SWIG instead of GCC-XML. In case anyone is interested, the process goes like this:


swig -xml -module errors -o NSXMLParser.xml /System/Library/ Frameworks/Foundation.framework/Versions/C/Headers/NSXMLParser.h
xsltproc enum.xsl NSXMLParser.xml | xmllint --format - > errors.plist


using the stylesheet below. SWIG does not grok Objective-C method declarations, but it's ok since it keeps parsing the file anyway. The result is a plist containing all enums in the file as dictionaries. Filtering and support for #defines can be easily added.

Camillo

-----8<----- enum.xsl -----8<-----
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
				version="1.0">

<xsl:output encoding="UTF-8"
	doctype-public="-//Apple Computer//DTD PLIST 1.0//EN"
	doctype-system="http://www.apple.com/DTDs/PropertyList-1.0.dtd"; />

<xsl:template match="/">
	<plist version="1.0">
		<array>
			<xsl:apply-templates select="//enum"/>
		</array>
	</plist>
</xsl:template>

<xsl:template match="enum">
<dict>
<key>enumeration</key>
<string><xsl:value-of select="attributelist[1]/attribute [@name='name']/@value"/></string>
<key>values</key>
<dict>
<xsl:apply-templates/>
</dict>
</dict>
</xsl:template>


<xsl:template match="enumitem">
<key><xsl:value-of select="attributelist[1]/attribute [@name='enumvalue']/@value"/></key>
<string><xsl:value-of select="attributelist[1]/attribute [@name='name']/@value"/></string>
</xsl:template>


</xsl:stylesheet>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Converting error codes to readable strings? (From: Jonathan del Strother <email@hidden>)
 >Re: Converting error codes to readable strings? (From: Camillo Lugaresi <email@hidden>)
 >Re: [High Spam] Re: Converting error codes to readable strings? (From: Jonathan del Strother <email@hidden>)
 >Re: Converting error codes to readable strings? (From: Camillo Lugaresi <email@hidden>)
 >Re: Converting error codes to readable strings? (From: Jonathan del Strother <email@hidden>)

  • Prev by Date: Re: Objective-C or Objective-C++
  • Next by Date: Re: Notification of selection change/no selection from NSBrowser?
  • Previous by thread: Re: Converting error codes to readable strings?
  • Next by thread: Re: [High Spam] Re: Converting error codes to readable strings?
  • Index(es):
    • Date
    • Thread