[flext] Basic question about ADDMETHOD
Thomas Grill
gr at grrrr.org
Thu Jan 14 14:18:29 UTC 2016
Yes, FLEXT_ADDMETHOD_ adapts to the arguments.
Nevertheless surprising that there is no explicit FLEXT_ADDMETHOD_S ;-)
gr~~~
> Am 14.01.2016 um 15:15 schrieb Matthias Geier <matthias.geier at gmail.com>:
>
> Hi Martin.
>
> I think the problem with your code seems to be that
> FLEXT_ADDMETHOD_S() doesn't exist (at least I didn't find it in the
> header files).
>
> You should probably try FLEXT_ADDMETHOD_() instead?
>
> And then, as Thomas suggested, you should probably change to
> FLEXT_CADDMETHOD_() used in a static member function defined by
>
> static void setup(t_classid c) { ... }
>
> Is that correct, Thomas?
>
> cheers,
> Matthias
>
> On Thu, Jan 14, 2016 at 3:11 PM, Thomas Grill <gr at grrrr.org> wrote:
>> Hi Martin,
>> the difference is that ADDMETHOD is used for per-instance methods (they are typically set in the constructur, as you did), whereas CADDMETHOD is for per-class static functions (those are set in a class setup function).
>> Actually, the use of per-instance methods is not encouraged and will not be supported any longer in future flext versions.
>> best, Thomas
>>
>>> Am 14.01.2016 um 06:02 schrieb Martin Jaroszewicz <temporum at gmail.com>:
>>>
>>> Dear forum,
>>>
>>> I'm new to Flext, and haven't coded in C++ in a long time. I'm trying to make the code below compile but get the following error:
>>>
>>> error: reference to non-static member function must be called
>>> FLEXT_ADDMETHOD_S(0,"read",m_read);
>>>
>>> Also can someone clarify the difference between the two ways to register methods (ADDMETHOD and CADDMETHOD) ? Does this have to do with passing pointers as arguments (?). Code below
>>> I'm trying to read a text file into a vector. This is the first step.
>>>
>>> '''
>>> #include <flext.h>
>>>
>>> #if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400)
>>> #error You need at least flext version 0.4.0
>>> #endif
>>>
>>> class hello:
>>>
>>> public flext_base
>>> {
>>>
>>> FLEXT_HEADER(hello,flext_base)
>>>
>>> public:
>>>
>>> hello();
>>>
>>> protected:
>>>
>>> void m_read(t_symbol *argument);
>>>
>>> private:
>>>
>>> FLEXT_CALLBACK_S(m_read)
>>> };
>>>
>>> FLEXT_NEW("hello",hello)
>>>
>>>
>>> hello::hello() {
>>>
>>>
>>> AddInAnything();
>>>
>>> FLEXT_ADDMETHOD_S(0,"read",m_read);
>>>
>>> }
>>>
>>> void hello::m_read(t_symbol *argument) {
>>> post("reading argument: %s)",GetString(argument));
>>>
>>> }
>>> '''
>>> _______________________________________________
>>> http://grrrr.org/ext/flext
>>>
>>> flext mailing list
>>> flext at grrrr.org
>>> http://grrrr.org/cgi-bin/mailman/listinfo/flext
>>
>>
>> _______________________________________________
>> http://grrrr.org/ext/flext
>>
>> flext mailing list
>> flext at grrrr.org
>> http://grrrr.org/cgi-bin/mailman/listinfo/flext
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://grrrr.org/pipermail/flext/attachments/20160114/f8494000/attachment.sig>
More information about the flext
mailing list