Determining signature for a .P ?

Posted by Peter Judge on 13-Jun-2017 13:25

I know how to get the signature for a class' methods (constructor, too) as well as for internal procedures and function in a persistent procedure.

But I don't know how to get them for a procedure.  It'd be nice to have something like a GET-SIGNATURE() method on the RCODE-INFO handle but in the absence of that, does anyone have any idea how I can figure that out at runtime?

ta

All Replies

Posted by Tim Kuehn on 13-Jun-2017 13:31

If you know the procedure name, this is supposed to work:

this-procedure:get-signature("procedure-name").

Posted by Tim Kuehn on 13-Jun-2017 13:31

this-procedure:internal-entries returns a list of all procedures and UDFs.

Posted by cverbiest on 14-Jun-2017 05:52

I don't know a documented way.

You could try to parse the .r,

that information is rather readable

Posted by David Abdala on 14-Jun-2017 06:08

Documentation (11.6):

- If you provide the nil procedure name (""), GET-SIGNATURE returns the signature of the procedure whose handle you supply.

I understands that as exactly what you need, unless documentation is wrong (50/50?) or I'm reading wrong (90/10?).

Posted by Peter Judge on 14-Jun-2017 14:31

Sadly not before you run the .P. But you need to know the signature to run the .P so ….chicken, meet egg.

Posted by jankeir on 15-Jun-2017 02:31

If you also have the source about at runtime and you're up for a little challenge, you can load the antlr classes and related stuff from PDSOE into the ABL using JPJVM and then use it to get what you want ;-) Proparse can probably do the same too. I'm not entirely sure I would want to put it in production like that, but if you run the parsing as part of the build chain and export the results to JSON and deploy those it may be a valid solution.

Posted by Stefan Drissen on 15-Jun-2017 02:45

And if we are going out on imaginative limbs, then you can probably also brute force using INVOKE to guess the parameters. When you have something invokable you can use get-signature to get the real data types.

Posted by Riverside Software on 15-Jun-2017 10:29

Less imaginary, but still not realistic in your case...

java -jar rci.jar /path/to/rcode.jar

Example output:

PUBLIC MAIN VOID src\progress\pct\v11\restoreTableContent.p (INPUT PARAMETER ipTable AS CHARACTER, INPUT PARAMETER ipFile AS CHARACTER)

Sorry, that's Java code, not ABL code !

Posted by cverbiest on 16-Jun-2017 06:30

quickly concocted something from a test I had

for

/* test.p */
define input parameter inputChar as char.
define output parameter outputChar as char.
define input-output parameter inputoutputChar as char.

define input parameter inputInt as int.
define output parameter outputInt as int.
define input-output parameter inputoutputInt as int.

it shows

MAIN test.p 1,,1 inputChar 1 0,2 outputChar 1 0,3 inputoutputChar 1 0,1 inputInt 4 0,2 outputInt 4 0,3 inputoutputInt 4 0

1 inputChar 1 0 :

  • 1 = input, 2 = output, 3 = input-output ...
  • the name of the parameter
  • 1 = character, 4 = integer, ...
  • 0 ????

def stream sdir.
def stream rcode.
def var shortname as char no-undo.
def var fullname as char no-undo.

def var filepos as int no-undo. /* should be local to rcode-sourcename, placed here for debugging reasons */

function rcode-sourcename returns char
    (input fullname as char, input ifullsignature as log):

    def var mptr as memptr no-undo.
    def var wz-signature as char no-undo form "x(50)".
    def var sourcename as char no-undo init ?.

    set-size(mptr) = 500.

    input stream rcode from value(fullname) binary no-convert.
    import stream rcode mptr.
    input stream rcode close.
    do filepos = 1 to 496
        while get-string(mptr, filepos, 4) <> "MAIN":
    end.
    wz-signature = get-string(mptr, filepos).
    sourcename = entry(1, entry(2, wz-signature, " ")).
    set-size(mptr) = 0.
    if ifullsignature
    then return wz-signature.
    return sourcename.

end function.

compile test.p save.
message rcode-sourcename("test.r", yes).

Posted by Mike Fechner on 16-Jun-2017 06:46

Interesting :-) and now the schema of parameter temp-tables?

Posted by cverbiest on 16-Jun-2017 08:51

[mention:6e3b17cb0ff148039a2aabb4c7834ce4:e9ed411860ed4f2ba0265705b8793d05] It's in there, a bit further on and looks similar to the signature

for

define temp-table tTest no-undo
    field tt1 as char
    field tt2 as int
    .

I find

@TTAB tTest 2 1 1 0 0,0 tt1 1 0 0 0 1 1 1,tt2 4 0 1 0 1 1 1^@

This thread is closed