forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PRX & Functions, Objects, variables

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Feb 15, 2006 10:11 pm    Post subject: PRX & Functions, Objects, variables Reply with quote

hi!
i had a look on the sample prx from pspsdk,
i saw that you can provide functions.
is it also possible to offer classes etc?
if so, how?

i guess varibles are passed by:
psp_export_var*

whats the diff between:
_nid and _hash

thanks in advance
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Feb 16, 2006 6:01 am    Post subject: Reply with quote

Well for a start you might want to read http://forums.ps2dev.org/viewtopic.php?t=4269 which describes how to build PRXes in PSPSDK along with descriptions of the various bits in psp-build-exports like the different between _NID and _NAME.

As for exporting C++ objects theoretically you can do it if you want to put in the time. C++ functions are exported as mangled names to the linker, the linker itself doesn't really know they are C++ functions, all it sees is a weird name which it ties with other weird names. Take for example a simple class.

Code:
class Test
{
    public:
        Test();
        ~Test();
        void Hello(const char *str);
};


If you compile that then run nm on the resulting binary you find 5 symbols.

Code:

00000018 T _ZN4Test5HelloEPKc
00000006 T _ZN4TestC1Ev
00000000 T _ZN4TestC2Ev
00000012 T _ZN4TestD1Ev
0000000c T _ZN4TestD2Ev


The first one is the mangled form of Test::Hello(), the next two are constructor definitions and the last two are the destructor definitions.

If you export from your application these function names they should in theory line up and you will be able to import them in your application. There are of course caveats, you probably can't externally access static variables for a start due to the way I think the PSP's variable export works, you probably cannot use exceptions, and it is pretty nasty to maintain if you change anything in your class but it should be doable.

Of course it is questionable if it is even worth it, the library import interface is abit restrictive, for example catching unresolved symbols will be abit of a nightmare, and I can't really see the biggest reason why you would necessarily want importable classes anyway, perhaps it is just me.

Have fun anyway :P
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Thu Feb 16, 2006 8:42 am    Post subject: Reply with quote

creating prx by adding
BUILD_PRX=1
to your makefile...
did not think its that simple
(hope i did not misunderstood that)

greets
lumo
PS: english is NOT my foreign language ;)
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Fri Feb 17, 2006 3:17 am    Post subject: Reply with quote

If you are using the pspsdk makefiles then yes for the most part it is that simple. For example take one of the pspsdk GU samples (say sprite), add that BUILD_PRX=1 line and rebuild it. Magically it will spit out a working PRX :)
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Fri Feb 17, 2006 3:35 am    Post subject: Reply with quote

so all i have to do is put up some documets which referr to the functions...

nice, now i need some beta-testers :D

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Fri Feb 17, 2006 3:48 am    Post subject: Reply with quote

Ah well of course if you are using a custom exports file you need to also set PRX_EXPORTS to exports.exp and remove any exports.o from your link line, but it is still simple :)
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Fri Feb 17, 2006 3:50 am    Post subject: Reply with quote

humm...
so exports... class is handled like a var?

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group