code-generation

Rails: creating a custom data type / creating a shorthand

拜拜、爱过 提交于 2019-12-03 06:47:56
问题 I am wondering how I could create a custom data type to use within the rake migration file. Example: if you would be creating a model, inside the migration file you can add columns. It could look like this: def self.up create_table :products do |t| t.column :name, :string t.timestamps end end I would like to know how to create something like this: t.column :name, :my_custom_data_type The reason for this to create for example a "currency" type, which is nothing more than a decimal with a

Programming languages that compile to native code and have the batteries included

浪尽此生 提交于 2019-12-03 06:02:49
问题 What are the programming languages that compile to native code and which have provided a comprehensive library with them? Libraries that includes functionality such as Networking, File IO, RegEx, Database, Graphics, Multimedia, Win32 API bindings, File compression, etc. 回答1: I'll assume everyone has thought of C and C++. Haskell is the obvious one here. In particular, if you want batteries included, you want the Haskell Platform. OCaml fits this category, as well. Go is a new player that has

Generating sources by running a project's java class in Maven

大憨熊 提交于 2019-12-03 05:58:27
I'm converting a largish Ant build to Maven. As part of the Ant build, we have several steps which created Java classes by invoking one of the project's classes, simplified as: javac SomeGenerator.java java SomeGenerator generated # generate classes in generated/ javac generated/*.java I've split each generator in its own Maven module, but I have the problem of not being able to run the generator since it's not yet compiled in the generate-sources phase. I've tried something similar to <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1.1<

Python generating Python

北战南征 提交于 2019-12-03 05:54:43
问题 I have a group of objects which I am creating a class for that I want to store each object as its own text file. I would really like to store it as a Python class definition which subclasses the main class I am creating. So, I did some poking around and found a Python Code Generator on effbot.org. I did some experimenting with it and here's what I came up with: # # a Python code generator backend # # fredrik lundh, march 1998 # # fredrik@pythonware.com # http://www.pythonware.com # # Code

How to use code generation to dynamically create C# methods?

萝らか妹 提交于 2019-12-03 05:52:39
In order to define a method in C that is callable by Lua it has to match a given signature and use the Lua API to retrieve parameters and return results. I'm writing a C# wrapper of Lua and I'm interested in being able to call arbitrary C# methods without making them follow these conventions. When wrapping in something like D, one might use the template system to dynamically create this glue code for any given method. I was thinking this might be possible as well in C#, but by using dynamic code generation. The C API looks something like this, and the generated code would manipulate this

Graphical Finite State Machine Editor [closed]

﹥>﹥吖頭↗ 提交于 2019-12-03 05:40:53
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I am looking for a sophisticated graphical FSM editor that can export a model in a well-documented output format, like SCXML or similar. Can anybody recommend me a tool? 回答1: I am only just now starting to look at YAKINDU - it looks like it might be a great graphical FSM tool built on top of the Eclipse

Are code generators bad?

点点圈 提交于 2019-12-03 05:11:22
I use MyGeneration along with nHibernate to create the basic POCO objects and XML mapping files. I have heard some people say they think code generators are not a good idea. What is the current best thinking? Is it just that code generation is bad when it generates thousands of lines of not understandable code? ConcernedOfTunbridgeWells Code generated by a code-generator should not (as a generalisation) be used in a situation where it is subsequently edited by human intervention. Some systems such the wizards on various incarnations of Visual C++ generated code that the programmer was then

T4 Get Current Working Directory of Solution

落花浮王杯 提交于 2019-12-03 05:04:25
问题 I am using T4 in Visual Studio 2010, and I want to iterate over the files in my solution, however I have found that T4 source generation works in a kind of a sandbox, and the current working directory is inside of the Visual Studio 10 directory in program files. Is there a way to reference the solution the T4 file is in relativistically, so that it doesn't break the build, or works on some one else's box that doesn't have the same file structure etc? Thanks 回答1: You must set the hostspecific

Generating LLVM Code from Java

半世苍凉 提交于 2019-12-03 04:51:40
I want to use the LLVM code generation Framework from Java. I.e., I do not want to compile Java code into LLVM. I simply want an LLVM library for code generation that I can call from Java. The usual LLVM library is C, so I cannot use it. Are there any Java ports? If no, what would be the easiest way to do it anyway? Wrap the API into JNI? A quick search for llvm java api bindings turned out several projects that seem like a good fit: LLVM-J JLLVM LAJ All of those libraries use JNI to access the C-API, so you have a DLL or SO file of the LLVM itself in any case. To answer the question with more

What are the limits to code generation from XML Schema in C#?

浪子不回头ぞ 提交于 2019-12-03 04:23:18
问题 I've seen several questions regarding problems with generating classes from XML Schema using xsd.exe , along with suggestions for how to pre-process the schema (often using XSLT) to resolve some of the trickier aspects prior to generation. My question is whether it's possible to construct a C# code generator that is 100% compliant with XML Schema. Are the problems with xsd.exe merely a question of its implementation, or do they point to a fundamental inconsistency between XML Schema and C#?