code-generation

Simple CRUD Generation

对着背影说爱祢 提交于 2019-12-04 21:56:39
问题 This is what I have: An entity-relational schema, modelled for Doctrine 2.0 (in PHP); The generated database, on a MySQL server. This is what I want: A very basic CRUD web-interface to the database, that allows me to (you guessed it!) create, read, update and delete records, with extra credit for implementing CRUD operations on entities and relations instead of records. Now, I'm terrible at writing web applications myself (read: I'm lazy). Are there any options to generate a CRUD web

Is there a Java parser for the Java language?

爷,独闯天下 提交于 2019-12-04 21:13:43
问题 I'm looking for a java library that allows me to parse a java source file and that gives me an AST representation of the code. Actually I'm only interested in the class and method definitions with their annotations. I don't need the AST of the method code. I'm using this information for code generation. This is why I can't compile the source file first to get the information from the resulting class file. The code wouldn't compile without errors until I generate some additional classes. 回答1:

Instance of an interface without an implementation class

无人久伴 提交于 2019-12-04 19:40:55
I have a JET Template that is meant to generate code for an interface implementation class. I am having trouble coming up with an executable test class that prints out this generated code because I am unable to get an object for the argument of the generate method created from the JET Template. I want the test class to work something like this: /** * An executable test class that prints out exemplary generator output * and demonstrates that the JET template does what it should. */ public class TestClass { public static void main(String args[]) throws ClassNotFoundException,

How to trigger T4 template from PowerShell script

别来无恙 提交于 2019-12-04 19:37:35
问题 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. 回答1: It looks like you can just invoke their command line utility, so you could create a script that just takes the location of your

Generate exe in .Net

爱⌒轻易说出口 提交于 2019-12-04 19:08:01
In .Net, you can generate byte code in memory, and presumably save the resulting program to a .exe file. To do the first step, I have the following test code adapted from http://www.code-magazine.com/Article.aspx?quickid=0301051 var name = new AssemblyName(); name.Name = "MyAssembly"; var ad = Thread.GetDomain(); var ab = ad.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run); var mb = ab.DefineDynamicModule("MyModule"); var theClass = mb.DefineType("MathOps", TypeAttributes.Public); var retType = typeof(System.Int32); var parms = new Type[2]; parms[0] = typeof(System.Int32); parms[1] =

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

牧云@^-^@ 提交于 2019-12-04 18:49:44
问题 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

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

情到浓时终转凉″ 提交于 2019-12-04 18:32:10
问题 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

Generating a model with many to many in Ruby on Rails

被刻印的时光 ゝ 提交于 2019-12-04 18:15:00
问题 Is there a way to generate a Rails model with a many to many relationship predefined? I know how to add it to the Active Record after the fact but it would be nice to have it defined in the DB migration and the Active Record model right off the bat. 回答1: Remember that you do not want an id for the join table, so make sure to add :id => false |t| create_table assemblies_parts, :id => false do |t| t.integer :assembly_id t.integer :part_id end If you use rails rails generate model Assemblies

How can I generate multiple classes from xsd's with common includes?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 17:29:01
Aloha I received a few nice xsd files which I want to convert to classes (using xsd.exe) All the xsd's have the same includes, like this: <xs:include schemaLocation="kstypes.xsd" /> <xs:include schemaLocation="ksparams.xsd" /> When I generate a class for each xsd the types declared in these files are duplicated for each original xsd. Is there any easy way to 1) only generate the types in the included xsd's once and 2) make sure all other classes use these types? -Edoode try the approach outlined here : http://blog.hosca.com/blog/fpmlgen/ Looking over the documentation, it would appear that the

Code generation with Scala

大憨熊 提交于 2019-12-04 17:00:16
问题 When using the SBT toolchain in Scala, is it possible to write a task that will read a special part of the project's source to generate scala-code at compile time. Any ideas or even articles/tutorials on this? I am looking for something rather similar to Template Haskell. 回答1: treehugger.scala is a library designed for code generation. import treehugger.forest._ import definitions._ import treehuggerDSL._ val tree: Tree = Predef_println APPLY LIT("Hello, world!") println(tree) println