OOP lib

Just starting out? Need help? Post your questions and find answers here.
SofT MANiAC
Enthusiast
Enthusiast
Posts: 142
Joined: Mon Sep 17, 2007 10:28 am
Location: P.O.P
Contact:

OOP lib

Post by SofT MANiAC »

How can I use classes from OOP libs in PB?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

It depends on what language they are written in. But the interface keyword can be used.
SofT MANiAC
Enthusiast
Enthusiast
Posts: 142
Joined: Mon Sep 17, 2007 10:28 am
Location: P.O.P
Contact:

Post by SofT MANiAC »

Trond wrote:But the interface keyword can be used.
How can I apply this? small example would be cool :(
any idea?
POiNT.OF.PRESENCE group
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4326
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

OOP has the advantage of being able to make tiny little problems into complex and frustrating HUGE problems...

That said... the OOPfiles speak here:

http://www.purebasic.fr/english/viewtop ... t=oop+pure

here:

http://www.purebasic.fr/english/viewtop ... t=oop+pure

and here:

http://www.purebasic.fr/english/viewtop ... t=oop+pure

I frankly cannot see why you would wish to torture yourself that way. My framework is slightly OOP like, but instead modified for inline ASM stack. Well, I think it is! :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
SofT MANiAC
Enthusiast
Enthusiast
Posts: 142
Joined: Mon Sep 17, 2007 10:28 am
Location: P.O.P
Contact:

Post by SofT MANiAC »

@Rook Zimbabwe
10x man, but I know what is OOP (I'm using PureObject by inc). :)
But I can't understand how to wrap classes from lib :oops:
POiNT.OF.PRESENCE group
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

It depends how the methods are wrapped up inside the lib. If it is a COM dll, well that requires use of interfaces and GUID's etc. There's enough examples in these forums of doing that kind of thing.

If you're talking about a static library built from an oop language (like Emergence Basic for example) then you may be able to get away with importing the functions by hand and building an interface yourself - it depends how the methods are built to accept parameters and whether they are to accept a *this type parameter etc. If this is not the case then you may just be able to import the functions for a c-style wrapper etc.

You will need a good definition of the underlying class; it's methods and private data etc. and you will need to know how the method names are mangled when placed into the static lib. oop languages often mangle the names by combining the class and method names etc.

So, there are a lot of 'ifs' and buts' with this I'm afraid.
I may look like a mule, but I'm not a complete ass.
SofT MANiAC
Enthusiast
Enthusiast
Posts: 142
Joined: Mon Sep 17, 2007 10:28 am
Location: P.O.P
Contact:

Post by SofT MANiAC »

@srod
thanks for info!
ok, i wanna make a wrapper for PopCapFramework (SexyApp) (VC++)
POiNT.OF.PRESENCE group
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Bloody hell; good luck with that!
I may look like a mule, but I'm not a complete ass.
SofT MANiAC
Enthusiast
Enthusiast
Posts: 142
Joined: Mon Sep 17, 2007 10:28 am
Location: P.O.P
Contact:

Post by SofT MANiAC »

srod wrote:Bloody hell
Yep :lol:
POiNT.OF.PRESENCE group
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4326
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

I knew it! :D
I still reccomend HGE
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
SofT MANiAC
Enthusiast
Enthusiast
Posts: 142
Joined: Mon Sep 17, 2007 10:28 am
Location: P.O.P
Contact:

Post by SofT MANiAC »

Rook Zimbabwe wrote:I knew it! :D
I still reccomend HGE
ok :)
I'll try it :D
POiNT.OF.PRESENCE group
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Rook Zimbabwe wrote:OOP has the advantage of being able to make tiny little problems into complex and frustrating HUGE problems...
I was once under that impression until i fully understood OOP.
--Kale

Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Well, let's not go there again.....

but I'm with Kale!

OOP is very very very very nice! :)
I may look like a mule, but I'm not a complete ass.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

Is there a simple example on how to wrap classes from a DLL in Purebasic?

Not because I like OOP, but because I know there are a lot of great engines/DLL that uses OOP and I'd like to have the functionality/commandset in PB.
Proud registered Purebasic user.
Because programming should be fun.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Well, difficult to comment without knowing more. If you are asking if you can create a dll in PB which contains OOP classes which you can access from a client program - then yes; no problam at all. I am currently working on such a project in which a dll exposes 4 classes and over 120 methods between them.

The dll exports a function which simply initialises a new instance of the class and returns a pointer to the newly created object etc. Very simple, very effective.

All the client program needs in order to make use of the object returned from the dll is a list of all the interfaces exposed by the dll and the methods therein etc. and that's it.

If this is the kind of thing you are asking about then I should be able to knock up a simple example for you. It would have to wait until tomorrow though. :)
I may look like a mule, but I'm not a complete ass.
Post Reply