code-generation

T4 Templates - suitable for generating C++ code?

爱⌒轻易说出口 提交于 2019-11-30 20:47:09
Are there any issues which might make MS's T4 Template code-generation system unsuitable for generating C++ code? It can generate any text you want, including C++ code. A bit lengthy answer yet I think some might find it interesting I would say T4 is excellent to generate C++ with Some might retort that C++ already has tools to do MetaProgramming with like: The Preprocessor Using the preprocessor and higher-order macros you can achieve somewhat what you can do with T4, but I say there are some pretty convincing benefits of T4: The generated code from T4 is easy to debug and understand

What are some techniques for code generation?

荒凉一梦 提交于 2019-11-30 17:56:34
问题 I'm generating C++ code, and it seems like it's going to get very messy, even my simple generating classes already have tons of special cases. Here is the code as it stands now: http://github.com/alex/alex-s-language/tree/local%2Fcpp-generation/alexs_lang/cpp . 回答1: I wrote Cog partly to generate C++ code from an XML data schema. It lets you use Python code embedded in C++ source files to generate C++ source. 回答2: One technique I've used for code generation is to not worry at all about

C# code generator [closed]

Deadly 提交于 2019-11-30 17:56:26
Can someone recommend a simple c# code generator. I just looking something with methods like: GenClass = CreateNewClass(AccessModifier,Name......) GenClass.Add(new Method(AccessModifier,RetType,Name....){code=@"....."} GenClass.Add(new Property(AccessModifier,Type, Name....) ........... etc and after creating all classes\methods and other members we call Code Generation function(where we can specific some parametrs) Is there such opensource code generator? Check out Using CodeDOM to generate CSharp (C#) and VB code T4 or Text Template Transformation Toolkit might be worth looking into. Another

(Kotlin) Backend Internal error: Exception during code generation

纵饮孤独 提交于 2019-11-30 17:36:47
I am creating a very thorough converter for Android with Kotlin, using the latest Android Studio Canary build and latest Kotlin. I am suddenly getting a compiling error, even thought Android Studio doesn't see any bug in the code, it is complaining about a backend error, so I think my project is good but the Android Studio has a bug?? Please help confirm, this has been a lot of work.... It is complaining about my class MassCalc, which is 6500 lines long, because of many cases for conversion, so maybe that is the problem?? UPDATE The error does not occur when hitting Clean project or Rebuild

Eclipse auto-generation of serialVersionUID with each change

别等时光非礼了梦想. 提交于 2019-11-30 17:34:20
Eclipse nicely generates the serialVersionUID for me. But this seems to be passive code generation as the id won't be automatically updated as I change the file unless I do the generation again. Is there some way to have the serialVersionUID being generated every time I change the contents? The "Save Actions" don't seem to include such an option - has somebody found some way to do this? It would be nice that it could be combined with the IDE save actions or something similar so that I could revert the change if I were doing that doesn't affect the serialization. Best regards, Touko EDIT:

How to generate Spring WebMVC CRUD API

核能气质少年 提交于 2019-11-30 15:52:29
What I want to do is to create a full Spring WebMVC CRUD API from database tables/Hibernate JPA entities, into an existing Maven Web Project. What I want generate, to be precise: Spring WebMVC controller (mapping&implementation) The JPA entity (if not given) - ofc. using the standard generation built in to most IDEs Spring Data JPA repository Optionally modifying some other files (f.e. adding the entity to existing persistence.xml) Is there a project for this? What would be the best way to create something like this? What I had thought about: Standalone Java APP Maven subgenerators Eclipse

Generating all possible trees of depth N?

狂风中的少年 提交于 2019-11-30 15:48:05
I have several different types of tree nodes, each of which may have anywhere from 0 to 5 children. I'm trying to figure out an algorithm to generate all possible trees of depth <= N. Any help here? I'm having trouble figuring out how to recursively walk the tree given that each change I make to a node may expose new subtrees (or remove old ones). Here's a Python program I wrote up that I think does what you're asking. It'll return all of the possible trees given a starting node. Essentially, it boils down to a trick with bit manipulation: if a node has 5 children, then there are 2 5 = 32

How can I get PowerShell Added-Types to use Added Types

霸气de小男生 提交于 2019-11-30 15:24:14
I'm working on a PoSh project that generates CSharp code, and then Add-Type s it into memory. The new types use existing types in an on disk DLL, which is loaded via Add-Type. All is well and good untill I actualy try to invoke methods on the new types. Here's an example of what I'm doing: $PWD = "." rm -Force $PWD\TestClassOne* $code = " namespace TEST{ public class TestClassOne { public int DoNothing() { return 1; } } }" $code | Out-File tcone.cs Add-Type -OutputAssembly $PWD\TestClassOne.dll -OutputType Library -Path $PWD\tcone.cs Add-Type -Path $PWD\TestClassOne.dll $a = New-Object TEST

Generating Objective-c client side code for consuming Rest Services

狂风中的少年 提交于 2019-11-30 14:38:17
I am working on building an iPhone application that uses an external server to store most of the data. The server exposes all the required services using a REST API. Ideally I would like to generate the client side code in objective-c that can consume these services. Preferably these should return objects that I can easily use instead of having to parse the return XML. What options am I looking at ? I have researched quiet a bit on this and the closest to code generation I have seen is wsdl2objc . Since I also own the backend services I could make them SOAP based services, but I really prefer

likely(x) and __builtin_expect((x),1)

[亡魂溺海] 提交于 2019-11-30 14:17:32
I know the kernel uses the likely and unlikely macros prodigiously. The docs for the macros are located at Built-in Function: long __builtin_expect (long exp, long c) . But they don't really discuss the details. How exactly does a compiler handle likely(x) and __builtin_expect((x),1) ? Is it handled by the code generator or the optimizer? Does it depend upon optimization levels? What's an example of the code generated? I just tested a simple example on gcc. For x86 this seems to be handled by the optimizer and depend on optimization levels. Although I guess a correct answer here would be "it