[Laszlo-dev] where should runtime-specific chunks of LFC code go?

P T Withington ptw at openlaszlo.org
Thu Apr 6 19:52:12 EDT 2006


Which is why I wasn't totally kidding when I said traits.

I don't think there is an easy answer here.  There are always going  
to be little 1-line changes that you won't want to put in a separate  
file to be conditionally included.  I think to some extent you have  
to use your judgement.  Or take six months and design the kernel API  
that can be implemented for all targets and which the generic code  
builds on.

On 2006-04-06 16:45 PDT, Henry Minsky wrote:

> What I'm wondering about is what if my method needs to access instance
> properties, as well as runtime-specific stuff, i.e., if I want to say
>
> this.foo = browserspecific(this.bar)
>
>
>
> On 4/6/06, P T Withington <ptw at openlaszlo.org> wrote:
>>
>> So Henry would break out some support function and then define
>>
>> LzDataNode.stringToData = kernelStringToData;
>>
>> or something like that.  Hm, does this extend nicely to the class
>> syntax, or do you end up having to have your method be a wrapper that
>> calls your kernel function?
>>
>> On 2006-04-06 14:07 PDT, Max Carlson wrote:
>>
>>> Not if you think of a series of kernel services that provide the
>>> same features across runtimes.  Classes call into the kernel(s).
>>>
>>> -Max
>>>
>>> P T Withington wrote:
>>>> But that will be tough to do if we start writing classes.  I.e.,
>>>> it's hard to put just bits of a class in a separate file.
>>>> Oh wait.  Traits!  :P
>>>> On 2006-04-06 13:57 PDT, Max Carlson wrote:
>>>>> I was thinking kernel/as/*.as and kernel/js/*.js in a top-level
>>>>> directory.  That way, all the runtime-specific stuff is grouped
>>>>> together.
>>>>>
>>>>> -Max
>>>>>
>>>>> Henry Minsky wrote:
>>>>>> OK, I have two versions of a function, one for DHTML and one for
>>>>>> SWF. In the source code file I currently have
>>>>>> this conditionalized as follows in data/LzDataNode.lzs.
>>>>>> But if I want to be cleaner about separting out runtime-
>>>>>> independent code, how should I do this?
>>>>>> Shoud create two new separate files just to hold these two
>>>>>> versions of the function ? I.e., in the new kernel/ directory
>>>>>> make files for the two copies of this function, LzDataText.as
>>>>>> and lzDataText.js?
>>>>>> Or should I make a kernel/ subdirectory under the lfc/data
>>>>>> directory? That is, each subdir should have a kernel dir for
>>>>>> runtime-specific stuff?
>>>>>> if ($dhtml) {
>>>>>>     LzDataNode.stringToLzData = function( str, trimwhitespace ) {
>>>>>>         var doc;
>>>>>>         if (typeof(DOMParser) != "undefined") {
>>>>>>             // Mozilla :-)
>>>>>>             var parser = new DOMParser();
>>>>>>             doc = parser.parseFromString(str, "text/xml");
>>>>>>         } else {
>>>>>>             // IE :-(#
>>>>>>             doc = new ActiveXObject("Microsoft.XMLDOM");
>>>>>>             doc.async="false";
>>>>>>             doc.loadXML(str);
>>>>>>         }
>>>>>>         if ( doc.childNodes.length != 1 ) return null;
>>>>>>         var lfcnode = LzDataset.prototype.copyBrowserXML(doc,
>>>>>> true, 0);
>>>>>>         var fc = lfcnode.removeChild( lfcnode.getFirstChild
>>>>>> () );         if ( fc instanceof LzDataText ) return null;
>>>>>>         return fc;
>>>>>>     }
>>>>>> } else {
>>>>>>     LzDataNode.stringToLzData = function( str, trimwhitespace ) {
>>>>>>         var xmlobj = new XML();
>>>>>>         xmlobj.ignoreWhite = true;
>>>>>>         xmlobj.parseXML( str );
>>>>>>         if ( xmlobj.childNodes.length != 1 ) return null;
>>>>>>         var lfcnode = LzLoader.prototype.copyFlashXML(xmlobj,
>>>>>> trimwhitespace);
>>>>>>         var fc = lfcnode.removeChild( lfcnode.getFirstChild
>>>>>> () );         if ( fc instanceof LzDataText ) return null;
>>>>>>         return fc;
>>>>>>     }
>>>>>> }
>>>>>> --Henry Minsky
>>>>>> Software Architect
>>>>>> hminsky at laszlosystems.com <mailto:hminsky at laszlosystems.com>
>>>>>
>>>>>
>>>>>
>>>>> --Regards,
>>>>> Max Carlson
>>>>> OpenLaszlo.org
>>>
>>>
>>> --
>>> Regards,
>>> Max Carlson
>>> OpenLaszlo.org
>>
>>
>
>
> --
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com



More information about the Laszlo-dev mailing list