On Sat, 19 Apr 2014, Bruno F??lix Rezende Ribeiro wrote:
> Em Sat, 19 Apr 2014 01:07:21 +0200
> Tobias Boege <tabo...@gmail.com> escreveu:
>
> > Oh, I forgot to ask: do you want the patch that allows inheritance-
> > compatible[*] classes to be used in place of a class in method and
> > property signatures to test the above approach - even if it's
> > unlikely that it goes mainline?
>
> Sure!
Attached. But be warned (again?): the interpreter is actually not my
business. Virtually, I don't even know what I've done to the code as an
entire with my patch but it worked in the single test case I had.
I tested code like this to have VariantArray implement Extract() and it
succeeded:
Public Sub Extract(Start As Integer, Optional Length As Integer = 1) As
VariantArray
Dim hNew As New VariantArray
Dim vElt As Variant
For Each vElt in Super.Extract(Start, Length)
hNew.Add(vElt)
Next
Raise ExtractEvent
Return hNew
End
Note that VariantArray.Extract(), just like Variant[].Extract(), returns
a new object which has, by default, no event name. So don't be surprised
if the returned object doesn't fire any events. You have to manually assign
it to an event observer using Object.Attach(). Another reason against giving
events to data containers ;-)
>
> Thank you very much for your efforts coding on the interpreter.
Well, that's pretty much the only thing I can do when Benoit is not around
to answer those core questions (which is seldom the case anyway).
Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
Index: gbx_class.c
===================================================================
--- gbx_class.c (revision 6243)
+++ gbx_class.c (working copy)
@@ -991,7 +991,9 @@
TYPE *sd, *sp;
int nsd, nsp;
- if (desc->property.type != pdesc->property.type)
+ if (desc->property.type != pdesc->property.type
+ && (!TYPE_are_objects(desc->property.type, pdesc->property.type)
+ || !CLASS_inherits((CLASS *) desc->property.type, (CLASS *) pdesc->property.type)))
{
//fprintf(stderr, "type! %ld / %ld\n", desc->property.type, pdesc->property.type);
return TRUE;
Index: gbx_type.c
===================================================================
--- gbx_type.c (revision 6243)
+++ gbx_type.c (working copy)
@@ -322,8 +322,10 @@
for (i = 0; i < np1; i++)
{
- if (sign1[i] != sign2[i])
- return TRUE;
+ if (sign1[i] != sign2[i]
+ && (!TYPE_are_objects(sign1[i], sign2[i])
+ || !CLASS_inherits((CLASS *) sign1[i], (CLASS *) sign2[i])))
+ return TRUE;
}
return FALSE;
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user