Re: API of Tidy-lib

Charlie Reitzel <[email protected]> Sat, 07 Jan 2006 10:17:18 -0500
Newsgroups gmane.comp.web.html-tidy.devel
Message-ID <[email protected]>
It is perhaps an oversight that the generic function was not exposed in the 
public interface.  The equivalent, of course, makes sense for 
attributes.  Certainly, the tidyAttrGetById( TidyNode tnod, TidyAttrId 
attId ) and similar make sense as well.  The HTML tag and attribute enums 
exist (see TidyTagId and TidyAttrId in tidy-enum.h).

Note, tidyNodeGetId() and tidyAttrGetId() are both available.

/* E.g. */
if ( tidyNodeGetId(tnod) == TidyTag_HTML )
{
   /* do something */
}

As you say, what you want mostly exists as macros.  For example, 
TagIsId(node, tid), defined in tags.h.  It would be just a couple lines to 
expose these in tidy.h/tidylib.c - which I would certainly have no problem 
with.

My reasons for providing the expanded set of node identification entry 
points were probably a) readability b) most external code depends only only 
a handful of tags/attributes and c) it does promote binary 
compatibility.  If the enum values change, client code breaks.  An entry 
point like tidyNodeIsA(), however, will not.

I don't think either of these issues is critical.  Readability is in the 
eye of the beholder, so you may reach a different conclusion for the same 
reason.

In practice, binary compatibility is an elusive goal.  It only really works 
if you have a strong discipline around major and minor version 
numbers.  I.e. only add enums to the end, only add new entry points, etc., 
until the next major version.  That way, binary compatibility can be 
guaranteed for each major version number.  Per group consensus, Tidy has 
never followed such a strict release process.

At 08:05 AM 1/7/2006 +0100, Robert Marquardt wrote:
>Why does Tidy-lib has these families of functions tidyNodeIsHTML, 
>tidyAttrIsHREF, tidyAttrGetHREF?
>It would be much simpler to replace each family by a single function with 
>an additional enum parameter. In fact the implementation is precisely 
>doing that by using AttrIsId.
>--
>Robert Marquardt (Team JEDI)  http://delphi-jedi.org



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click