code-generation

Automatically generate C++ file from header?

↘锁芯ラ 提交于 2019-11-28 17:53:12
I have a bunch of C++ header files with various class and function declarations. So far, when I've been writing the C++ source file implementations of the declared classes and functions, I've been manually: Copying the declarations from the header file to the corresponding source file. Deleting "class classname {" and the matching "};" Adding "classname::" onto the names of all the class functions. Replacing the semicolons after the function declarations with "{}". Deleting the keywords "virtual" and "static". Only after all that work, which doesn't really do anything, can I actually go about

Java code generation [closed]

纵然是瞬间 提交于 2019-11-28 17:51:15
What are the leading frameworks for java code generation? I am not looking for a DB or app generation tool. I have a skeleton of a class, and I need to generate it with different dynamic parts for different use cases. The majority of the class is identical, hence I want to run code that generates different flavors of the class. Anyone know a good framework? Thanks. stacker cglib is a powerful, high performance and quality Code Generation Library jet/velocity are using templates. If you're looking to generate a whole application check out JBoss Seam framework. Spring Roo AppFuse Note that these

JPA java code generation

久未见 提交于 2019-11-28 15:33:55
问题 I am specifically looking for JPA code generation technique First, what are all the project could generate JPA compliant code? (Eg. HibernateTools) Second, I would also like to customize the code generation utility, as it has to compliant to our corporate standards. If not, what are all the framework available to generate java code using reflection? so I can write from scratch. Note: I used eclipse to generate JPA code and refactor it repeatedly to make it compliant. 回答1: I also have

What's the use of metaprogramming?

戏子无情 提交于 2019-11-28 15:13:27
I've read: Wikipedia Code Generation vs. Metaprogramming The art of Metaprogramming Metaprogramming at c2.com and I confess some confusion at the purpose behind metaprogramming/code generation. Does anyone have a concrete example of where they use metaprogramming/code generation? Even better would be an accompanying explanation of why it was better than an alternative. edit : Would Thistle be considered metaprogramming? Imagine a guy who builds cars. Say it's the same thing as using a computer. At some point he realizes he's always doing the same thing, more or less. So he builds factories to

Are there alternatives to cglib? [closed]

帅比萌擦擦* 提交于 2019-11-28 14:58:35
Just out of curiosity, are there any (stable) open source projects for runtime java code generation other than cglib? And why should I use them? ASM java-asm CGLIB and almost all other libraries are built on top of ASM which itself acts on a very low level. This is a show-stopper for most people as you have to understand the byte code and a little bit of the JVMS to use it properly. But mastering ASM is most certainly very interesting. Note however that while there is a great ASM 4 guide , in some part of the API the javadoc documentation can be very concise if it is present at all, but it is

java partial classes

夙愿已清 提交于 2019-11-28 12:14:21
Small preamble. I was good java developer on 1.4 jdk. After it I have switched to another platforms, but here I come with problem so question is strongly about jdk 1.6 (or higher :) ). I have 3 coupled class, the nature of coupling concerned with native methods. Bellow is example of this 3 class public interface A { public void method(); } final class AOperations { static native method(. . .); } public class AImpl implements A { @Override public void method(){ AOperations.method( . . . ); } } So there is interface A, that is implemented in native way by AOperations, and AImpl just delegates

SBT generate code using project defined generator

和自甴很熟 提交于 2019-11-28 10:51:01
I'd like to compile a project which contains a java source generator and then compile the generated code within a single project. I.e: compile Generator.scala, run Generator.generate(outputDir), compile outputDir, package into a jar. I'm trying this: sourceGenerators in Compile <+= sourceManaged in Compile map { out => Generator.generate(out / "generated") } but sbt complains [error] Build.scala:1: object example is not a member of package org [error] import org.example.Generator Basically, sbt doesn't see Generator defined in the project it compiles. Is it possible to do it my way with sbt?

Dynamically generate classes at runtime in php?

空扰寡人 提交于 2019-11-28 09:38:27
Here's what I want to do: $clsName = substr(md5(rand()),0,10); //generate a random name $cls = new $clsName(); //create a new instance function __autoload($class_name) { //define that instance dynamically } Obviously this isn't what I'm actually doing, but basically I have unknown names for a class and based on the name, I want to generate the class with certain properties etc. I've tried using eval() but it is giving me fits over private and $this-> references... //edit Ok, obviously my short and sweet "here's what I want to do" caused massive strife and consternation amongst those who may be

Generating Java code from XML in Eclipse

青春壹個敷衍的年華 提交于 2019-11-28 09:31:28
I am working on a project that will have several Java classes that are very similar to each other, and that I would like to generate from XML files. What I would like to be able to do is change the Eclipse build process to do something like this: Compile the code generator Run the code generator, converting the XML to Java Compile the rest of the project I could do this all manually but I would prefer to be able to have Eclipse do it all for me. Example I want to be able to take a source XML file that looks like this: <command-list> <command name="DATE" /> <command name="GROUP"> <capability

XJC Generating Integer Instead of int

风格不统一 提交于 2019-11-28 09:24:22
The following schema should be generating two primitive int fields in a Value class, but instead generates a primitive int for the element and java.lang.Integer for the attribute . <?xml version="1.0" encoding="UTF-8"?> <xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/test" xmlns:test="http://www.example.com/test" elementFormDefault="qualified"> <xsd:element name="values"> <xsd:complexType> <xsd:sequence minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="test:value" /> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd