QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

[CPP] Luabind

This is a discussion on [CPP] Luabind within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Luabind What:A small lib to simplify binding CPP classes to lua. Who:jparishy Spoiler for Readme : Code: This is a ...

Reply
 
LinkBack Thread Tools
Old 08-18-2008, 03:51 PM   #1
No longer a community member.
 
a_noob's Avatar
 
Join Date: Sep 2006
Location: Over there.
Posts: 666
Trader Feedback: 0
Default [CPP] Luabind

Luabind
What:A small lib to simplify binding CPP classes to lua.
Who:jparishy

Spoiler for Readme:
Code:
This is a copy of Luabind revision 1.26.2.5 from the SVN ported to the Sony PSP.
 
Luabind is under the MIT License.
 
What is Luabind?
----------------
Luabind is the best library available for exporting C and C++ code to the lua interpretor, and vice versa.
I've tried all of the competitors, and nothing beats Luabind's awesomeness.
 
 
Dependencies:
-------------
Boost4PSP - http://boost4psp.sourceforge.net/
Lua - svn://svn.ps2dev.org/psp/trunk/lua
 
You will need to install both of the above for Luabind to work.
 
Install:
--------
After installing the Dependencies (see above), go into the luabind directory (The one with Makefile.PSP in it),
and type "make -f Makefile.PSP" to build the library, then "make -f Makefile.PSP install" to install it. You can clean the directory by
doing "make -f Makefile.PSP clean".
 
Samples:
--------
There is a sample in the examples/PSP folder. Just type "make" to build it.
 
Happy Coding!
 
-Julius Parishy
 
Copyright (C) The Luabind Team
http://www.rasterbar.com/products/luabind.html


Spoiler for Example:
Code:
// Minimal Luabind test on the PSP.
// Loads a luafile named 'test.lua'
// and uses the class 'Test' which is
// exported to lua.
//
// Copyright (C) 2008 Julius Parishy
 
#include <iostream>
#include <string>
using namespace std;
 
#include <luabind/luabind.hpp>
#include <lua.hpp>
 
#include <pspkernel.h>
PSP_MODULE_INFO("Luabind Test", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
 
class Test
{
private:
	std::string m_string;
public:
	Test(const std::string& str) : m_string(str) { }
	~Test() { }
	void print() { std::cout << m_string << "\n"; }
};
 
int main(int argc, char** argv)
{
	lua_State* luaMain = lua_open();
	luaL_openlibs(luaMain);
	luabind::open(luaMain);
	luabind::module(luaMain)
	[
		luabind::class_<Test>("Test")
			.def(luabind::constructor<const std::string&>())
			.def("print", &Test::print)
	];
 
	int err = luaL_loadfile(luaMain, "test.lua");
	if(!err)
	{
		err = lua_pcall(luaMain, 0, LUA_MULTRET, 0);
		if(err)
		{
			std::cout << "Lua encountered an error. \"" << lua_tostring(luaMain, -1) << "\n";
		}
	}
 
	lua_close(luaMain);
	return 0;
}


Download:Here
a_noob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-18-2008, 04:29 PM   #2
Local Tech
 
joseph10444's Avatar
 
Join Date: Oct 2007
Real First Name: Joe
Location: home
Just Played: rockband
Posts: 1,822
Trader Feedback: 0
Default

cool grweat job
joseph10444 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-18-2008, 05:33 PM   #3
Enter Custom Title
 
dan369's Avatar
 
Join Date: Jan 2008
Real First Name: Dan
Location: Wales, cardiff
Just Played: Overlord 2
Posts: 1,308
Blog Entries: 1
Trader Feedback: 0
Default

Nice Normally i wouldn't care about C++ things but i'm started taking interest.
dan369 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
cpp , luabind

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 04:34 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us