Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

AddressOf equivalent? (Real Studio Plugins Mailinglist archive)

Back to the thread list
Previous thread: Plugin Crashes in 2005
Next thread: Invalid Plugin Method Format in RB2k5?


macosx and unix paths   -   GOLD
  AddressOf equivalent?   -   Alfred Van Hoek
   Re: AddressOf equivalent?   -   Björn Eiríksson <b
   Re: AddressOf equivalent?   -   Alfred Van Hoek
   Re: AddressOf equivalent?   -   Jonathan Johnson
   Re: AddressOf equivalent?   -   Alfred Van Hoek
   Re: AddressOf equivalent?   -   Alfred Van Hoek
   Re: AddressOf equivalent?   -   Jonathan Johnson
   Re: AddressOf equivalent?   -   Alfred Van Hoek
   Re: AddressOf equivalent?   -   Mars Saxman

AddressOf equivalent?
Date: 25.06.05 17:25 (Sat, 25 Jun 2005 12:25:57 -0400)
From: Alfred Van Hoek
Is there an AddressOf equivalent for a plugin? For example, there is a
need to get a function pointer to a RB defined method. Are there
already tricks to accomplish something like this?

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>

Re: AddressOf equivalent?
Date: 25.06.05 17:53 (Sat, 25 Jun 2005 16:53:03 +0000)
From: Björn Eiríksson <b

On 25.6.2005, at 16:25, Alfred Van Hoek wrote:

> Is there an AddressOf equivalent for a plugin? For example, there
> is a need to get a function pointer to a RB defined method. Are
> there already tricks to accomplish something like this?
>
> Alfred

LoadObjectMethod and LoadGlobalMethod ?

Re: AddressOf equivalent?
Date: 25.06.05 20:27 (Sat, 25 Jun 2005 15:27:40 -0400)
From: Alfred Van Hoek

On Jun 25, 2005, at 12:53 PM, Björn Eiríksson wrote:

>
> On 25.6.2005, at 16:25, Alfred Van Hoek wrote:
>
>> Is there an AddressOf equivalent for a plugin? For example, there is
>> a need to get a function pointer to a RB defined method. Are there
>> already tricks to accomplish something like this?
>>
>> Alfred
>
> LoadObjectMethod and LoadGlobalMethod ?

Both return a nil pointer, that is why I wanted to use AddressOff, but
it returns a ptr type. I was trying to put this into a memoryblock, by
exploiting the memoryblock operator-convert from?, like

memblock = AddressOf("myMethod") but this leads to a syntax error?

Having it in a memblock it would be easy to retrieve it as a REALproc
from REALmemoryBlockGetPtr....

What gives?

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>

Re: AddressOf equivalent?
Date: 25.06.05 20:55 (Sat, 25 Jun 2005 14:55:33 -0500)
From: Jonathan Johnson

On Jun 25, 2005, at 2:27 PM, Alfred Van Hoek wrote:

>
> On Jun 25, 2005, at 12:53 PM, Björn Eiríksson wrote:
>
>>
>> On 25.6.2005, at 16:25, Alfred Van Hoek wrote:
>>
>>> Is there an AddressOf equivalent for a plugin? For example, there
>>> is a need to get a function pointer to a RB defined method. Are
>>> there already tricks to accomplish something like this?
>>>
>>> Alfred
>>>
>> LoadObjectMethod and LoadGlobalMethod ?
>>
> Both return a nil pointer,

How are you using them? They work for us just fine. One thing to note
is that if a global method isn't being used in REALbasic code, it
will be linked out, so you must refer to the method in question for
it to be there at runtime.

> that is why I wanted to use AddressOff, but it returns a ptr type.
> I was trying to put this into a memoryblock, by exploiting the
> memoryblock operator-convert from?, like
>
> memblock = AddressOf("myMethod") but this leads to a syntax error?

The AddressOf syntax is this:

dim mb as MemoryBlock
mb = AddressOf myMethod

No quotes are allowed. The item passed in is not a string.

HTH,
Jon

--

Re: AddressOf equivalent?
Date: 25.06.05 21:13 (Sat, 25 Jun 2005 16:13:36 -0400)
From: Alfred Van Hoek

On Jun 25, 2005, at 3:55 PM, Jonathan Johnson wrote:

> How are you using them? They work for us just fine. One thing to note
> is that if a global method isn't being used in REALbasic code, it will
> be linked out, so you must refer to the method in question for it to
> be there at runtime.

