[Seaside] concatenate JS assignments in script generation
Johan Brichau
johan.brichau at uclouvain.be
Mon May 31 18:27:35 UTC 2010
Hi Hernan,
You are right.
The implementation of JSObject>>#, (which does the concatenation as desired) is overridden on JSScript to add the statements to the body.
For now, I have added the JScript>>after: method which does the super call to the correct #, implementation.
I'm still a bit puzzled why the implementation is like that. It seems to break the composability property of JSObjects using concatenation, requiring a special case to concatenate JSFunction declarations (decorated or not).
Thanks a lot!
Johan
On 31 May 2010, at 19:17, Hernán Morales Durand wrote:
> Hi Johan,
>
> That's because #, is adding your var2 to the statements of var1. In
> Seaside 2.8 you may do something like
>
> factory := SUFactory on: (WARenderCanvas
> context: WARenderingContext new
> callbacks: WACallbackRegistry new).
> f1 := ( ( factory create: SUFunction ) assignTo: 'x' ).
> f2 := ( ( factory create: SUFunction ) assignTo: 'y' ).
> f1 after: f2
>
> in Seaside 3.0 it would be
>
> function1 := ( JSFunction context: ( WARenderContext new ) ) asFunction.
> function2 := ( JSFunction context: ( WARenderContext new ) ) asFunction.
> f1 := ( function1 assignTo: 'x' ).
> f2 := ( function2 assignTo: 'y' ).
>
> but I cannot find an #after: equivalence for JSFunction... so doing
>
> JSObject>>after: anObject
> "Call anObject directly after the receiver is evaluated."
>
> self addDecoration: (JSConcatenation on: anObject)
>
> then you may print
>
> f1 after: f2
>
> hope that helps
> Cheers,
>
> Hernán
>
> 2010/5/31 Johan Brichau <Johan.Brichau at uclouvain.be>:
>> Hi,
>>
>> I'm a bit puzzled with one of the JSScript features in Seaside 3.0.
>>
>> I'm trying to generate something like the following javascript:
>>
>> var1 = function() { ... };
>> var2 = function() { .... };
>>
>> Using the following Seaside code:
>>
>> script1 := ( ... ) asFunction assignTo: 'var1'.
>> script2 := ( ... ) asFunction assignTo: 'var2'.
>>
>> ^ script1 , script2
>>
>> However, the concatenation in the return puts all statements of script2 into the body of script1, rather than concatenate the assignments. The result is thus:
>>
>> var1 = function() { .... ; var2 = function() {...} }
>>
>> Variables script1 and script2 indeed contain a JSFunction object which is decorated with a JSAssign. So I must be missing something on how this decoration is supposed to work.
>> Hope somebody can help me :-)
>>
>> cheers!
>>
>> ----------------------------
>> Johan Brichau
>> johan.brichau at uclouvain.be
>>
>>
>>
>>
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
----------------------------
Johan Brichau
johan.brichau at uclouvain.be
More information about the seaside
mailing list