code-generation

How to trigger T4 template from PowerShell script

自闭症网瘾萝莉.ら 提交于 2019-12-03 14:02:06
In my VS2010 solution I have set of Powershell scripts and T4 templates based on T4Scaffolding NuGet, everything is working fine with scaffolding and related T4's, but in one of my scripts I need to trigger a T4 template located in another project. Any simple Powershel cmdlet for this? to just run the template with out passing any parameters or values. Thanks. It looks like you can just invoke their command line utility, so you could create a script that just takes the location of your .tt file. param([string] $T4Template) & "C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating

Is there a Java library to generate class files from an AST?

﹥>﹥吖頭↗ 提交于 2019-12-03 12:58:07
This page describes how I can use the code generator in javac to generate code given that I can build an AST (using a separate parser which I wrote). The technique involves editing javac's source code to basically bypass the Java parser, so that one could supply his/her own AST to the code generator. This could work, but I was hoping to do it in a slightly cleaner way. I want to include the code generating part of javac as a library in my project so I can use it to generate code, without bringing with it the rest of javac's source. Is there a way to do this with javac, or is there perhaps a

Framework for building structured binary data parsers?

浪子不回头ぞ 提交于 2019-12-03 12:23:34
I have some experience with Pragmatic-Programmer-type code generation: specifying a data structure in a platform-neutral format and writing templates for a code generator that consume these data structure files and produce code that pulls raw bytes into language-specific data structures, does scaling on the numeric data, prints out the data, etc. The nice pragmatic(TM) ideas are that (a) I can change data structures by modifying my specification file and regenerating the source (which is DRY and all that) and (b) I can add additional functions that can be generated for all of my structures

Why is an extra comma not allowed in a parameter list when it is allowed in a brace initialization?

…衆ロ難τιáo~ 提交于 2019-12-03 12:03:26
Following up on an old question of mine ( Is there any relevance to an extra "," in the end of a brace initialization? ) Are there any technical reasons why the parameter list in function declarations and function calls has not been made code-generation-friendly like the brace initialization? What I mean is: This is ok, the extra , is ignored: int generated_array[] = { 1, 2, 3, }; For consistency, wouldn't it also make sense to allow this? int someFunc( int v1, int v2, int v3, ){...} int ret_val = someFunc( 1, 2, 3, ); I cannot see how it would make compilation more complicated, but perhaps

Creating a class for an interface at runtime, in C#

↘锁芯ラ 提交于 2019-12-03 11:57:51
I'm looking at taking a set of objects, let's say there's 3 objects alive at the moment, which all implement a common interface, and then wrap those objects inside a fourth object, also implementing the same interface. The fourth object's implementations of methods and properties would simply call the relevant bits on those 3 underlying objects. I know that there will be cases here where it won't make sense to do that, but this is for a service multicast architecture so there's already a good set of limitations in place. My question is where to start. The generation of that fourth object

Generating methods with generic types with Asm bytecode generator (ClassWriter)

时光毁灭记忆、已成空白 提交于 2019-12-03 11:52:32
Defining simple getters and setters is easy using Asm (and fortunately it is even explained in their FAQ). But one thing that is not mentioned, and for which I have been unable to find documentation, is how to implement these using generic type information. I am actually able to determine generic type information itself quite easily (since code will take existing fields and/or methods and full generic type handling and resolution exists). I just need to generate generics version for types that have generic type included. I hope this is something as easy as modifying signature Asm ClassWriter

Can I automatically generate controller classes from FXML?

我的梦境 提交于 2019-12-03 11:46:48
问题 As I understand it, when using FXML to describe a Java FX scene, the controller class is written manually and it's member variables and methods can then be referenced from the .fxml file. When loading the scene using the FXMLLoader , member variables are set to the corresponding scene elements and methods are wired up to the corresponding events automatically. This works but is very cumbersome as changes need to be done in two places and any mistakes will only show up at runtime. I've seen

Code generation in Maven

大城市里の小女人 提交于 2019-12-03 11:28:35
I want to autogenerate some java classes from interfaces. My first thought was to write a code generator, and integrate it as a maven plugin. I was thinking of creating a maven plugin with a codegen goal that is called during the build process. So if I choose this route, how do I provide the plugin with the interfaces to be processed? And where should the generated files go? Are there any existing plugins that can be configured to generate default class implementations? Sources should go in {project.build.directory}/generated-sources/[plugin-id]/ Most plugins take configuration passed through

How do I generate C# code from WADL files?

你说的曾经没有我的故事 提交于 2019-12-03 11:15:14
问题 I am looking for a code generator than can generate C# code to access RESTful web services described by WADL files in a way similar to how wadl2java works. Doing som searching I came across the rest-api-code-gen project on Google Code, but although the latest source does in fact support C#, the REST Describe & Compile demo site does not. (The C# button is there, but it's disabled.) I realize I could download the source and set up my own server with the latest version, but I would prefer not

Avoiding gcc function prologue overhead?

早过忘川 提交于 2019-12-03 11:10:48
I've lately encountered a lot of functions where gcc generates really bad code on x86. They all fit a pattern of: if (some_condition) { /* do something really simple and return */ } else { /* something complex that needs lots of registers */ } Think of simple case as something so small that half or more of the work is spent pushing and popping registers that won't be modified at all. If I were writing the asm by hand, I would save and restore the saved-across-calls registers inside the complex case, and avoid touching the stack pointer at all in the simple case. Is there any way to get gcc to