-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More concise way to render param types and values #136
Comments
I'm almost done with this feature (coming soon!) This is slightly related to #142. |
…ting input arrays * By using a modified version of jmte, with the ${<X} token
I just found out a fundamental design error, which causes this issue (messy template) and also related to #142 and #151. That is, the ParamValue class, should not try to cover both array values and normal values. The right design should be two separate classes, ParamValue and ParamValueList, in which ParamValueList contains a list of ParamValue. In this case, the language renderer should be able to render ParamValueList separately and get the correct format. User can choose between render the ParamValueList directly or foreach over its values and render each ParamValue. Right now the code is wrong when try to convert to values from TC API model to greed model. In AbstractLangauge.java line 64, the renderParamValue method is called. However, no rendering should happen at this time. The data model should be language independent and the rendering is delayed to the code generation phase. |
@shivawu I totally agree with you. Actually, I had caught the deficit and was making a way to fix this. As I previously mentioned in the other issues, the |
Yes, please share your working branch and I'll take a look, then we can find the best way to do this. |
What do you think of this commit? It basically separate the ParamValue and ParamValueList, and the templates are still the same. This is only a proposal, if you have better solutions, that would be great. |
@shivawu Hello, we were maybe too busy these days. I finally managed to continue my previous refactoring and improvements on this issues: it's almost done. I am now sharing my branch, please feel free to look at it. Technical details on the implementations you might be interested in can be found in the commit messages. |
@wookayin I've gone through your change of param value briefly, got a few questions. Also, when I implement my branch (param-value), I found that when we start a rendering process, the language related engine is fixed, so when rendering the data template, there's no way for the engine to know that here we must use a bare engine instead of the language specific engine. So your way to solve this problem, is to distinguish the argument (which is a pure value), and the param value (which is language related), and use argument in the data template rather than the param value to render it to its canonical form, it this right? |
I am sorry I missed your previous comment. Here are my answers: as of current branch (up to commit cca51df),
Actually the names have to be exchanged ( I had already noticed this, but it seems to be introducing a backward-incompatibility on templates; so we might need some discussions. I remember that I once wrote a commit of exchanging those class names, but I see I didn't attached the commit into this branch. It looks that you agree with this, don't you? |
And yes, to distinguish the argument (currently The value's are rendered into appropriate forms (e.g. |
The old way
For example, we have templates such as
or
Suggestion
A little messy, isn't it? Instead, I imagine a way that the parameter value is rendered directly in a polymorphic way: if it was a scalar, render it as-is, and if was a vector, render it in the way the compiler can interpret it.
We can know the language trait informations and the way how the parameter values should be rendered, given the context and the options.
The new way
Here are examples:
__expected = ${e.Output}
1
or"YES"
or3.14159265358979
...${e.Output}
renders into the form of {1, 2, 3, 4, 5}. The modified render emits (1, 2, 3, 4, 5) -- the tuple, which is the way it should be written in python.or
Type
becomes, for example,int
,vector<int>
,vector<long long>
(in C++), orint[]
(in Java), and so on...${in}
(orin.Value
?) becomes3
,{1, 2, 3}
, ... (no foreach blahblah)${in.Declaration}
-- writing the variable declaration code in the Java code, not in the template?Remarks
String[]
maybe), there are lots of things to be concerned.The text was updated successfully, but these errors were encountered: