[stringtemplate-interest] StringTemplate type proxies
Terence Parr
parrt at cs.usfca.edu
Tue Dec 14 12:06:05 PST 2010
Ah! You are so correct! It only works on the values you pass through setAttribute. Ok, so the proposition is to simply add
registerProxy(ModelType, MyProxyType)
and have ST created new MyProxyType object with
new MyProxyType(aModelTypeObjectAttribute)
for each reference to a ModelType object? Won't that get inefficient? perhaps it should be like renderer and we create a single object to wrap any object?
$a.foo$ would invoke method MyProxyType.getFoo(a), right?
Am I going in the right direction?
Ter
On Dec 14, 2010, at 11:28 AM, Rafael Chaves wrote:
> Yup, renderers translate from whatever values to String. The decorator
> (not a proxy, as it augments the shape of the target object) allows
> obtaining the values.
>
> This should apply at any level in the model graph, not only top level
> attributes. Does setAttribute handle that?
>
> For instance: Package has Classes with have Attributes. I set only one
> attribute on the top-level template, to be the root package object,
> and then navigate the graph with several templates (one for packages,
> one for classes, and another for attributes).
>
> Will overriding setAttribute allow me to intercept how any arbitrarily
> deep object is handled?
>
> Cheers,
>
> Rafael
>
> On Tue, Dec 14, 2010 at 11:16 AM, Terence Parr <parrt at cs.usfca.edu> wrote:
>> Very convincing argument, folks. thank you. 3rd party models.
>>
>> Ok, so how do they interact with renderers? I guess the renderer is done *after* proxy stuff.
>>
>> Proxy: RandomModelObject -> MyWrapperForRandomModelObject, adds getFoo() or whatever.
>>
>> Then, if getFoo() returns type Date, renderer applies to that. I like it.
>>
>> I remember mentioning how to do this manually. just override setAttribute() so that it traps RandomModelObject and wraps.
>>
>> Does this need to be formalized or can it simply be a FAQ entry? it's a switch on type, look up in hashtable thing only right?
>>
>> Ter
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list