I have been using sfml libraries and it's string class.
I really want to keep using the sfml string class though it will not work with the angelscript std string addon.
Even though if the string class is given a stdString in c++ it will convert it.
I have tried modifying the angelscript std string add on for sfml string(with some changes to sfml string)
Like the following error
error: invalid static_cast from type '<unresolved overloaded function type>' to type 'bool (*)(const sf::String&, const sf::String&)'|
for the following
r = engine->RegisterObjectMethod("string", "bool opEquals(const string &in) const", asFUNCTIONPR(operator ==, (const sf::String &, const sf::String &), bool), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
I know I can not expect you to write it or fix mine so I just have a few questions
I have not really read anything about alternative to the std string addon anywhere. I was wondering if there might be some other examples I can look at.
Also internally sfml String uses a std::basic_string<Uint32> to store the string. the functions that i would expose to script would be like this
int XUIElement::getAttributeInt(sf::String searchName)
Is there a way this could be used to simplify the process. I am not really sure if std string addon needs to be modified for using this type of string as opposed to just a uint8 char.
Custom text handling for SFML String
The <unresolved overloaded function type> is most likely because SFML implements the equality operator as a class method instead of a global function. Try changing the registration to the following:
Hopefully it should work. If not, please post what the SFML string class looks like.
The string type is really just an ordinary type in AngelScript, and is registered just like that with the only exception being the additional string factory. I include registration for the std::string because it is the most common, but many developers use their own implementation.
std::basic_string<Uint32> is a completely different type than std::basic_string<char>, a.k.a std::string, so the fact that both are implemented from the same template doesn't really make things any easier here.
r = engine->RegisterObjectMethod("string", "bool opEquals(const string &in) const", asMETHODPR(sf::String, operator ==, (const sf::String &) const, bool), asCALL_THISCALL); assert( r >= 0 );
Hopefully it should work. If not, please post what the SFML string class looks like.
The string type is really just an ordinary type in AngelScript, and is registered just like that with the only exception being the additional string factory. I include registration for the std::string because it is the most common, but many developers use their own implementation.
std::basic_string<Uint32> is a completely different type than std::basic_string<char>, a.k.a std::string, so the fact that both are implemented from the same template doesn't really make things any easier here.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Never mind I worked out what was wrong.
I was not using namespace sf which is where the global function operators was declared.
I could get around it by using that name space or using the asFUNCTIONPR
asFUNCTIONPR(sf::operator +, (const sf::String &, const sf::String &), sf::String)
all that frustration for something so stupid.
[s]With that change i get the following as an error
I also think the function version matches it better.
It uses this outside of the class declaration. like so
There must be something really stupid I am doing
Also here is a link to the headers of sfml string.
https://github.com/L...stem/String.hpp[/s]
I was not using namespace sf which is where the global function operators was declared.
I could get around it by using that name space or using the asFUNCTIONPR
asFUNCTIONPR(sf::operator +, (const sf::String &, const sf::String &), sf::String)
all that frustration for something so stupid.
[s]With that change i get the following as an error
error: 'operator==' is not a member of 'sf::String'|
I also think the function version matches it better.
It uses this outside of the class declaration. like so
SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
There must be something really stupid I am doing
Also here is a link to the headers of sfml string.
https://github.com/L...stem/String.hpp[/s]
![:)](http://public.gamedev.net//public/style_emoticons/<#EMO_DIR#>/smile.png)
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement