From 08b4279c4dc5334658a43f6a1a6eba7bb1095ac1 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Tue, 10 Jun 2014 13:10:10 +0400 Subject: [PATCH] Document better how to access fields of the interposed class. --- library/include/VTableInterpose.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/include/VTableInterpose.h b/library/include/VTableInterpose.h index f93eb4176..ec950bfe2 100644 --- a/library/include/VTableInterpose.h +++ b/library/include/VTableInterpose.h @@ -42,12 +42,16 @@ namespace DFHack struct my_hack : df::someclass { typedef df::someclass interpose_base; - DEFINE_VMETHOD_INTERPOSE(void, foo, (int arg)) { + // You may define additional methods here, but NOT non-static fields + + DEFINE_VMETHOD_INTERPOSE(int, foo, (int arg)) { // If needed by the code, claim the suspend lock. // DO NOT USE THE USUAL CoreSuspender, OR IT WILL DEADLOCK! // CoreSuspendClaimer suspend; ... - INTERPOSE_NEXT(foo)(arg) // call the original + ... this->field ... // access fields of the df::someclass object + ... + int orig_retval = INTERPOSE_NEXT(foo)(arg); // call the original method ... } };