code-generation

Java Hangman Project: Action Listener

喜夏-厌秋 提交于 2019-12-10 17:09:08
问题 I am creating a hangman game. I made a button A - Z using the GUI Toolbars in Netbeans as follows:. My problem is, how can I add an actionlistener to all of it. Is it possible to use a loop? If i click the button A, i will get the character 'a' and so on.. 回答1: Yes it is possible to use a loop, but since your JButtons were created by using NetBeans code-generation, they won't be in an array or collection initially, and so this is something that you'll have to do: create an array of JButton

Generating database tables from object definitions

旧时模样 提交于 2019-12-10 15:44:45
问题 I know that there are a few (automatic) ways to create a data access layer to manipulate an existing database (LINQ to SQL, Hibernate, etc...). But I'm getting kind of tired (and I believe that there should be a better way of doing things) of stuff like: Creating/altering tables in Visio Using Visio's "Update Database" to create/alter the database Importing the tables into a "LINQ to SQL classes" object Changing the code accordingly Compiling What about a way to generate the database schema

Optimal JAXB XJC code generation and optimal XML schema with inheritance

走远了吗. 提交于 2019-12-10 15:07:46
问题 There have been a lot of similar questions which focus on one aspect to optimize but each solution had an ugly downside. Suppose I want to develop an XML schema (XSD) which allows the following documents and want to generate classes using XJC: <Catalogue> <Book>...</Book> <Journal>...</Journal> <Book>...</Book> ... </Catalogue> The schema should model the type hierarchy ( Book and Journal are subclasses of Publication ). Naturally, this should also be the case for the generated Java classes.

Code generation and make rule expansion

白昼怎懂夜的黑 提交于 2019-12-10 11:38:39
问题 Assume I have a make rule: .PHONY:gen gen: auto.template generate-sources auto.template that creates a bunch of files, for example auto1.src , auto2.src , auto3.src and so on. If I now have rules to build targets from *.src files, like this: $(patsubst %.src,%.target,$(wildcard *.src)): %.target: %.src build $< > $@ How can I tell make to first execute the gen rule and then expand the preconditions for the second rule template? GNU extensions are welcome. Note : I would like to keep it in one

Generating more than one output file from a template

倾然丶 夕夏残阳落幕 提交于 2019-12-10 11:17:38
问题 Hi I am writing a custom template generator for my xml file. I was wondering if you guys can tell me a way I can generate more than one output file from the template under the same template. The no of file should depend on the no of xml files I input If I want to generate the c# class for a.xml I am doing something like this <#= XmlToCsGenerator.Xml(this.Host.ResolvePath("a.xml")) #> where my function XmlToCsGenerator.Xml(string path) returns the string to be written into the file. Thanks in

C++11 source code generation

本秂侑毒 提交于 2019-12-10 11:03:13
问题 Is there some sort of library for C++ which contains classes which represents C++ source code? It should of course be able to output the source code to a stream. I'm looking for something which supports most C++11 features and is also capable of generating templated constructions. When I google for this, I'm not getting the results I want. I'm sure though, that there is something available. Maybe I'm just using the wrong terms. 回答1: Check out the Clang compiler which uses a library-based

Generate Invokedynamic with Javassist

邮差的信 提交于 2019-12-10 10:24:32
问题 I am trying to do something relatively simple, I think. Take for example the following Java bytecode for a method doSomething(int): public java.lang.String doSomething(int i); 0 iload_1 [i] 1 invokestatic MyHelper.doSomething(int) : Java.lang.String 4 areturn This bytecode pretty much only forwards the call to a static helper. What I want to do now is to replace the invokestatic with invokedynamic using Javassist. I know how to do this with ASM therefore just assume that I want to know how it

Export template haskell generated definitions

安稳与你 提交于 2019-12-10 07:00:11
问题 My module contains definitions, part of which are exported (in module clause). I want to export Template Haskell-generated declarations too. But since there is seemingly no way to modify module clause with TH, I cannot do this. Is it possible to specify that TH-generated declarations should be exported at all? Or maybe there are other ways to do this? 回答1: You need to export the names of the generated TH declarations. For example, if you have a TH function that generates a data B = C | D

Running TextTransform.exe (T4) on a build server

冷暖自知 提交于 2019-12-10 03:36:44
问题 I am trying to setup a process where my T4 templates will be transformed on the build server (Visual Studio is not installed there). I've read all online references, but could not get a clear source that shows how to do this. Specifically, here's the 2 issues i've encountered: TextTransform.exe throws an error about missing DLL: C:\TeamCity\buildAgent\work\AppSettings.tt(0,0) : error CS0006: Compiling transformation: Metadata file 'Microsoft.VisualStudio.TextTemplating.Interfaces.10.0,

x86 instruction encoding tables

倖福魔咒の 提交于 2019-12-10 01:57:03
问题 I'm in middle of rewriting my assembler. While at it I'm curious about implementing disassembly as well. I want to make it simple and compact, and there's concepts I can exploit while doing so. It is possible to determine rest of the x86 instruction encoding from opcode (maybe prefix bytes are required too, a bit). I know many people have written tables for doing it. I'm not interested about mnemonics but instruction encoding, because it is an actual hard problem there. For each opcode number