realbasic-plugins
[Top] [All Lists]

Re: REALLoadObjectMethod leaking memory?

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: Re: REALLoadObjectMethod leaking memory?
From: Alfred Van Hoek <vanhoek at mac dot com>
Date: Sun, 15 Jan 2006 17:08:37 -0500
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
References: <BFF0733E dot FEDF%alexander dot traud at macnews dot de>

On Jan 15, 2006, at 3:46 PM, Alexander Traud wrote:


Sorry - I do not understand what you mean. Do I need the *name* of a
parameter to find an (overloaded) function? It is the name which is leaking.
So use a one letter name...

Yes, I understood you correctly; No REALstrings leaking, just the char(s) of the name.., no you do not need the correct name of an arg, but you require a name in the sig, and was only speculating that the pointers to these names might be important for searching/maintaining the fp.

How should I load a method with an optional parameter with
REALLoadObjectMethod? This is what you are talking about, correct? Actually I would have needed that but how do I know which method was found, how do I
typecast my function pointer?



As Jon said, you are responsible for the full signature, including default values, but typecasting is based on the complete set of args:

suppose you would want to call DrawPicture of the graphics class:

You will need to inquire about how many arguments are defined by REALbasic, and sometimes you need to do some guessing about the default values, which makes these parameters optional:

"DrawPicture(image As Picture, x As Integer, y As Integer, w1 As Integer=-10000, h1 As Integer=-10000, sx As Integer=0, sy As Integer=0, w2 As Integer=-10000, h2 As Integer=-10000)"

This is the signature, and based on this you define the typecasting:

static void (*_fp)(REALgraphics, REALpicture, int, int, int, int, int, int, int, int) = nil;

and REALLoadObjectMethod is typecasted to:

(void(*)(REALgraphics, REALpicture, int, int, int, int, int, int, int, int))

With respect to avoiding guessing default values, you might want to try this signature:

"DrawPicture(image As Picture, x As Integer, y As Integer, Optional w1 As Integer, Optional h1 As Integer, Optional sx As Integer, Optional sy As Integer, Optional w2 As Integer, Optional h2 As Integer)"

Haven't tested the latter,

Alfred
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>