2012-05-28 16:58:16 +08:00
|
|
|
/**
|
|
|
|
* Simple example of a C++ class that can be binded using the
|
|
|
|
* automatic script generator
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "simple_class.h"
|
|
|
|
|
|
|
|
SimpleNativeClass::SimpleNativeClass()
|
|
|
|
{
|
2012-05-29 16:21:23 +08:00
|
|
|
// just set some fields
|
|
|
|
m_someField = 0;
|
|
|
|
m_someOtherField = 10;
|
|
|
|
m_anotherMoreComplexField = NULL;
|
2012-05-28 16:58:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// empty destructor
|
|
|
|
SimpleNativeClass::~SimpleNativeClass()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// just a very simple function :)
|
|
|
|
int SimpleNativeClass::doSomeProcessing(std::string arg1, std::string arg2)
|
|
|
|
{
|
2012-05-29 16:21:23 +08:00
|
|
|
return arg1.length() + arg2.length();
|
2012-05-28 16:58:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleNativeClass::setAnotherMoreComplexField(const char *str)
|
|
|
|
{
|
2012-05-29 16:21:23 +08:00
|
|
|
if (m_anotherMoreComplexField) {
|
|
|
|
free(m_anotherMoreComplexField);
|
|
|
|
}
|
|
|
|
size_t len = strlen(str);
|
|
|
|
m_anotherMoreComplexField = (char *)malloc(len);
|
|
|
|
memcpy(m_anotherMoreComplexField, str, len);
|
2012-05-28 16:58:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace SomeNamespace
|
|
|
|
{
|
|
|
|
AnotherClass::AnotherClass()
|
|
|
|
{
|
2012-05-29 16:21:23 +08:00
|
|
|
justOneField = 1313;
|
|
|
|
aPublicField = 1337;
|
2012-05-28 16:58:16 +08:00
|
|
|
}
|
|
|
|
// empty destructor
|
|
|
|
AnotherClass::~AnotherClass()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void AnotherClass::doSomethingSimple() {
|
2012-05-29 16:21:23 +08:00
|
|
|
fprintf(stderr, "just doing something simple\n");
|
2012-05-28 16:58:16 +08:00
|
|
|
}
|
|
|
|
};
|