[Project_owners] Converting C code to Javascript/what am I doing wrong?

Neil Deakin enndeakin at sympatico.ca
Tue Aug 23 11:39:29 EDT 2005


Michael Vincent wrote:

> I'm trying to rewrite a perfectly working piece is code in JavaScript, 
> because I need something that isn't available, and I don't have a C 
> compiler nor do I want to build Mozilla myself simple because I can't 
> use it.
>
> The following code fails in RDFCUtils.MakeSeq() but I don't see why:
>
>   var kNC = "rdf:http://home.netscape.com/NC-rdf#";
>   var datasource = RDF.GetDataSource("rdf:bookmarks");
>   var livemarkResource = RDF.GetAnonymousResource();
>   var container = RDFCUtils.MakeSeq(datasource, 
> RDF.GetResource(livemarkResource.Value));
>
>
> It should do exactly the same as:
> http://lxr.mozilla.org/aviary101branch/source/browser/components/bookmarks/src/nsBookmarksService.cpp#2845 
>
>
It doesn't do exactly the same. Your code calls MakeSeq with the 
bookmarks datasource, whereas the bookmarks service calls it with the 
inner in-memory-datasource that actually stores the bookmarks. The 
former doesn't allow some kinds of changes to be made (see 
nsBookmarksService::CanAccept).

/ Neil



More information about the Project_owners mailing list