[Jslib] Bug in RemoteFile?

Pete Collins pete at mozdev.org
Sat Nov 29 09:35:10 EST 2003


Karsten Düsterloh wrote:
> Pete Collins aber hob zu reden an und schrieb:
> 
>>Yes, this actually raises an issue I haven't obviously tested thoroughly 
>>enough for, constant/namespace collision among libs.
> 
> 
> Maybe you can use the context argument of loadSubScript
> 
> 	Include: function(asURL, aoContext)
> 	{ ...
> 	  oLoader.loadSubScript(asURL, aoContext);
> 	  ...
> 	}
> 
> So that a script file F with
> 
> 	const x = 42;
> 	function y(){};
> 
> can be loaded into another context
> 
> 	var obj = {}
> 	Include("F", obj);
> 	obj.x;	// x in F
> 	obj.y() // y in F
> 
> Of course you're getting a (maybe unwanted) "in-between" layer this way...


Actually I think just using the proper namespace in this case is what is 
needed.


const JS_REMOTEFILE_IOSERVICE      = C.classes[JS_FILE_IOSERVICE_CID].
                              getService(JS_FILE_I_IOSERVICE);


This will ensure there isn't const collision and follows the style 
guidelines I am breaking here the the remote file class. :)

--pete

-- 
Pete Collins
www.mozdev.org
www.mozdevgroup.com



More information about the Jslib mailing list