Advertisement

a suggestion for string object...

Started by October 16, 2005 02:04 AM
3 comments, last by DaesDemon 19 years, 1 month ago
A function cannot directly register which take a char* parameter, it is headache that we must wrap this function again and replace the const char* with std::string. So, I think, if the was a special flag for register function when the function have one or more char* parameters and when angel engine call this function, it will pass the std::string::c_str() returned value, not the object reference, the will give we some convenience.
That's nice, except theres no guarantee the string class has such a function. Yes, std::string does, but AngelScript allows you to use any string class. It would require the use of a reverse-StringFactory function, and angelscript would have to carefully manage the memory involved. On the other hand, you could change your own classes' interface, or wrap them if changes are not possible. There are reasons std::string is prefered to char*, and you should never have a reason to use char* over std::string, unless your code is C.
Advertisement
the string cpp included in angel script is just an addon not part of the engine, that said it would require some extra option in the engine to make the string magical so it converts alone.

At the end string is much better than char* as Deyja said. Unless you are using c in that case you can change the string addon (aka making a new one) that uses char* instead of std:string.
------ XYE - A new edition of the classic Kye
I have already been thinking about implementing some way that would allow the application to tell AngelScript to convert a type just before calling a registered function. That would allow AngelScript to convert for example a string to const char * when passing it as a parameter. But any such implementation will not be done for a while yet, because I don't have the time to do so.

Until then I'm afraid you'll have to standardize your application-script interface so that all your functions work with the same string type. Or you could write manual functions for converting between one string type to another.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Perhaps the casting operator magic would happends there ;)

This topic is closed to new replies.

Advertisement