Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Have some questions about setting up dependency functions in a plugin

Author
Message
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 2nd Feb 2010 03:59 Edited at: 2nd Feb 2010 23:24
When using the functions GetNumDependencies( void ) and GetDependencyID(int ID) in your plugin, does DBPro expect to see the ReceiveCoreDataPtr(LPVOID CorePtr) function?

Does DBPro expect GetNumDependencies( void ) to return the number of dependencies as an integer?

Does DBPro expect GetDependencyID(int ID) to return the memory address to a string (from an array) defining the dependency? Is this function repeatedly called to get all of the dependency names if there is more than one defined in the array? Hence, incrementing the dependency array element.

Also, is the Constructor function called before or after the two dependency functions?

I am trying to do this in PureBasic 4.40, but having trouble using the dependency functions. It seems to crash at these functions.

PureBasic Code Snippet:


Yes, I did change the function names to mangled after compiling the DLL in PureBasic.
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 2nd Feb 2010 10:30 Edited at: 2nd Feb 2010 23:23
Okay, here is the PureBasic source code for anyone trying to write a plugin on there own. Maybe someone can help with this. NEEDS WORK!

I haven't tested the whole thing just the dependency functions, which crashes DBPro at the moment. I tried to make this example closely approximate IanM's C++ example.

IanM's Original C++ Example:


My PureBasic 4.40 Example:


PureBasic Globstruct (May need updated):


Edited: Change the beginning array element back to zero.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Feb 2010 14:47
Can't help with the PureBasic stuff, but the answers to your first post are:
1. No, you don't need a ReceiveCoreDataPtr
2. Yes, it's an int (if it matters, returned in the eax register).
3. Yes, it returns a pointer to the string (again returned in eax).
4. Yes, it will be called the same number of times as the value you returned using GetNumDependencies. So if you returned 4, the GetDependencyID will be called with values of 0, 1, 2 and 3, and expect a pointer to each dependency string.
5. Constructor is called after the dependencies, but before ReceiveCoreDataPtr.

Remember that all of these functions that you can provide are entirely optional (except that GetNumDependencies and GetDependencyID should both be present if one of them is).

D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 2nd Feb 2010 23:20
Thanks, IanM.

I figured the functions were supposed to return an int and a string pointer. Thats standard usually, but I just wanted to confirm it.

So, The GetDependencyID is called starting at zero. I will change it back to zero then.

It seems that DBPro doesn't like these two function done in PureBasic. Unless it's something else that I've over looked.

If I understand correctly, the call order is:

1. GetNumDependencies()
2. GetDependencyID()
3. Constructor()
4. RecieveCoreDataPtr()
5. Destructor

If anyone has some input on how to do this in PureBasic 4.40, I would appreciate it.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Feb 2010 23:39
Actually, my personal notes list the Constructor being called before the dependencies - TBH, I do all of my construction in the ReceiveCoreDataPtr, so it's not something that would cause me any problems.

Anyway, I've now reconfirmed the order of initialisation/teardown as:
- Constructor
- GetNumDependencies
- GetDependencyID (called once for each dependency)
- ... Window Created
- ReceiveCoreDataPtr
- ... Further internal initialisation
- ... Normal running, until user-code ends
- ... Window Destroyed
- PreDestructor
- Destructor

D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 3rd Feb 2010 00:21
Wow! I didn't know that. Especially the PreDestructor function...

Yeah, I used the ReceiveCoreDataPtr to init my internal function prototypes. Effectively getting the dependency function pointers from the Globstruct g_Memblocks DLL handle. This is to say if I passed the core pointer into the function correctly. Haven't thoroughly tested yet.

Is there any documentation on these functions somewhere? It would be nice for 3rd party plugin developers to have.
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 3rd Feb 2010 07:38 Edited at: 3rd Feb 2010 07:41
I got this working! The changes to my code were minor.

If anyone is interested, I will probably be posting a sticky thread in the PureGDK forum. Why? Because it has to do with PureBasic. Just to add more HOW TO DO with PureBasic in the forum. Unless Mistrel or someone else seriously abjects to putting it there rather than in the DLL Talk forum.

Let me know what you think.

BTW, thanks again IanM!
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 3rd Feb 2010 20:17
Remember that the dependency functions are called at compile time as well as at runtime (Didn't know they were called at runtime as well, that's odd!)

kaedroho
16
Years of Service
User Offline
Joined: 21st Aug 2007
Location: Oxford,UK
Posted: 3rd Feb 2010 22:53
It might be used for DBPro to calculate the best order of which the dlls must be loaded.

D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 4th Feb 2010 02:54
I will be posting a thread in the DLL Talk board about this shortly. Feel free to add your contributions to it there.

Login to post a reply

Server time is: 2024-04-20 11:54:59
Your offset time is: 2024-04-20 11:54:59