[Laszlo-dev] Re: Dynamic libraries and resources
Oliver Steele
steele at laszlosystems.com
Fri Jan 7 14:27:50 PST 2005
Here's a possible implementation for dynamic library resources:
The basic idea is to turn all resources into dynamic resource requests.
No resource is compiled into a dynamic library file; instead, all
resources referenced in dynamic libraries are loaded dynamically. With
keepalive, this doesn't incur appreciable bandwidth or connection
overhead. (There are a few more http headers.) It does create a
timing window during which the dimensions of a resource, or a view that
it is attached to, aren't available.
For <view src="logo.jpg"/>, this is an easy change: just turn <view
src="logo.jpg"/> into <view src="http:{path}logo.jpg"/>, where {path}
is the relative path from the canvas file to the library file. (I
think there's already code that does this pathname adjustment for <view
src="http:logo.jpg"/> in a static library source file, so the dynamic
library case could just transform <view src="logo.jpg"/> to <view
src="http:logo.jpg"/> and then fall through.)
For <resource name="logo" src="logo.jpg"/> in a library, generate code
that adds an entry "logo" -> "{path}logo.jpg" to a table for that
library. view.setResource(name) looks up whether there's an entry for
"logo" for the current library, and call setSource(url) on the value of
that entry if there is. Otherwise it falls through to the other cases.
For this to work, you do need to know which library a view or instance
is in. LzInstantiate could set this, for example if the beginning of
each library set a global to the value of the current library and the
end unset it (not sure if this works if two libraries are loading at
once, though).
This implementation strategy would have the advantage that it would
have the side effect of implementing named dynamic resources, e.g.
<resource name="logo" src="http:logo.jpg"/>. This has been a frequent
request.
More information about the Laszlo-dev
mailing list