@@ -778,53 +778,56 @@ pub fn binding(self: webui, element: [:0]const u8, comptime callback: anytype) !
778778 fn handle (e : * Event ) void {
779779 var param_tup : tup_t = undefined ;
780780
781+ var index : usize = 0 ;
781782 inline for (fnInfo .params , 0.. fnInfo .params .len ) | param , i | {
782783 if (param .type ) | tt | {
783784 const paramTInfo = @typeInfo (tt );
784785 switch (paramTInfo ) {
785786 .@"struct" = > {
786- if (tt != Event ) {
787+ if (tt == Event ) {
788+ param_tup [i ] = e .* ;
789+ index += 1 ;
790+ } else {
787791 const err_msg = std .fmt .comptimePrint (
788792 "the struct type is ({}), the struct type you can use only is Event in params!" ,
789793 .{tt },
790794 );
791795 @compileError (err_msg );
792796 }
793- param_tup [i ] = e ;
794797 },
795798 .bool = > {
796- const res = e .getBoolAt (i );
799+ const res = e .getBoolAt (i - index );
797800 param_tup [i ] = res ;
798801 },
799802 .int = > {
800- const res = e .getIntAt (i );
803+ const res = e .getIntAt (i - index );
801804 param_tup [i ] = @intCast (res );
802805 },
803806 .float = > {
804- const res = e .getFloatAt (i );
807+ const res = e .getFloatAt (i - index );
805808 param_tup [i ] = res ;
806809 },
807810 .pointer = > | pointer | {
808- if (pointer .size != .slice or pointer .child != u8 or pointer .is_const == false ) {
811+ if (pointer .size == .slice and pointer .child == u8 and pointer .is_const == true ) {
812+ if (pointer .sentinel ()) | sentinel | {
813+ if (sentinel == 0 ) {
814+ const str_ptr = e .getStringAt (i - index );
815+ param_tup [i ] = str_ptr ;
816+ }
817+ }
818+ } else if (pointer .size == .one and pointer .child == Event ) {
819+ param_tup [i ] = e ;
820+ index += 1 ;
821+ } else if (pointer .size == .many and pointer .child == u8 and pointer .is_const == true and pointer .sentinel () == null ) {
822+ const raw_ptr = e .getRawAt (i - index );
823+ param_tup [i ] = raw_ptr ;
824+ } else {
809825 const err_msg = std .fmt .comptimePrint (
810- "the pointer type is ({}), not support other type for pointer param !" ,
826+ "the pointer type is ({}), now we only support [:0]const u8 or [*]const u8 or *webui.Event !" ,
811827 .{tt },
812828 );
813829 @compileError (err_msg );
814830 }
815- if (pointer .sentinel ()) | sentinel | {
816- if (sentinel != 0 ) {
817- const err_msg = std .fmt .comptimePrint (
818- "type is ({}), only support these types: Event, Bool, Int, Float, [:0]const u8, []u8!" ,
819- .{tt },
820- );
821- @compileError (err_msg );
822- }
823- const str_ptr = e .getStringAt (i );
824- param_tup [i ] = str_ptr ;
825- } else {
826- @compileError ("not support []u8" );
827- }
828831 },
829832 else = > {
830833 const err_msg = std .fmt .comptimePrint (
0 commit comments