Recent

Author Topic: Invokeable Variant with Named Arguments  (Read 2565 times)

stj-mv

  • New member
  • *
  • Posts: 7
Invokeable Variant with Named Arguments
« 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

Thaddy

  • Hero Member
  • *****
  • Posts: 14391
  • Sensorship about opinions does not belong here.
Re: Invokeable Variant with Named Arguments
« Reply #1 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.
« Last Edit: May 05, 2019, 05:02:58 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

stj-mv

  • New member
  • *
  • Posts: 7
Re: Invokeable Variant with Named Arguments
« Reply #2 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

Thaddy

  • Hero Member
  • *****
  • Posts: 14391
  • Sensorship about opinions does not belong here.
Re: Invokeable Variant with Named Arguments
« Reply #3 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)
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

stj-mv

  • New member
  • *
  • Posts: 7
Re: Invokeable Variant with Named Arguments
« Reply #4 on: May 05, 2019, 05:53:59 pm »
Fine.

Thanks and have a nice evening.
Stephan

PascalDragon

  • Hero Member
  • *****
  • Posts: 5486
  • Compiler Developer
Re: Invokeable Variant with Named Arguments
« Reply #5 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...

stj-mv

  • New member
  • *
  • Posts: 7
[SOLVED] Invokeable Variant with Named Arguments
« Reply #6 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