From ac0d878b691bb73227f0b281a7cfbe6566813c38 Mon Sep 17 00:00:00 2001 From: jj Date: Fri, 6 Apr 2012 19:59:11 +0200 Subject: [PATCH] ruby: include memstruct in autogen --- plugins/ruby/CMakeLists.txt | 4 ++-- plugins/ruby/codegen.pl | 10 ++++++---- plugins/ruby/ruby-memstruct.rb | 7 +------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/plugins/ruby/CMakeLists.txt b/plugins/ruby/CMakeLists.txt index 4a69c09ea..6927dbc8a 100644 --- a/plugins/ruby/CMakeLists.txt +++ b/plugins/ruby/CMakeLists.txt @@ -13,8 +13,8 @@ if(RUBY_FOUND) ) ADD_CUSTOM_COMMAND( 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 - DEPENDS 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 ruby-memstruct.rb ) ADD_CUSTOM_TARGET(ruby-autogen-rb ALL DEPENDS ruby-autogen.rb) include_directories("${dfhack_SOURCE_DIR}/depends/tthread" ${RUBY_INCLUDE_PATH}) diff --git a/plugins/ruby/codegen.pl b/plugins/ruby/codegen.pl index 29259fdc3..7afc63da7 100755 --- a/plugins/ruby/codegen.pl +++ b/plugins/ruby/codegen.pl @@ -346,6 +346,7 @@ my $input = $ARGV[0] || '../../library/include/df/codegen.out.xml'; # delete offsets my $output = $ARGV[1] or die "need output file"; my $offsetfile = $ARGV[2]; +my $memstruct = $ARGV[3]; if ($offsetfile) { open OF, "<$offsetfile"; @@ -379,10 +380,6 @@ for my $obj ($doc->findnodes('/ld:data-definition/ld:global-object')) { open FH, ">$output"; 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 \"df/$_.h\"\n" for @include_cpp; print FH "#include \n"; @@ -402,6 +399,11 @@ if ($output =~ /\.cpp$/) { } else { print FH "module DFHack\n"; print FH "module MemHack\n"; + if ($memstruct) { + open MH, "<$memstruct"; + print FH "$_" while(); + close MH; + } print FH "$_\n" for @lines_rb; print FH "end\n"; print FH "end\n"; diff --git a/plugins/ruby/ruby-memstruct.rb b/plugins/ruby/ruby-memstruct.rb index 9b78a3086..f4afe8761 100644 --- a/plugins/ruby/ruby-memstruct.rb +++ b/plugins/ruby/ruby-memstruct.rb @@ -1,6 +1,3 @@ -module DFHack -module MemHack - class MemStruct attr_accessor :_memaddr 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 end -end -end -require 'ruby-autogen' +