Extension Methods

Extension method is a function which takes four parameters: the first parameter specifies the object and the remaining three parameters are the standard method parameters named 'p1', 'p2' and 'p3'. Just like regular methods, extension methods can use these parameters to any info to the method in question.

To define new extension method:

    static void *sayhello(R3OBJ *obj, void *p1, void *p2, void *p3)
    {
        R3Info("Hello %s", p3);
        return NULL;
    }

    R3ClassAddExtensionMethod(R3CLID_WINDOW, "SayHello", sayhello);

To call the defined extension method:


    R3DoEA3(mywindow, "Hello", NULL, NULL, "John");

and a dialog with "Hello John" will pop up.

Note: extension method names are resolved in run time so they should not be used in speed critical tasks.

Example: 'samples/kernel/extmth'