From 7b7b15a18c27bc494e59539d44020b6504d6a440 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Thu, 16 Jun 2011 16:35:10 -0500 Subject: [PATCH 1/2] Update istate.pybroccoli test. For changes made to broccoli-python repository in commit dbc73389e3a8c17734815993626d83084eb93615 --- testing/btest/Baseline/istate.pybroccoli/bro..stdout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/btest/Baseline/istate.pybroccoli/bro..stdout b/testing/btest/Baseline/istate.pybroccoli/bro..stdout index 9eec3a4550..8b772e094f 100644 --- a/testing/btest/Baseline/istate.pybroccoli/bro..stdout +++ b/testing/btest/Baseline/istate.pybroccoli/bro..stdout @@ -14,6 +14,6 @@ Servus [a=42, b=6.6.7.7] 42, 6.6.7.7 ==== coerced record -[a=13, b=, c=helloworld] +[one=, a=13, b=, c=helloworld, d=] 13 helloworld From f24a67d662b9fd1ce884355834d9a4610888e43d Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Mon, 27 Jun 2011 17:11:14 -0500 Subject: [PATCH 2/2] Move event arg. record coercion check; now only done for recv'd remote events --- src/EventHandler.cc | 25 ------------------------- src/RemoteSerializer.cc | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/EventHandler.cc b/src/EventHandler.cc index ef0c9fc63c..9cc5306c9c 100644 --- a/src/EventHandler.cc +++ b/src/EventHandler.cc @@ -69,32 +69,7 @@ void EventHandler::Call(val_list* vl, bool no_remote) } if ( local ) - { - if ( FType() ) - { - const type_list* arg_types = type->ArgTypes()->Types(); - loop_over_list(*vl, i) - { - Val* v = (*vl)[i]; - BroType* va_t = v->Type(); - BroType* ar_t = (*arg_types)[i]; - if ( va_t->Tag() == TYPE_RECORD && ar_t->Tag() == TYPE_RECORD ) - { - if ( ! same_type(va_t, ar_t) ) - { - Val* nv; - nv = v->AsRecordVal()->CoerceTo(ar_t->AsRecordType()); - if ( nv ) - { - vl->replace(i, nv); - Unref(v); - } - } - } - } - } Unref(local->Call(vl)); - } else { loop_over_list(*vl, i) diff --git a/src/RemoteSerializer.cc b/src/RemoteSerializer.cc index 6f33a33bca..9970118440 100644 --- a/src/RemoteSerializer.cc +++ b/src/RemoteSerializer.cc @@ -2732,6 +2732,31 @@ void RemoteSerializer::GotEvent(const char* name, double time, e->handler = event; e->args = args; + // if needed, coerce received record arguments to the expected record type + if ( e->handler->FType() ) + { + const type_list* arg_types = e->handler->FType()->ArgTypes()->Types(); + loop_over_list(*args, i) + { + Val* v = (*args)[i]; + BroType* v_t = v->Type(); + BroType* arg_t = (*arg_types)[i]; + if ( v_t->Tag() == TYPE_RECORD && arg_t->Tag() == TYPE_RECORD ) + { + if ( ! same_type(v_t, arg_t) ) + { + Val* nv; + nv = v->AsRecordVal()->CoerceTo(arg_t->AsRecordType()); + if ( nv ) + { + args->replace(i, nv); + Unref(v); + } + } + } + } + } + events.append(e); }