#include "../tdkpin_window_messages.h" #include "../tdkpin_object_list.h" #include Win16FarPtr g_object_windows_application; HINSTANCE16 g_win16_previous_instance; HINSTANCE16 g_win16_instance; uint16_t g_win16_show_command; Win16FarPtr g_win16_message_box; Win16FarPtr g_object_windows_dispatch_proc; uint16_t g_object_windows_thunk_code_selector; Win16FarPtr g_object_windows_free_thunk; Win16FarPtr g_object_windows_message_hook; Win16FarPtr g_object_windows_creating_object; static Win16FarPtr g_client_result; static Win16FarPtr g_client_getter; static unsigned g_getter_calls; static HWND16 g_destroyed_window; static HWND16 g_sent_window; static UINT16 g_sent_message; static WPARAM16 g_sent_wparam; static LPARAM16 g_sent_lparam; void win16_call_object_action( Win16FarPtr procedure, Win16FarPtr child) { assert(procedure == win16_make_far_pointer(0x6000, 0x0cc7)); object_windows_set_flag_4_if_windowed(0xffff, child); } Win16FarPtr win16_call_object_far_method( Win16FarPtr procedure, Win16FarPtr object) { (void)object; assert(procedure == g_client_getter); g_getter_calls++; return g_client_result; } BOOL16 DestroyWindow16(HWND16 window) { g_destroyed_window = window; return 1; } LRESULT16 SendMessage16( HWND16 window, UINT16 message, WPARAM16 wparam, LPARAM16 lparam) { g_sent_window = window; g_sent_message = message; g_sent_wparam = wparam; g_sent_lparam = lparam; return 0; } static void write_far(uint16_t offset, Win16FarPtr pointer) { win16_write_u16( win16_dgroup_pointer(offset), 0, win16_far_offset(pointer)); win16_write_u16( win16_dgroup_pointer((uint16_t)(offset + 2)), 0, win16_far_selector(pointer)); } static void reset_calls(void) { g_getter_calls = 0; g_destroyed_window = 0; g_sent_window = 0; g_sent_message = 0; g_sent_wparam = 0; g_sent_lparam = 0; } int main(void) { static uint8_t dgroup[0x1000]; static uint8_t code[0x1000]; static uint8_t window_bytes[64]; static uint8_t child_bytes[64]; static uint8_t parent_bytes[64]; static uint8_t client_bytes[64]; win16_reset_segment_bindings(); win16_bind_segment(0x5000, dgroup, sizeof(dgroup), true); win16_set_dgroup_selector(0x5000); win16_bind_ne_segment(4, 0x6000, code, sizeof(code), false); win16_bind_segment(0x7000, window_bytes, sizeof(window_bytes), true); win16_bind_segment(0x7100, child_bytes, sizeof(child_bytes), true); win16_bind_segment(0x7200, parent_bytes, sizeof(parent_bytes), true); win16_bind_segment(0x7300, client_bytes, sizeof(client_bytes), true); Win16FarPtr window = win16_make_far_pointer(0x7000, 2); Win16FarPtr child = win16_make_far_pointer(0x7100, 2); Win16FarPtr parent = win16_make_far_pointer(0x7200, 2); Win16FarPtr client = win16_make_far_pointer(0x7300, 2); win16_write_u16(window, 4, 0x77); win16_write_u16(child, 4, 0x88); win16_write_u16(client, 4, 0x99); win16_write_u16(window, 6, win16_far_offset(parent)); win16_write_u16(window, 8, win16_far_selector(parent)); object_windows_append_child(window, child); win16_write_u16(parent, 0, 0x0100); g_client_getter = win16_make_far_pointer(0x6100, 0x0200); write_far(0x0130, g_client_getter); reset_calls(); object_windows_destroy_native_window(window); assert(g_destroyed_window == 0x77); assert(object_windows_has_flags(child, 4)); object_windows_update_flags(window, true, 8); reset_calls(); g_client_result = 0; object_windows_destroy_native_window(window); assert(g_getter_calls == 1 && g_destroyed_window == 0x77); reset_calls(); g_client_result = client; object_windows_destroy_native_window(window); assert(g_getter_calls == 2 && g_destroyed_window == 0); assert(g_sent_window == 0x99 && g_sent_message == 0x221); assert(g_sent_wparam == 0x77 && g_sent_lparam == 0); win16_write_u16(window, 4, 0); reset_calls(); object_windows_destroy_native_window(window); assert(g_getter_calls == 0 && g_destroyed_window == 0); return 0; }