void GetHandler(REALobject instance, REALstring procname)
{
ClassData(MyClass, instance, MyData, data);
REALproc handler = (REALproc)REALLoadObjectMethod(instance,
procname->CString());
....
}

The myClass is subclassed in RB, A method to this class is defined as

procname() as Boolean

To use a global method, a similar method was defined in Module1 and

REALproc handler = (REALproc)REALLoadGlobalMethod(nil,
procname->CString());

was called. The handler in both cases was 0.

>
>> that is why I wanted to use AddressOff, but it returns a ptr type. I
>> was trying to put this into a memoryblock, by exploiting the
>> memoryblock operator-convert from?, like
>>
>> memblock = AddressOf("myMethod") but this leads to a syntax error?
>
> The AddressOf syntax is this:
>
> dim mb as MemoryBlock
> mb = AddressOf myMethod
>
> No quotes are allowed. The item passed in is not a string.

Oh, thanks a bunch, wished that RB's compiler would have pointed this
out. I'll try this avenue again,

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>

Re: AddressOf equivalent?
Date: 27.06.05 00:14 (Sun, 26 Jun 2005 19:14:26 -0400)
From: Alfred Van Hoek

On Jun 25, 2005, at 3:55 PM, Jonathan Johnson wrote:

> The AddressOf syntax is this:
>
> dim mb as MemoryBlock
> mb = AddressOf myMethod
>
> No quotes are allowed. The item passed in is not a string.
>
> HTH,

Thanks Jon, AddressOf is cool and does exactly that what was needed.

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>

Re: AddressOf equivalent?
Date: 27.06.05 01:09 (Sun, 26 Jun 2005 19:09:03 -0500)
From: Jonathan Johnson

On Jun 25, 2005, at 3:13 PM, Alfred Van Hoek wrote:

>
> On Jun 25, 2005, at 3:55 PM, Jonathan Johnson wrote:
>
>> How are you using them? They work for us just fine. One thing to
>> note is that if a global method isn't being used in REALbasic
>> code, it will be linked out, so you must refer to the method in
>> question for it to be there at runtime.
>>
> void GetHandler(REALobject instance, REALstring procname)
> {
> ClassData(MyClass, instance, MyData, data);
> REALproc handler = (REALproc)REALLoadObjectMethod(instance,
> procname->CString());
> ....
> }
>
> The myClass is subclassed in RB, A method to this class is defined as
>
> procname() as Boolean
>
> To use a global method, a similar method was defined in Module1 and
>
> REALproc handler = (REALproc)REALLoadGlobalMethod(nil, procname-
> >CString());
>
> was called. The handler in both cases was 0.

Is the value passed in for procname "procname() as Boolean"? You need
to pass in the entire signature, with proper types, to both
REALLoadGlobalMethod and REALLoadObjectMethod for it to work.

HTH,
Jon

Re: AddressOf equivalent?
Date: 27.06.05 03:23 (Sun, 26 Jun 2005 22:23:26 -0400)
From: Alfred Van Hoek

On Jun 26, 2005, at 8:09 PM, Jonathan Johnson wrote:

> Is the value passed in for procname "procname() as Boolean"? You need
> to pass in the entire signature, with proper types, to both
> REALLoadGlobalMethod and REALLoadObjectMethod for it to work.

Yes, I know and thanks for the reminder. However, AddressOf does not
require knowledge of the signature at all and that 's just a
convenience under particular circumstances. While usage of AddressOf
failed initially (because I used quotes) the fallback was dynamic
access and indeed forgot to provide the entire signature, and should
have known better, because dynamic access is used very often in the
plugin.

AddressOf is more natural than a full signature defined in a string in
the RB IDE.

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>

Re: AddressOf equivalent?
Date: 27.06.05 17:17 (Mon, 27 Jun 2005 09:17:35 -0700)
From: Mars Saxman

On Jun 26, 2005, at 7:23 PM, Alfred Van Hoek wrote:

> Yes, I know and thanks for the reminder. However, AddressOf does
> not require knowledge of the signature at all and that 's just a
> convenience under particular circumstances. While usage of
> AddressOf failed initially (because I used quotes) the fallback was
> dynamic access

Huh? What do you mean by this? If you are using RB code then
AddressOf is your only option, and if you are using a plugin then the
dynamic access API is your only option. How can one be a fallback for
the other? I am worried that you have written a plugin which expects
its RB client code to pass in a function pointer. This would
definitely not be an intended use for AddressOf.

Mars Saxman
REAL Software

_______________________________________________
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>