Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Aug 14, 2018 8:30 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Depricated structures???
PostPosted: Fri Jul 24, 2009 1:50 pm 
I am able to get structures out of an array... I just don't know how to put them into an array...

for (long i = 0; i <= ubound; i++) {
elementStruct tmp;
REALGetArrayStructure( (REALarrayStruct*) send, i, &tmp );
// Now I have a structure out of the array.
}

Now the reverse side of the scenario is populating an REALarray. (Which is a mystery to me.)
elementStruct t[10];
for (int i=0; i < 10; ++i)
REALSetArrayStructure( (REALarrayStruct *) receive, i, (void *) &t[i]); // Or at least this is what I think it should be....

receive is passed into C++ as the destination for returned data.
As RB doesn't know how much data is going to be put into the array, the array is declared in RB as:
dim receive(-1) as elementStructure

So I'm not sure what I need to do to make sure that C++ doesn't put too many elements into the array.
Or does it dynamically grow?

I wish I could get away from these structure definitions and use objects... But I can't for the life of me figure out how a class that is defined in RB can be passed and used by a C++ plugin.


Top
  
Reply with quote  
 Post subject: Does this explain it?
PostPosted: Fri Jul 24, 2009 5:22 pm 
I can pass a real basic class to the c++ plugin and it can use its methods and have access to its data? (Via methods or as variables?)

I found this code under the discussion of deprecated methods in RB.
http://www.mail-archive.com/realbasic-plugins@lists.realsoftware.com/msg01029.html

REALstring (*fpReadAll)( REALobject, long ) = (REALstring (*)( REALobject, long ))REALLoadObjectMethod( (REALobject)mSocket, "ReadAll( encoding as TextEncoding = nil ) as String" );
if (fpReadAll)
someString = fpReadAll( (REALobject)mSocket, 0 );
}


This code seems to show a C++ application calling a method of mSocket...
Pitty I don't have the RB code for where this mSocket was constructed.

As for accessing the data in the class....
Is this how you would get access to the properties of the class?
// Calling the function from the "flat C" SDK
long value = 0;
REALGetPropValueInt32( object, "SomeProperty", &value );


Top
  
Reply with quote  
 Post subject: Re: Depricated structures???
PostPosted: Sat Jul 25, 2009 11:29 am 
Offline
User avatar

Joined: Wed Sep 28, 2005 8:39 am
Posts: 9341
Location: St Augusta, MN
JustSomeGuy wrote:
I wish I could get away from these structure definitions and use objects... But I can't for the life of me figure out how a class that is defined in RB can be passed and used by a C++ plugin.


How it works depends on whether the class is defined by the plugin or by REALbasic. Generally speaking, it should be defined by the plugin. It's pretty rare that you need to do it the other way. If the plugin defines the class (using REALRegisterClass), then the plugin already has all of the information about the object available to it. If RB defines the class, then the plugin will need to use the dynamic access APIs to pull data from the object, which is significantly more fragile.


Top
 Profile  
Reply with quote  
 Post subject: Re: Depricated structures???
PostPosted: Mon Jul 27, 2009 11:41 am 
Still digging through the example code and ran across this example called TestPlugin.cpp.
Which seems to pass an array of objects to C++.
However there doesn't seem to be an rbp file that goes along with this example.
Could someone tell me what the syntax in RB would be like to call this method?

static REALobject arrayTestObjectFunc(REALobjectArray arr)
{
return REALGetArrayObject(arr, 3);
}
REALmethodDefinition arrayTestObjectDefn = {
&nbsp; &nbsp;(REALproc) arrayTestObjectFunc, REALnoImplementation, "arrayTestObject(arr() as Object) As Object"
};


Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group