您是否使用代码生成工具(除了那些用于生成代理的工具和内置于visual studio的设计器)?
您生成的应用程序的哪些部分?
你经常推自己的发电机吗?如果是这样,你会写什么类型的生成器(asp模板,代码等).如果没有,你使用什么第三方工具?
我目前正在开发一些不同的项目,它们都使用自定义代码生成器来处理从生成数据库结构,业务实体,DAL和BLL的所有内容.我很好奇其他人的经历是用这些工具.
我正在重写我的汇编程序.在此期间,我对实施反汇编感到好奇.我想让它变得简单和紧凑,并且我可以利用这些概念.
可以从操作码确定x86指令编码的其余部分(也可能需要前缀字节,一点).我知道很多人都写过表格.
我对助记符和指令编码不感兴趣,因为那是一个实际的难题.对于每个操作码编号,我需要知道:
sandpile.org有一些我需要的东西,但它的格式不容易解析.
在我开始自己编写和验证这些表之前,我决定写这个问题.你知道这种桌子存在吗?在一种不需要太多努力解析的形式.
b byte
w word
v word or dword (or qword), depends on operand size attribute (0x66)
z word or dword (or dword), depends on operand size attribute
J instruction-relative address (next character describes type)
G instruction group, has modrm-field (next character describes operand type)
R has modrm-field (next two characters describe register and operand type)
M modrm, but operand field must point to memory
O direct offset (next …Run Code Online (Sandbox Code Playgroud) 有没有人有使用继承减少模板代码膨胀的经验?
我犹豫以这种方式重写我们的容器:
class vectorBase
{
public:
int size();
void clear();
int m_size;
void *m_rawData;
//....
};
template< typename T >
class vector : public vectorBase
{
void push_back( const T& );
//...
};
Run Code Online (Sandbox Code Playgroud)
我应该保持最大的性能,同时减少编译时间
我也想知道为什么stl实现不使用这种方法
感谢您的反馈
我目前正在学习D,我想知道的一件事是D是否有办法复制JVM语言的代码生成功能.
这是一个场景:我有一个对象,我想基于该对象生成一个字符串,该字符串给出了它的名称及其所有字段.在Java/Scala中,我可以使用反射,但假设速度是一个问题.我可以使用字节码生成库来动态生成和编译一个没有反射的类.实现将分解为迭代对象的字段并通过递归获取其名称,并使用该信息动态生成直接访问字段的Java(或字节码).
如果您不喜欢这种情况,因为它很弱和/或不现实,另一个可能更现实的是优化对象序列化.
我已经看过D编译时评估和/或模板元编程用于编译时预先计算斐波那契序列和其他递归算法的例子,但有没有办法用这种语言和编译器做这样的事情,或者你需要开发一个单独的代码生成器并在编译器之前运行它以获得这种功能?
我正在使用protobuf-net,我正在尝试:
这分别很容易使用:
protogen.exe 工具Serializer<T>.GetProto() 方法但问题是我需要支持protobuffer 自定义选项,但它似乎并不像我那样简单.
让我解释:
基本上,给出:
message person {
option (my_message_option) = true;
optional string firstname = 1 [(my_field_option) = 42];
optional string lastname = 2 [(my_field_option) = 12];
optional int age = 3;
}
Run Code Online (Sandbox Code Playgroud)
我想生成:
[ProtoContract, MyMessageOption(true)]
public class Person
{
[ProtoMember(1), MyFieldOption(42)]
public string Firstname;
[ProtoMember(2), MyFieldOption(12)]
public string Firstname;
[ProtoMember(3)]
public string Firstname;
}
Run Code Online (Sandbox Code Playgroud)
......反之亦然.
备注:
my_message_option和
my_field_option)已经存在于protofile中(例如,my_custom_options.proto),自定义属性类也可以存在于某个地方(MyMessageOptionAttribute和
MyFieldOptionAttribute).是否有将Java对象序列化为Java代码的实现?例如,如果我有对象
Map<String,Integer> m = new Map<String,Integer>();
m.put("foo",new Integer(21));
Run Code Online (Sandbox Code Playgroud)
我可以使用它来序列化
ObjectOutputStream out = new ObjectOutputStream( ... );
out.writeObject( m );
out.flush();
Run Code Online (Sandbox Code Playgroud)
例如,输出就是
java.util.Map<String,Integer> m = new java.util.Map<String,Integer>();
m.put("foo",new Integer(21));
Run Code Online (Sandbox Code Playgroud)
你为什么要这个?有时,以编程方式部分创建复杂对象更容易,然后在代码中手动完成创建.然后可以将此代码包含在源代码中,并使用其他所有内容控制版本.请注意,使用外部序列化对象不是例外.
谢谢你提供的所有帮助.
当我在eclipse中生成hibernate类时,所有类文件都在更新,尽管现在在数据库中进行了真正的更改.大多数文件中唯一的变化是注释行:// 2011年6月15日上午6:50:40由Hibernate Tools 3.4.0.CR1生成.
每次再生时该线的改变是不方便的,因为它破坏了对SVN变化的跟踪.
有没有指示生成过程不产生这条线?
我正在使用XSD在C#中定义我的DTO类型.我正在使用XSD.exe来生成XSD的类.
我有一个定义地址类型的Common.xsd,我想在多个类中使用它:
<xs:complexType name="Address">
<xs:sequence>
<xs:element name="Street1" type="xs:string"/>
<xs:element name="Street2" type="xs:string"/>
<xs:element name="City" type="xs:string"/>
<xs:element name="State" type="xs:string"/>
<xs:element name="Zip" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Address" type="mhm:Address"/>
Run Code Online (Sandbox Code Playgroud)
我在XSD公司中引用它:
<xs:include schemaLocation=".\Common.xsd"/>
<xs:complexType name="Company">
<xs:sequence>
<xs:element name="AdmCode" type="xs:string"/>
<xs:element name="CompanyCode" type="xs:string"/>
<xs:element name="Name" type="xs:string"/>
<xs:element ref="mhm:Address"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Company" type="mhm:Company"/>
Run Code Online (Sandbox Code Playgroud)
员工XSD:
<xs:include schemaLocation=".\Common.xsd"/>
<xs:complexType name="Employee">
<xs:sequence>
<xs:element name="EmployeeNumber" type="xs:int"/>
<xs:element name="FirstName" type="xs:string"/>
<xs:element name="LastName" type="xs:string"/>
<xs:element name="Address" type="mhm:Address"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Employee" type="mhm:Employee"/>
Run Code Online (Sandbox Code Playgroud)
我使用这个命令行生成类:
xsd .\XSD\Common.xsd /c /o:. /n:"DomainModel"
xsd .\XSD\Employee.xsd /c /o:. …Run Code Online (Sandbox Code Playgroud) 对于编写编译器,使用LLVM IR vs C作为目标语言有哪些优缺点?我知道两者都被使用了,我想如果我使用clang来编译C,那么最终的机器代码会是相似的.那么还有什么需要考虑的事情呢?
请考虑以下代码段:
void f();
void a() { f(); }
void b() noexcept { f(); }
Run Code Online (Sandbox Code Playgroud)
在上面的场景f中,当前转换单元中的编译器看不到正文.因此,由于b已标记noexcept,因此必须在调用方生成其他代码,以确保捕获并std::terminate调用异常.
这就是clang++ -Ofast -std=c++2a做(主干版本):
a(): # @a()
jmp f() # TAILCALL
b(): # @b()
push rax
call f()
pop rax
ret
mov rdi, rax
call __clang_call_terminate
__clang_call_terminate: # @__clang_call_terminate
push rax
call __cxa_begin_catch
call std::terminate()
Run Code Online (Sandbox Code Playgroud)
但是,g++ -Ofast -std=c++2a不(主干版):
a():
jmp f()
b():
jmp f()
Run Code Online (Sandbox Code Playgroud)
怎么g++逃避这个?不应该在调用方生成代码,因为主体f不可见? …
code-generation ×10
c# ×2
c++ ×2
.net ×1
assembly ×1
c++11 ×1
d ×1
disassembly ×1
eclipse ×1
exception ×1
hibernate ×1
inheritance ×1
java ×1
llvm ×1
llvm-ir ×1
noexcept ×1
protobuf-net ×1
reflection ×1
svn ×1
templates ×1
x86 ×1
xsd ×1
xsd.exe ×1