Lazarus

Free Pascal => General => Topic started by: stj-mv on May 05, 2019, 03:22:26 pm

Title: Invokeable Variant with Named Arguments
Post by: stj-mv on May 05, 2019, 03:22:26 pm
Hi all.
Is there a structured way to get the name and value of a named argument while using DispInvoke of a custom variant type?

x := V.AMethod(AArg := 1);

I'd like to fetch the Name "AArg" and the Value "1" from the given parameters in
DispInvoke(Dest: PVarData; var Source: TVarData; CallDesc: PCallDesc; Params: Pointer)
of my custom variant.

Any hints welcome.
Stephan
Title: Re: Invokeable Variant with Named Arguments
Post by: Thaddy on May 05, 2019, 04:57:26 pm
Yes. RTTI.

Be careful, though, such coding style is always slow in any language.
I hope you know that. The overhead is quite considerable (again: in any language!).

Supported by IInvocable together with RTTI.

It is slow because it requires a look-up mechanism at run-time.
Title: Re: Invokeable Variant with Named Arguments
Post by: stj-mv on May 05, 2019, 05:37:28 pm
Thanks for your reply.

I'm working on an enhanced UNO (OpenOffice) bridge, based on the already existing one.
The aim is to make it useable with (at least) Windows 32/64 and Linux 32/64 and to get
rid of those annoying CPP bootstrapping.

Your suggestion "via RTTI" sounds promising. Do you have any hints examples etc?
The Params argument is a simple Pointer and the given ArgType in PCallDesc^
doesn't help much.

TIA
Stephan
Title: Re: Invokeable Variant with Named Arguments
Post by: Thaddy on May 05, 2019, 05:49:20 pm
It is not a simple pointer, but a buffer....
Anyway, tomorrow I have more time. I think I can come up with a simple example. (Because I also use that software)
Title: Re: Invokeable Variant with Named Arguments
Post by: stj-mv on May 05, 2019, 05:53:59 pm
Fine.

Thanks and have a nice evening.
Stephan
Title: Re: Invokeable Variant with Named Arguments
Post by: PascalDragon on May 06, 2019, 09:24:58 am
Hi all.
Is there a structured way to get the name and value of a named argument while using DispInvoke of a custom variant type?

x := V.AMethod(AArg := 1);

I'd like to fetch the Name "AArg" and the Value "1" from the given parameters in
DispInvoke(Dest: PVarData; var Source: TVarData; CallDesc: PCallDesc; Params: Pointer)
of my custom variant.
The parameter names are encoded into the CallDesc^.ArgTypes array behind the method name (which is at CallDesc^.ArgTypes[CallDesc^.ArgCount]). You can see a bit more in the Variants unit in TInvokeableVariantType.DispInvoke though the argument names are not used there.
You could also check for a Delphi tutorial for that as that data should be Delphi compatible...
Title: [SOLVED] Invokeable Variant with Named Arguments
Post by: stj-mv on May 06, 2019, 03:49:03 pm
The parameter names are encoded into the CallDesc^.ArgTypes array behind the method name (which is at CallDesc^.ArgTypes[CallDesc^.ArgCount]).
You can see a bit more in the Variants unit in TInvokeableVariantType.DispInvoke though the argument names are not used there.
You could also check for a Delphi tutorial for that as that data should be Delphi compatible...

Thanks alot.
The hint to look behind the method name was really useful.

I did look at TInvokeableVariantType.DispInvoke and didn't found anything about the parameter names.
A search on this topic gives me near to nothing about named arguments.

For me this is solved :-)

Stephan
TinyPortal © 2005-2018