From 3cb0a53ecae7797ef387064cab097842d14d3d58 Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 7 Jan 2005 21:14:21 +0000 Subject: [PATCH] + compiler side of variant<->interface implemented --- compiler/defcmp.pas | 22 ++++++++++++++++++++-- compiler/ncnv.pas | 43 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas index 85320543ab..aeed85024f 100644 --- a/compiler/defcmp.pas +++ b/compiler/defcmp.pas @@ -76,7 +76,9 @@ interface tc_variant_2_dynarray, tc_dynarray_2_variant, tc_variant_2_enum, - tc_enum_2_variant + tc_enum_2_variant, + tc_interface_2_variant, + tc_variant_2_interface ); function compare_defs_ext(def_from,def_to : tdef; @@ -661,6 +663,14 @@ implementation eq:=te_convert_l1; end; end; + objectdef : + begin + if is_interface(def_from) then + begin + doconv:=tc_interface_2_variant; + eq:=te_convert_l1; + end; + end; end; end; end; @@ -965,6 +975,11 @@ implementation begin eq:=te_convert_l1; doconv:=tc_equal; + end + else if (def_from.deftype=variantdef) and is_interface(def_to) then + begin + doconv:=tc_variant_2_interface; + eq:=te_convert_l1; end; end; end; @@ -1334,7 +1349,10 @@ implementation end. { $Log$ - Revision 1.64 2005-01-06 13:30:40 florian + Revision 1.65 2005-01-07 21:14:21 florian + + compiler side of variant<->interface implemented + + Revision 1.64 2005/01/06 13:30:40 florian * widechararray patch from Peter Revision 1.63 2005/01/03 17:55:57 florian diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index 29360753f2..cc9f16d3f9 100644 --- a/compiler/ncnv.pas +++ b/compiler/ncnv.pas @@ -78,6 +78,8 @@ interface function resulttype_variant_to_enum : tnode; function resulttype_enum_to_variant : tnode; function resulttype_proc_to_procvar : tnode; + function resulttype_variant_to_interface : tnode; + function resulttype_interface_to_variant : tnode; protected function first_int_to_int : tnode;virtual; function first_cstring_to_pchar : tnode;virtual; @@ -615,7 +617,9 @@ implementation 'tc_variant_2_dynarray', 'tc_dynarray_2_variant', 'tc_variant_2_enum', - 'tc_enum_2_variant' + 'tc_enum_2_variant', + 'tc_interface_2_variant', + 'tc_variant_2_interface' ); begin inherited printnodeinfo(t); @@ -1113,6 +1117,28 @@ implementation end; + function ttypeconvnode.resulttype_variant_to_interface : tnode; + begin + result := ccallnode.createinternres( + 'fpc_variant_to_interface', + ccallparanode.create(left,nil) + ,resulttype); + resulttypepass(result); + left:=nil; + end; + + + function ttypeconvnode.resulttype_interface_to_variant : tnode; + begin + result := ccallnode.createinternres( + 'fpc_interface_to_variant', + ccallparanode.create(left,nil) + ,resulttype); + resulttypepass(result); + left:=nil; + end; + + function ttypeconvnode.resulttype_variant_to_enum : tnode; begin @@ -1223,7 +1249,9 @@ implementation { variant_2_dynarray} @ttypeconvnode.resulttype_variant_to_dynarray, { dynarray_2_variant} @ttypeconvnode.resulttype_dynarray_to_variant, { variant_2_enum} @ttypeconvnode.resulttype_variant_to_enum, - { enum_2_variant} @ttypeconvnode.resulttype_enum_to_variant + { enum_2_variant} @ttypeconvnode.resulttype_enum_to_variant, + { variant_2_interface} @ttypeconvnode.resulttype_interface_to_variant, + { interface_2_variant} @ttypeconvnode.resulttype_variant_to_interface ); type tprocedureofobject = function : tnode of object; @@ -2053,6 +2081,8 @@ implementation nil, nil, nil, + nil, + nil, nil ); type @@ -2287,7 +2317,9 @@ implementation @ttypeconvnode._second_nothing, { variant_2_dynarray } @ttypeconvnode._second_nothing, { dynarray_2_variant} @ttypeconvnode._second_nothing, { variant_2_enum } - @ttypeconvnode._second_nothing { enum_2_variant } + @ttypeconvnode._second_nothing, { enum_2_variant } + @ttypeconvnode._second_nothing, { variant_2_interface } + @ttypeconvnode._second_nothing { interface_2_variant } ); type tprocedureofobject = procedure of object; @@ -2546,7 +2578,10 @@ begin end. { $Log$ - Revision 1.172 2005-01-06 13:40:41 florian + Revision 1.173 2005-01-07 21:14:21 florian + + compiler side of variant<->interface implemented + + Revision 1.172 2005/01/06 13:40:41 florian * 1.0.10 starting patch from Peter Revision 1.171 2005/01/06 13:30:41 florian