--- /dev/null
+#include <stdio.h>
+
+struct foo {
+ const char *common;
+ int a;
+};
+
+struct bar {
+ const char *common;
+ double a;
+};
+
+void print_foo(struct foo *foo)
+{
+ printf("foo: %d\n", foo->a);
+}
+
+void print_bar(struct bar *bar)
+{
+ printf("bar: %f\n", bar->a);
+}
+
+void run_test()
+{
+ struct foo foo = { "l33t", 1337 };
+ struct bar bar = { "h4x0r", 1.337 };
+
+ print_foo(&foo);
+ print_bar(&bar);
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE testcase SYSTEM "testcase.dtd">
+<testcase name="Dynval Casting">
+ <plugin id="plugin-cast" source="plugin-cast.c" />
+ <run name="Integer parameter captures" target="cast-target.c" hooks="cast-hooks.c">
+ <using plugin="plugin-cast" />
+ <output>
+ In advice function: l33t
+ foo: 1337
+ In advice function: h4x0r
+ bar: 1.337000
+ </output>
+ <prototypes>
+ void _advice(ALL_POINTER_T);
+ </prototypes>
+ </run>
+</testcase>
--- /dev/null
+#include <aop.h>
+#include <stdio.h>
+#include <string.h>
+
+AOP_I_AM_GPL_COMPATIBLE();
+
+static void plugin_join_on_call(struct aop_joinpoint *jp, void *data)
+{
+ struct aop_dynval *param;
+
+ param = aop_capture_call_param(jp, 0);
+ aop_assert(aop_is_pointer_type(aop_get_dynval_type(param)));
+ aop_cast_to_all_pointer(param);
+
+ aop_insert_advice(jp, "_advice", AOP_INSERT_BEFORE, AOP_DYNVAL(param), AOP_TERM_ARG);
+}
+
+static unsigned int plugin_cast()
+{
+ struct aop_pointcut *pc;
+
+ const struct aop_type *foo_type;
+ const struct aop_type *bar_type;
+
+ foo_type = aop_t_struct_ptr("foo");
+ bar_type = aop_t_struct_ptr("bar");
+
+ pc = aop_match_function_call();
+ aop_filter_call_pc_by_param(pc, 0, foo_type);
+ aop_join_on(pc, plugin_join_on_call, NULL);
+
+ pc = aop_match_function_call();
+ aop_filter_call_pc_by_param(pc, 0, bar_type);
+ aop_join_on(pc, plugin_join_on_call, NULL);
+
+ return 0;
+}
+
+void aop_finish()
+{
+ const char *header;
+ header = aop_get_arg_value("header");
+
+ if (header != NULL) {
+ int res;
+ res = aop_write_c_header(header, "_CAST_HEADER_", NULL, NULL);
+ if (res != 0)
+ perror(header);
+ }
+}
+
+AOP_MAIN_PROTO aop_main()
+{
+ aop_register_pass("cast", plugin_cast);
+}