[Laszlo-dev] still confused about referencing node id's from methods
P T Withington
ptw at openlaszlo.org
Tue Apr 1 10:59:42 PDT 2008
It's actually in LzRuntime. And if you chase everything down, it
eventually aliases to `this` which in every other runtime is the
actual global object. But perhaps this is where the problem lies, and
we need to do something different for swf9?
Index: LzRuntime.lzs
===================================================================
--- LzRuntime.lzs (revision 8509)
+++ LzRuntime.lzs (working copy)
@@ -25,7 +25,11 @@
/**
* Define runtime module
*/
+if ($swf9) {
+$modules.runtime = global;
+} else {
$modules.runtime = this;
+}
/**
* Define LZ module
@@ -45,7 +49,10 @@
* Define global
* TODO [2006-03-12 ptw] if the LFC is shared this needs to be
multiplexed
*/
+if ($swf9) {
+} else {
var global = $modules.user;
+}
if ($debug) {
/**
On 2008-04-01, at 13:42 EDT, Henry Minsky wrote:
> In LzDefs.lzs there is this declaration
> /**
> * Define global
> * TODO [2006-03-12 ptw] if the LFC is shared this needs to be
> multiplexed
> */
> var global = $modules.user;
>
>
>
> On Tue, Apr 1, 2008 at 1:36 PM, P T Withington <ptw at openlaszlo.org>
> wrote:
>
>> That's a huge change from JS1. There must be some way to do this.
>>
>> Supposedly there is an 'unnamed package' whose top-level
>> definitions are
>> accessible to the entire program. So we just have to figure out
>> how we put
>> our global definitions there. I'm not creating any `global`
>> object, just
>> setting properties on it, so I was assuming that `global` was an
>> alias for
>> this unnamed package.
>>
>> I would think you would get an error trying to install the global
>> property
>> if that were not true.
>>
>> Maybe I don't understand about creating globals dynamically.
>>
>>
>> On 2008-04-01, at 13:26 EDT, Henry Minsky wrote:
>>
>>> But we have to explicitly do a "with (...) " of that object to get
>>> the
>>> vars
>>> in scope. I think only other way to get globals is to have it in
>>> its own
>>> .as
>>> file at compile time like we do with various globals like the
>>> compiler
>>> flags
>>> ($swf9, etc)
>>> package {
>>> public var foo = 259;
>>> }
>>>
>>>
>>>
>>>
>>> On Tue, Apr 1, 2008 at 1:03 PM, P T Withington <ptw at openlaszlo.org>
>>> wrote:
>>>
>>> I don't understand. Isn't global supposed to be the outermost scope
>>>> and
>>>> where free refs will be looked up?
>>>>
>>>>
>>>> On 2008-04-01, at 11:25 EDT, Henry Minsky wrote:
>>>>
>>>> This code
>>>>> <view id="v1" width="100" height="20" bgcolor="red"/>
>>>>> <view id="v2" width="100" height="20" y="100" x="${v1.x +
>>>>> v1.width
>>>>> +
>>>>> 20}"
>>>>> bgcolor="blue"/>
>>>>>
>>>>> compiles to a constraint method:
>>>>> $lzc$bind_x$v2_$m10:
>>>>> function ($lzc$ignore = null) {
>>>>> this.setAttribute("x", v1.x + v1.width + 20);
>>>>> }
>>>>>
>>>>>
>>>>> $lzc$dependencies_x$v2_$m10:
>>>>> function () {
>>>>> return [v1, "x", v1, "width"]
>>>>> }
>>>>>
>>>>>
>>>>> But nodes which have id's set them on the "global" object. So how
>>>>> can
>>>>> we
>>>>> expect these references to work? Did we decide we need
>>>>> to put with (global) {...} around all method bodies? Or have the
>>>>> compiler
>>>>> find all id's at compile timeand make real top level vars for
>>>>> them?
>>>>>
>>>>> --
>>>>> Henry Minsky
>>>>> Software Architect
>>>>> hminsky at laszlosystems.com
>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> Henry Minsky
>>> Software Architect
>>> hminsky at laszlosystems.com
>>>
>>
>>
>
>
> --
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com
More information about the Laszlo-dev
mailing list