ruby: include memstruct in autogen

develop
jj 2012-04-06 19:59:11 +02:00
parent 52007e0d4f
commit ac0d878b69
3 changed files with 9 additions and 12 deletions

@ -13,8 +13,8 @@ if(RUBY_FOUND)
) )
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ruby-autogen.rb OUTPUT ruby-autogen.rb
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/codegen.pl ${dfhack_SOURCE_DIR}/library/include/df/codegen.out.xml ${CMAKE_CURRENT_SOURCE_DIR}/ruby-autogen.rb ${CMAKE_CURRENT_BINARY_DIR}/ruby-autogen.offsets COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/codegen.pl ${dfhack_SOURCE_DIR}/library/include/df/codegen.out.xml ${CMAKE_CURRENT_SOURCE_DIR}/ruby-autogen.rb ${CMAKE_CURRENT_BINARY_DIR}/ruby-autogen.offsets ${CMAKE_CURRENT_SOURCE_DIR}/ruby-memstruct.rb
DEPENDS ruby-autogen.offsets DEPENDS ruby-autogen.offsets ruby-memstruct.rb
) )
ADD_CUSTOM_TARGET(ruby-autogen-rb ALL DEPENDS ruby-autogen.rb) ADD_CUSTOM_TARGET(ruby-autogen-rb ALL DEPENDS ruby-autogen.rb)
include_directories("${dfhack_SOURCE_DIR}/depends/tthread" ${RUBY_INCLUDE_PATH}) include_directories("${dfhack_SOURCE_DIR}/depends/tthread" ${RUBY_INCLUDE_PATH})

@ -346,6 +346,7 @@ my $input = $ARGV[0] || '../../library/include/df/codegen.out.xml';
# delete offsets # delete offsets
my $output = $ARGV[1] or die "need output file"; my $output = $ARGV[1] or die "need output file";
my $offsetfile = $ARGV[2]; my $offsetfile = $ARGV[2];
my $memstruct = $ARGV[3];
if ($offsetfile) { if ($offsetfile) {
open OF, "<$offsetfile"; open OF, "<$offsetfile";
@ -379,10 +380,6 @@ for my $obj ($doc->findnodes('/ld:data-definition/ld:global-object')) {
open FH, ">$output"; open FH, ">$output";
if ($output =~ /\.cpp$/) { if ($output =~ /\.cpp$/) {
print FH "#include \"Core.h\"\n";
print FH "#include \"Console.h\"\n";
print FH "#include \"Export.h\"\n";
print FH "#include \"PluginManager.h\"\n";
print FH "#include \"DataDefs.h\"\n"; print FH "#include \"DataDefs.h\"\n";
print FH "#include \"df/$_.h\"\n" for @include_cpp; print FH "#include \"df/$_.h\"\n" for @include_cpp;
print FH "#include <stdio.h>\n"; print FH "#include <stdio.h>\n";
@ -402,6 +399,11 @@ if ($output =~ /\.cpp$/) {
} else { } else {
print FH "module DFHack\n"; print FH "module DFHack\n";
print FH "module MemHack\n"; print FH "module MemHack\n";
if ($memstruct) {
open MH, "<$memstruct";
print FH "$_" while(<MH>);
close MH;
}
print FH "$_\n" for @lines_rb; print FH "$_\n" for @lines_rb;
print FH "end\n"; print FH "end\n";
print FH "end\n"; print FH "end\n";

@ -1,6 +1,3 @@
module DFHack
module MemHack
class MemStruct class MemStruct
attr_accessor :_memaddr attr_accessor :_memaddr
def _at(addr) ; @_memaddr = addr ; self ; end def _at(addr) ; @_memaddr = addr ; self ; end
@ -194,7 +191,5 @@ class Global < MemStruct
def _at(addr) ; g = const_get(@_glob) ; g._at(addr) ; end def _at(addr) ; g = const_get(@_glob) ; g._at(addr) ; end
end end
end
end
require 'ruby-autogen'