Using agent with external (or class) methods

12 views
Skip to first unread message

Louis M

unread,
Jun 15, 2020, 10:59:15 AM6/15/20
to Eiffel Users
Hello everyone.

I try to use an external method in the {C_EXTERNAL} class like this:

    frozen method_name(a_object:POINTER):POINTER
        external
            "C++ inline use <Box2D.h>"
        alias
            "((CType *)$a_object)->functionName()"
        end

in an agent call. I define the {FUNCTION} variable like this:

    l_method:FUNCTION[POINTER, POINTER]

Finally, I assign the agent like this:

    l_method := agent {C_EXTERNAL}.method_name

When I compile that, I have a VUAR error saying that the type of the
agent is:

    FUNCTION [C_EXTERNAL, POINTER, POINTER]

instead of :

    FUNCTION [POINTER, POINTER]

Since it is a class method, I don't have an object of type {C_EXTERNAL}
to use in the agent call. I have a workaround using:

    l_method := agent (a_item:POINTER):POINTER do Result :=
{C_EXTERNAL}.method_name(a_item) end

But I think that this is ugly (particularly when used as method
argument). So is there a way to use a more concise technique of creating
an agent from external or class method?

Thanks a lot,

Louis M

Alexander Kogtenkov

unread,
Jun 15, 2020, 3:25:29 PM6/15/20
to eiffel...@googlegroups.com
Agents were introduced in the language long time before class features. Class features are a recent addition. So, I believe, there is no special syntax for class-based (as opposed to object-based) agents at the moment.
 
Regards,
Alexander Kogtenkov
 
 
'Louis M' via Eiffel Users <eiffel...@googlegroups.com>:
 
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/8357d200-7605-3edd-6df6-d56aa702c600%40tioui.com.
 

Louis M

unread,
Jun 15, 2020, 3:36:10 PM6/15/20
to 'Alexander Kogtenkov' via Eiffel Users

Ok. Thanks.

Louis M

Reply all
Reply to author
Forward
0 new messages