code-generation

Reducing template bloat with inheritance

Does anyone have experience reducing template code bloat using inheritance? i hesitate rewriting our containers this way: class vectorBase { public: int size(); void clear(); int m_size; void *m_rawData; //.... }; template< typename T > class vector : public vectorBase { void push_back( const T& ); //......

Type-safe generic data structures in plain-old C?

I have done far more C++ programming than "plain old C" programming. One thing I sorely miss when programming in plain C is type-safe generic data structures, which are provided in C++ via templates. For sake of concreteness, consider a generic singly linked list. In C++, it is a simple matter to define your own template class, and th...

Generating unmanaged C++ via CodeDom

Hello, I'm looking to programmatically generate unmanaged C++ code via CodeDom. It seems that the default implementation of CppCodeProvider is only capable of generating managed C++/CLI. Any alternatives out there? Thanks! ...

CodeDom and collection initializers

Is there a way to generate a dictionary initializer using the C# CodeDom? Are those supported at all? I would like to have: private IDictionary<string, string> map = new Dictionary<string, string> { { "Name", "Value" }, ... }; ...

Admin auto generation

Hi, I create custom CMS sites and then go ahead for the backend/admin side. Is there any tool out there to automatically create admin side of my sites, for example, based on table relationships or whatever customization we may put in place. PHPMaker seems to claim something like what i ask for but i have not used it. Any tool out there...

Way to generate a code that creates a constructor based on the current values of an object?

Hi, What I want to achieve is after loading my object from the database, to generate a code that will give me a block which initializes my object based on its current values so that I can use this code-block in my unit tests again and again without loading it from Db anymore. Is there any tool around to achieve such a goal for VS? tha...

How to create Item Templates that add more than one file?

I've created an Item Template for VS2008, per these instructions and it seems simple enough. However, is it possible to add more than one file to the project? For instance, let's say I create a AcmeWidget Item Template. When I select it in VS2008, I'd like it to create an AcmeScreen winForm and a AcmeScreenSetup winform. Is this poss...

Use hbm2ddl to generate SQL DDL for database schema update (without losing data)

I have been using hbm2ddl and hbm2java to build my database and POJOs for my project based on my XML mapping files (hbm.xml). I'm starting to get some real data now in the system, so re-running my ant script which drops the database and recreates everything is no longer a viable option since I want to keep the data. I have heard that the...

cheap way to mock an interface with no runtime overhead

Suppose I have an interface with lots of methods that I want to mock for a test, and suppose that I don't need it to do anything, I just need the object under test to have an instance of it. For example, I want to run some performance testing/benchmarking over a certain bit of code and don't want the methods on this interface to contribu...

Integrating DSLs with T4, and indicating script errors

Hi, everyone. I have an advanced T4 question and I'm hoping someone can help. I've created a SQL-like DSL, and the scripts are saved in '.satsql' files in my C# projects, like so; // contents of myqueries.satsql SELECT <column t1.Id> FROM <table mytable t1> I have a .tt file which loads the file and attempts to parse it. If it fails,...

How to load an arbitrary java .class file from the filesystem and reflect on it?

I want to make a command-line utility that does some operations based on reflection of external class files. I would pass in a path to .class files or source files(possibly wildcards). At some point during the execution, I need to get Class objects for each class, not knowing their package names beforehand. What would it take to do th...

generate service /dao layer for GWT/Spring/Hibernate/PostgreSQL

We're developing a webapp using GWT 2.0(not to AppEngine), Spring and Hibernate and trying to jumpstart by auto-generating as much code as possible. I've looked at http://stackoverflow.com/questions/1963672/spring-roo-vs-appfuse-generate-service-dao-layer. I tried appfuse but that did NOT work for me; Also, roo for GWT is not quite ther...

Can I automatically generate methods for Buttons, Checkboxes, etc. in Visual Studio 2010?

One way of doing it is double-clicking on each component and it will automatically create a method for you in Code-Behind file. But what if you have many components in your project, is there a quicker way to generate those methods rather than by double-clicking on each and every component? ...

What is the technique behind the code generation feature of UML tools

Hello everyone. I am an engineering student, and deciding upon my final year project. One of the many candidates is an online UML tool with code generation facilities. But I did not take compiler designing classes, so I am not much aware of the code generation techniques. I want to know about the techniques that I should look to stud...

Subsonic DB Schema Generation.

I was watching subsonic's simple repository demo. I came to know that DB schema can be generated from code. I think of code generation as usually domain layer from database. Where is this useful? ...

Addition of Custom Keywords to .net to be addressed by a Pre or Post build process

I am looking for a method to add custom keywords to the .net framework that offer "special" pre-complier benefits or are ignored by the compiler. Example I would like to do something like this public static factory class Foo<T> { public static create T Create(); } I would like to add a pre-compile event that translates that code...

Eclipse plugin for code generation

I have several classes like in the following example: abstract class AClass { boolean validate(){ return true; } } When another class extends AClass, I do it like this: class BClass extends AClass { @Override boolean validate() { if (!super.validate()) { return false; } // TODO validate return true...

JS code generation to avoid de facto open-sourcing my code?

I want to build a small library based on Raphael.JS for work, and none of us particularly like the idea of open sourcing our code. How insane would it be to write all the logic in Python and have it generate hardcoded JS for each "drawing", as a function of the input data? I know this could increase the size of the downloaded JS (espec...

T4 generating garbage ouput, tt file error free.

Hi, I'm trying to create a T4 template to generate a class for a specific task I need. However, something is broken with its output. The output file contains random garbage characters even when the .tt file is blank. I'm thinking it's something to do with the character encoding on the .tt file, maybe. I can successfully add a code g...

How to generate default empty array value in @interface using Java's CodeModel

I'm using Java's CodeModel to generate some annotations code. However, I can't find a way to indicate that a parameter's default value should be the empty array, expressed as {}. Example: public @interface Example { Class<?>[] groups() default {}; } I know I can use JDefinedClass#direct(String) to output raw code, but I would lik...