code-generation

Code generation in Maven

試著忘記壹切 提交于 2019-12-21 04:07:56
问题 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? 回答1: Sources should go

Framework for building structured binary data parsers?

99封情书 提交于 2019-12-21 04:05:04
问题 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

Python parser for Python-like language

这一生的挚爱 提交于 2019-12-21 03:52:14
问题 I'm looking to write a Python import filter or preprocessor for source files that are essentially Python with extra language elements. The goal is to read the source file, parse it to an abstract syntax tree, apply some transforms in order to implement the new parts of the language, and write valid Python source which can then be consumed by CPython. I want to write this thing in Python and am looking for the best parser for the task. The parser built in to Python is not appropriate because

Avoiding gcc function prologue overhead?

强颜欢笑 提交于 2019-12-21 03:43:05
问题 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

Is there Python Clang wrapper in the vein of pygccxml which wraps GCC-XML?

时间秒杀一切 提交于 2019-12-21 03:42:45
问题 For a long time now I've been using pygccxml to parse and introspect my C++ source code: it helps me to do some clever code-generation during our build process. Recently I've read a lot about the benefits of the LLVM stack, and especially the benefits that the LLVM Clang parser brings to C++ compilation. I am now wondering if there is any Python interface to Clang such that I could use it as the basis for some of my existing code generation tasks? 回答1: After further digging I found that in

Is Code Generation a Bad Thing?

[亡魂溺海] 提交于 2019-12-21 03:12:36
问题 This is a subjective question. Recently I have been trying to learn NHibernate. The problem with it is at least 2 fold: mapping xml file that needs to be coded by hand Entity Class that needs manual coding While NHibernate is a wonderful framework, but the need to write mapping file and to create entity classes that mimic the database tables are pain in neck to write. There are a few tools that can alleviate this problem, such as Castle ActiveRecord or NHibernate Fluent. But as much as those

Generate database schema from NHibernate mapping

故事扮演 提交于 2019-12-20 20:34:15
问题 Is it possible to generate the database schema from the Nhibernate mappings DLL? My requirements is for MySQL. If so, how do I do that? Are there tools/scripts for this? Open source/freeware tools? Additionally, can I use these tools to insert/update datasets to the database? 回答1: Have you tried using NHibernate's built-in schema generation tool? var cfg = new NHibernate.Cfg.Configuration(); cfg.Configure(); cfg.AddAssembly(typeof(AnEntityInYourMappingLib).Assembly); new NHibernate.Tool

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

点点圈 提交于 2019-12-20 18:37:19
问题 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

Debugging a generated .NET assembly from within the application that generated it

妖精的绣舞 提交于 2019-12-20 10:33:53
问题 The question in short: How can I debug the code generated during a debugging session on the generating program? (see code below) I am facing the following issue: I would like to debug into dynamically generated/compiled code from the application that generates it. I provided an oversimplified example to clarify it. This example doesn't need debugging! My real app generates many more lines and code that really justify debugging, believe me :-) I would like to know if there is a way to debug or

What are the best resources for learning CIL (MSIL)

一笑奈何 提交于 2019-12-20 09:23:23
问题 I'm an expert C# 3 / .NET 3.5 programmer looking to start doing some runtime codegen using System.Reflection.Emit.DynamicMethod. I'd love to move up to the next level by becoming intimately familiar with IL. Any pointers (pun intended)? 回答1: The best way to learn it, is to write something you understand, then look at the IL it created. Also, depending on what you are doing, you can use expression trees instead of emitting IL, and then when you compile the expression trees, those smart guys at