Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



Now asume class x reimplement the virtual function bar.
The newly bar function has to share the calling conventions that were
declared by class y.
If we call function bar using a type y pointer we submit a this pointer
of type y.
But the function is designed to have a this pointer of type x.
Now the function must recalculate the supplied y pointer into an x
pointer.
If we call funtcion bar using a type x pointer we still have to convert
the x pointer into an y pointer because the function still expects an y
pointer.

> Notice how "bar" = (char *)impl + 8 ?
> 
> Somehow, when doing a "direct" call, the "this" pointer ends up as the
> impl pointer, not as the "bar" pointer, even if "bar" is used in the
> call.
> 
> However, in the "invoke" code, we get literally what we asked for --
> the "this" pointer == the "bar" pointer.  
> 
> We need to somehow be able to tell that its a case like this and make
> the this pointer be the impl pointer. 
> 
> Appended is sample output, with some of the methods modified to print out
> the this pointer.
> 
> Drew
> 
> calling direct:
> 	1 + 1 = 2
> 	1L + 1L = 2
> 	2 * 2 = 4
> 	2L * 2L = 4
> 	1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
> 	1 + 2 = 3.000000f
> 	1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55.000000
> 	1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55.000000f
> 	1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 +1 15 + 16 + 17 + 18 + 19 + 20 = 210.000000f
> 	moo cow = milk
> calling via invoke:
> 	1 + 1 = 2
> 	1L + 1L = 2
> 	2 * 2 = 4
> 	2L * 2L = 4
> 	1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
> 	1 + 2 = 3.000000f
> 	1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55.000000
> 	1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55.000000f
> 	1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 = 210.000000f
> 	moo cow = milk
> 
> impl == 0x1200160c0
> foo  == 0x1200160c0
> bar  == 0x1200160d8
> Calling Foo...
> direct calls:
> this = 0x1200160c0
> 	FooImpl::FooMethod1 called with i == 1, FooImpl part of a FooBarImpl
> this = 0x1200160c0
> 	FooImpl::FooMethod2 called with i == 2, FooImpl part of a FooBarImpl
> invoke calls:
> this = 0x1200160c0
> 	FooImpl::FooMethod1 called with i == 1, FooImpl part of a FooBarImpl
> this = 0x1200160c0
> 	FooImpl::FooMethod2 called with i == 2, FooImpl part of a FooBarImpl
> 
> Calling Bar...
> direct calls:
> this = 0x1200160d8
> 	BarImpl::BarMethod1 called with i == 1, BarImpl part of a FooBarImpl
> this = 0x1200160d8
> 	BarImpl::BarMethod2 called with i == 2, BarImpl part of a FooBarImpl
> invoke calls:
> this = 0x1200160d8
> 	BarImpl::BarMethod1 called with i == 1, BarImpl part of a FooBarImpl
> this = 0x1200160d8
> 	BarImpl::BarMethod2 called with i == 2, BarImpl part of a FooBarImpl
> 
> 
> impl == 0x12001c080
> foo  == 0x12001c080
> bar  == 0x12001c088
> Calling Foo...
> direct calls:
> this = 0x12001c080
> 	FooBarImpl2::FooMethod1 called with i == 1, local value = 12345678
> this = 0x12001c080
> 	FooBarImpl2::FooMethod2 called with i == 2, local value = 12345678
> invoke calls:
> this = 0x12001c080
> 	FooBarImpl2::FooMethod1 called with i == 1, local value = 12345678
> this = 0x12001c080
> 	FooBarImpl2::FooMethod2 called with i == 2, local value = 12345678
> 
> Calling Bar...
> direct calls:
> this = 0x12001c080
> 	FooBarImpl2::BarMethod1 called with i == 1, local value = 12345678
> this = 0x12001c080
> 	FooBarImpl2::BarMethod2 called with i == 2, local value = 12345678
> invoke calls:
> this = 0x12001c088
> 	FooBarImpl2::BarMethod1 called with i == 1, local value = 0
> this = 0x12001c088
> 	FooBarImpl2::BarMethod2 called with i == 2, local value = 0
> 
> 
> 
> 
> 
> 
> To Unsubscribe: send mail to majordomo@xxxxxxxxxxx
> with "unsubscribe freebsd-alpha" in the body of the message

-- 
B.Walter                   BWCT                http://www.bwct.de
ticso@xxxxxxx                                  info@xxxxxxx

B.Walter              COSMO-Project         http://www.cosmo-project.de
ticso@xxxxxxxxx         Usergroup           info@xxxxxxxxxxxxxxxx


To Unsubscribe: send mail to majordomo@xxxxxxxxxxx
with "unsubscribe freebsd-alpha" in the body of the message