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.

DLL Talk / Classes Function In String Table

Author
Message
puppysss
17
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 4th Jul 2010 12:09
Hi, Recently , I making a plug-in for dbpro.
I learned about Applying C Style Functions To DLL String Table.
But If Functions looks like this

How I apply Above Functions?
When I Written Like
"PGUI CREATE RICHEDIT
[DSLLLLLLD%CPGUIRICH::RichEdit_Create_Window%D"
,It Didn't Work.
Umm... I Really Solve This Problem. Help Me Plz!

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Jul 2010 15:31
It didn't work because you are calling a member function - you can't do that. Which object is it going to use (because you didn't tell it which one anywhere!)?

What you need to do is to provide a standard function that will call the member function on the object you require:


You can convert the 'ObjectId' to an instance of CPGUIRICH in one of two ways - first, use a lookup table that contains the ID to CPGUIRICH*, or you can return a handle when you create the new object and rely on the programmer to pass it in when needed.

I've used both methods - most of my plug-ins use a lookup of ID to pointer, but one, my networking plug-in, passes a handle to the user and requires that to be passed back to determine which network socket is being addressed.

Lookups are easier for the user. Handles are slightly faster.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 6th Jul 2010 13:38
Quote: "but one, my networking plug-in, passes a handle to the user and requires that to be passed back to determine which network socket is being addressed."

I think that is similar to what I do, I cast the pointer to an integer , then that integer can be passed to another function where it is cast back.

Out of interest can you directly call static methods of a class via the string table?

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Jul 2010 16:39
I would guess (and it IS a guess) that the MS compiler would allow it ... but in that case, why not just write a non-class function instead? They'd (most probably) be exactly the same except for name.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 7th Jul 2010 00:02
I was just wondering really. There are a few cases where I've written non-class functions that wrap around static methods but generally I am wrapping around actual objects. I prefer to put global stuff into classes anyway so that variables and functions can be nicely grouped, and to reduce pollution of the namespace.

puppysss
17
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 7th Jul 2010 11:54
Thanks So Much!
I really didn't know that class variable can get specific Id!
So, Could I Ask To You Something?
Questions
- Your Meaning is like this?


- C++'s Classes have Own Address? like this?
class MYCLASS // This Class have address?
{
public:
/*...*/
private:
/*...*/
};

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Jul 2010 15:09
Possibly. Without an actually full example I can't tell whether you've gotten the whole idea or not.

Using your code as a base, this is what I mean:


I prefer to use DWORD for passing around pointers, but it doesn't really matter too much. I'd also put some error checking in place in the CallObj function so that the user can't pass in a random or null value and have the call crash or corrupt memory (store it in an std::set or a std::vector when it's created, and check that the value exists in the storage before using it).

@Michael P,
That's what the namespace command is for.

Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 7th Jul 2010 15:36
Ah damn I've been coding in Java for the past year, totally forgot about that! Cheers

puppysss
17
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 8th Jul 2010 13:01
Michael P@ Thanks Again For Your Cheers , Helps...etc!

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 13th Oct 2010 05:09
IanM, you really know a lot about C++. I have (for the most part) no idea what you are talking about. I started programming (several years ago) with Liberty BASIC. I struggled with len back then. Then I went to Clonkscript (specific to the game Clonk), and couldn't manage it (I didn't realise it was based on C++). After that I went to DBPro. Since then I have tried to learn C++, but with little luck. Any tutorials I find are very dry and boring. They also never explain how to do anything! They all tell you about variables, pointers, char-pointers, etc. But I have only ever been able to make a feet2meters converter, and only following a tutorial. How do you know what commands you have??? How do you know learn what a namespace is? (I can do namespace std or something but it's useless unless I know why I'm using it) The whole language (compared to DBPro) seems very counter-intuitive.

Anyway if you could give me any kind of tutorials that will actually help me then I'd be grateful.

Thanks,
Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Oct 2010 15:48
Rather than stay with DBPro and write plug-ins, perhaps a better way for you to move forward would be to dive directly into GDK instead.

For the most part, the commands available are the same as DBPro's - SYNC ON matches dbSyncOn(), and MAKE OBJECT CUBE matches dbMakeObjectCube() for example.

This way, you can have a gentle intro to C++, but with some more interesting commands available to you. If you are a 'learn by doing' person, then that's one way that I've advise you to go.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 17th Oct 2010 11:31
I would, but I have to download the massive (I think 390mb) DirectX9 SDK. I can't do that. Is there no other way? For instance, I think the SDK includes masses of unneeded junk that Microsoft likes to stick in everything, you could upload only the needed files.

Yes, I'm a learn by doing person.

I was wondering (and assuming), can you use standard C++ stuff with GDK? Cause that way you could have the incredible power of C++ combined with the simplicity of DBPro. (I know, I sound like a salesperson

Clonkex

Making games is easy.....finishing them is a different matter.

Intel Core 2 Duo 2.8Ghz, Nvidia GeForce 9400 GT 512mb, 1gb ram.

Login to post a reply

Server time is: 2024-04-24 14:45:45
Your offset time is: 2024-04-24 14:45:45