Merge remote-tracking branch 'kmartin/master'

develop
Alexander Gavrilov 2012-10-20 15:39:20 +04:00
commit 687dc7105f
4 changed files with 66 additions and 16 deletions

@ -374,6 +374,8 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve
" unload PLUGIN|all - Unload a plugin or all loaded plugins.\n"
" reload PLUGIN|all - Reload a plugin or all loaded plugins.\n"
);
con.print("\nDFHack version " DFHACK_VERSION ".\n");
}
else if (parts.size() == 1)
{

@ -232,7 +232,11 @@ sub render_global_class {
render_struct_fields($type);
my $vms = $type->findnodes('child::virtual-methods')->[0];
render_class_vmethods($vms) if $vms;
if ($vms)
{
my $voff = render_class_vmethods_voff($parent);
render_class_vmethods($vms, $voff);
}
};
push @lines_rb, "end\n";
}
@ -275,7 +279,6 @@ sub render_struct_field_refs {
my ($parent, $field, $name) = @_;
my $reftg = $field->getAttribute('ref-target');
render_field_reftarget($parent, $field, $name, $reftg) if ($reftg);
my $refto = $field->getAttribute('refers-to');
render_field_refto($parent, $name, $refto) if ($refto);
@ -285,6 +288,8 @@ sub render_struct_field_refs {
if ($meta and $meta eq 'container' and $item) {
my $itemreftg = $item->getAttribute('ref-target');
render_container_reftarget($parent, $item, $name, $itemreftg) if $itemreftg;
} elsif ($reftg) {
render_field_reftarget($parent, $field, $name, $reftg);
}
}
@ -368,9 +373,29 @@ sub render_container_reftarget {
}
}
# return the size of the parent's vtables
sub render_class_vmethods_voff {
my ($name) = @_;
return 0 if !$name;
my $type = $global_types{$name};
my $parent = $type->getAttribute('inherits-from');
my $voff = render_class_vmethods_voff($parent);
my $vms = $type->findnodes('child::virtual-methods')->[0];
for my $meth ($vms->findnodes('child::vmethod'))
{
$voff += 4 if $meth->getAttribute('is-destructor') and $os eq 'linux';
$voff += 4;
}
return $voff;
}
sub render_class_vmethods {
my ($vms) = @_;
my $voff = 0;
my ($vms, $voff) = @_;
for my $meth ($vms->findnodes('child::vmethod'))
{

@ -282,6 +282,10 @@ module DFHack
DFHack.memory_read_int32(@_memaddr) & 0xffffffff
end
def _setp(v)
DFHack.memory_write_int32(@_memaddr, v)
end
def _get
addr = _getp
return if addr == 0
@ -294,7 +298,15 @@ module DFHack
case v
when Pointer; DFHack.memory_write_int32(@_memaddr, v._getp)
when MemStruct; DFHack.memory_write_int32(@_memaddr, v._memaddr)
when Integer; DFHack.memory_write_int32(@_memaddr, v)
when Integer
if @_tg and @_tg.kind_of?(MemHack::Number)
if _getp == 0
_setp(DFHack.malloc(@_tg._bits/8))
end
@_tg._at(_getp)._set(v)
else
DFHack.memory_write_int32(@_memaddr, v)
end
when nil; DFHack.memory_write_int32(@_memaddr, 0)
else _get._set(v)
end

@ -118,18 +118,8 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
return CR_OK;
}
// send a single ruby line to be evaluated by the ruby thread
DFhackCExport command_result plugin_eval_ruby( color_ostream &out, const char *command)
static command_result do_plugin_eval_ruby(color_ostream &out, const char *command)
{
// if dlopen failed
if (!r_thread)
return CR_FAILURE;
// wrap all ruby code inside a suspend block
// if we dont do that and rely on ruby code doing it, we'll deadlock in
// onupdate
CoreSuspender suspend;
command_result ret;
// ensure ruby thread is idle
@ -159,6 +149,27 @@ DFhackCExport command_result plugin_eval_ruby( color_ostream &out, const char *c
return ret;
}
// send a single ruby line to be evaluated by the ruby thread
DFhackCExport command_result plugin_eval_ruby( color_ostream &out, const char *command)
{
// if dlopen failed
if (!r_thread)
return CR_FAILURE;
if (!strncmp(command, "nolock ", 7)) {
// debug only!
// run ruby commands without locking the main thread
// useful when the game is frozen after a segfault
return do_plugin_eval_ruby(out, command+7);
} else {
// wrap all ruby code inside a suspend block
// if we dont do that and rely on ruby code doing it, we'll deadlock in
// onupdate
CoreSuspender suspend;
return do_plugin_eval_ruby(out, command);
}
}
DFhackCExport command_result plugin_onupdate ( color_ostream &out )
{
if (!r_thread)