Passing char[] or char*
I was wondering if there is a way of passing
char* or char[] to AS. The existent std::string class
seems to be a little bit overloaded with that streaming calls.
// cpp
long System::SetProc(const char* , const char* )
{
}
...
r = ps->RegisterObjectMethod("System", "long SetProc(const char*, const char*)", asMETHOD(System,SetProc),asCALL_THISCALL);
//script
int Main(System sys)
{
sys.SetProc("sysenv.as", "SystemProc");
}
I really hate when people follow links off the front page and don't bother to pay attention to what forum the thread is in.
As for the question; use std::string. If you find it's a bottle neck later (after extensive profiling, of course; and it won't be a bottle neck) then look for other solutions.
As for the question; use std::string. If you find it's a bottle neck later (after extensive profiling, of course; and it won't be a bottle neck) then look for other solutions.
You can create your own wrapper around "char*" and register is as a new string class for AS (lite std::string if you prefer).
Quote:Original post by Deyja
I really hate when people follow links off the front page and don't bother to pay attention to what forum the thread is in.
Point taken. Sorry, I'm new here...
Don't be so harsh, Deyja. I just think it is funny. :)
Hanatarou: If you didn't figure it out yet; AS is short for AngelScript, which in turn is short for AngelCode Scripting Library.
---
Currently the easiest way, in my opinion, is to write wrapper functions for those functions that take const char pointers.
I do have plans however to let AngelScript use a registered method that will convert the registered string type to const char*, and vice versa. This way you'll be able to register these functions directly. I'm not sure when I will get around to implementing that however.
Regards,
Andreas
Hanatarou: If you didn't figure it out yet; AS is short for AngelScript, which in turn is short for AngelCode Scripting Library.
---
Currently the easiest way, in my opinion, is to write wrapper functions for those functions that take const char pointers.
I do have plans however to let AngelScript use a registered method that will convert the registered string type to const char*, and vice versa. This way you'll be able to register these functions directly. I'm not sure when I will get around to implementing that however.
Regards,
Andreas
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement