lxnyce

Members
  • Content count

    58
  • Joined

  • Last visited

Community Reputation

122 Neutral

About lxnyce

  • Rank
    Member
  1. AngelScript 2.5.0 WIP 2

    Just catching up on AngelScript happenings and seen this message. Hooray for pointers :).
  2. How to Interface with C/C++?

    Pardon me for being a grump, but what do those other languages have to do with AngelScript? The main point of AngelScript IMHO is speed, ease of use, C/C++ coding similarities, and quick binding to existing code. Its just not a fair comparison to say something like that. Perhaps withlord will work on those items, but thats if they will benefit the current users. In short, yes you can do that in VBA and SAS (don't quite know what this is), but how many cross platform games use those as scripting languages?
  3. AS Library bindings

    I agree. There should be some way to provide different bindings, that users don't have to manually compile to include. Perhaps create a generic C dll interface for registerring scripts through include statements. This way you can drop a dll into your exe directory and have support for that plugin if available. Some key plugins could be things like IO, HTTP, GUI Toolkits, etc...
  4. Get/Set Properties.

    Not quite sure what "Syntatic Sugar" means, but Rain Dog, I don't think its an option for all users of AngelScript to go in and manually modify their classes to provide get/set properties. For example, my node class knows nothing about AngelScript and neither does its 50+ different types. I would like to keep it that way. AngelScript is used as an add-on. I created a node wrapper, which exposes safe rendering methods to angelscript. This AngelScript node type maintains script safety whenever calling anything pertaining to application node's. As such, I can query for a given node and assign it to an ASNode variable. Any operations done on this ASNode type checks to see if the node is valid. Thus the script can query for an existing node, and assign it properties safely even if the node wasn't found. Here is a little example of how properties like I stated above could have helped. I have an internal node type "TextBox" which doesn't know anything about AngelScript. AngelScript creates the textbox which is simply a generic node. We can then set properties on that node using the Set command. /* Store a global variable for our text box */ Node g_tb; /* Called once when the scene is created or this node is added to the scene */ void OnStartup() { /* Creates a textbox node */ g_tb = env.CreateTextBox( "TextBox" ); /* Set its initial position */ g_tb.Set("Top Y", env.Height()-45); g_tb.Set("Bottom Y", env.Height()-5); g_tb.Set("Right X", 300 ); /* Anchor it to the bottom left of the screen */ g_tb.Set("Anchor", "Bottom + Left"); } /* Called every time the scene is rendered */ void OnRender() { /* Grab our current viewing position */ Point vpos = env.GetViewPosition(); /* Convert our position to a string */ string spos; spos = "Pos : " + vpos.x + " , " + vpos.y + " , " + vpos.z; /* Set the new text onto our textbox */ g_tb.SetString("Text", spos); /* Display our textbox */ g_tb.Render(); } Another area is when registerring GUI properties. GUI toolkits I work with typically don't have member variables I can modify myself (or its just not safe to do that). Its best to call the member functions usually. By having this method of setting properties, we can register something like window.title = "My Title" without the need of having a string variable to store the physical title property. Nevertheless, this is again a selfish request on my part. I can live with it as it stands right now. It probably won't even work with my properties with spaces in their names anyway. The current method works, just not as clean as get/set property operations. [Edited by - lxnyce on August 21, 2005 11:47:34 PM]
  5. Get/Set Properties.

    How about a generic method of setting/getting properties. In the script, it would look like this : MyClass.xpos = 10; MyClass.xpos = "10"; In C++ we register two property functions like below: void MyClass::GetProperty( string &name, string &value ); void MyClass::GetProperty( string &name, double &value ); void MyClass::SetProperty( string &name, string &value ); void MyClass::SetProperty( string &name, double &value ); //! Example of using only a string get property to represent all property methods void MyClass::SetProperty( string &name, string &value ) { MyClassProperty *prop = FindProperty( name ); /* Find the internal representation of the property */ if (!prop) { /* If we didn't find it, simply return */ Log( "Property not found : MyClass::SetProperty::" + name ); return; } switch (prop->GetType()) { case PROP_STRING: ((StringProp *)prop)->Set( name ); break; case PROP_NUMBER: ((NumberProp *)prop)->Set( atof(name) ); break; /* You can support other properties here like boolean, color, position, etc... */ default: Log( "Unsupported property type : MyClass::SetProperty::" + name ); } } Ideally, I think we should only be forced to register the get/set string property values. AngelScript would then convert the values into strings if the number propety wasn't available. My selfish reasoning behind this, is that I use alot of reflectance code these days. For example, I typically have a node class that has properties assigned to it. I know nothing of that node class, but it has a set of random properties I can query for. So with the functions above, I can query for "xpos" at runtime and simply return or change its value based on the internal type of xpos I found. I realize its not as fast as the other property routines due to the string search, but its at least backwards and forwards compatible while eliminating the need for the developer to register 20 different property functions for each object type they have. What do you guys think? [Edited by - lxnyce on August 21, 2005 6:52:25 PM]
  6. Module building error

    Just a guess, but you probably have to register it with the address of pi, and not the value. engine->RegisterGlobalProperty("const float PI", (void*)π); Edit : Now I see why witchlords reply looks like that. & p_i gets changed to &pi. Use the following without the '_': engine->RegisterGlobalProperty("const float PI", (void*)&p_i);
  7. Registerring Strings

    Thanks for letting us know :).
  8. Registerring Strings

    I ran into the INTERNAL COMPILER ERROR issue as well, but only when trying to resolve the std:string issue, so I didn't mention it. Deyja, the code to the string class is not that easy to disect, and if I could I would post it. It is basically wxString from wxWidgets though. Quote:From what I can determine from the code you pasted, the std::string implementation hasn't changed in any way that should stop it from working. I didn't really think it would either since, others are successfully using it with MSVC7.1. I compile cleanly in MSVC 7.1 myself with the supplied solutions. That means its almost definetely a configuration issue, as I haven't changed anything (copy and pasted really). I even use the std string, not my custom version. Since the solution I had from an older version worked though, I am just going to stick with that and hope I don't run into this problem again (sweep it under the carpet if you will). Thanks again for all the help guys.
  9. Completely Lost

    Thanks WitchLord, your fast responses is also one of the reason I love AngelScript. This clarifies things alot for me though. I'll let you know how it goes.
  10. Registerring Strings

    Sorry, the captial "String" declaration was a left over from a copy and paste job. I compile your supplied projects cleanly, so I am assuming that it is a compiler configuration error. The only thing I can think of thats funny though, is probably the use of precompiled headers. The string class I use is actually something completely different (like aCString). I just typedef String because I prefer typing that. I don't think it should be causing the compilation issue. I supplied it below for reference if you like though. // string standard header #pragma once #ifndef _STRING_ #define _STRING_ #include <istream> #pragma pack(push,8) #pragma warning(push,3) #pragma warning(disable: 4189) _STD_BEGIN // basic_string TEMPLATE OPERATORS template<class _Elem, class _Traits, class _Alloc> inline basic_string<_Elem, _Traits, _Alloc> __cdecl operator+( const basic_string<_Elem, _Traits, _Alloc>& _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // return string + string return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right); } template<class _Elem, class _Traits, class _Alloc> inline basic_string<_Elem, _Traits, _Alloc> __cdecl operator+( const _Elem *_Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // return NTCS + string return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right); } template<class _Elem, class _Traits, class _Alloc> inline basic_string<_Elem, _Traits, _Alloc> __cdecl operator+( const _Elem _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // return character + string return (basic_string<_Elem, _Traits, _Alloc>(1, _Left) += _Right); } template<class _Elem, class _Traits, class _Alloc> inline basic_string<_Elem, _Traits, _Alloc> __cdecl operator+( const basic_string<_Elem, _Traits, _Alloc>& _Left, const _Elem *_Right) { // return string + NTCS return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right); } template<class _Elem, class _Traits, class _Alloc> inline basic_string<_Elem, _Traits, _Alloc> __cdecl operator+( const basic_string<_Elem, _Traits, _Alloc>& _Left, const _Elem _Right) { // return string + character return (basic_string<_Elem, _Traits, _Alloc>(_Left) += _Right); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator==( const basic_string<_Elem, _Traits, _Alloc>& _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test for string equality return (_Left.compare(_Right) == 0); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator==( const _Elem * _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test for NTCS vs. string equality return (_Right.compare(_Left) == 0); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator==( const basic_string<_Elem, _Traits, _Alloc>& _Left, const _Elem *_Right) { // test for string vs. NTCS equality return (_Left.compare(_Right) == 0); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator!=( const basic_string<_Elem, _Traits, _Alloc>& _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test for string inequality return (!(_Left == _Right)); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator!=( const _Elem *_Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test for NTCS vs. string inequality return (!(_Left == _Right)); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator!=( const basic_string<_Elem, _Traits, _Alloc>& _Left, const _Elem *_Right) { // test for string vs. NTCS inequality return (!(_Left == _Right)); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator<( const basic_string<_Elem, _Traits, _Alloc>& _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test if string < string return (_Left.compare(_Right) < 0); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator<( const _Elem * _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test if NTCS < string return (_Right.compare(_Left) > 0); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator<( const basic_string<_Elem, _Traits, _Alloc>& _Left, const _Elem *_Right) { // test if string < NTCS return (_Left.compare(_Right) < 0); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator>( const basic_string<_Elem, _Traits, _Alloc>& _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test if string > string return (_Right < _Left); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator>( const _Elem * _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test if NTCS > string return (_Right < _Left); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator>( const basic_string<_Elem, _Traits, _Alloc>& _Left, const _Elem *_Right) { // test if string > NTCS return (_Right < _Left); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator<=( const basic_string<_Elem, _Traits, _Alloc>& _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test if string <= string return (!(_Right < _Left)); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator<=( const _Elem * _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test if NTCS <= string return (!(_Right < _Left)); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator<=( const basic_string<_Elem, _Traits, _Alloc>& _Left, const _Elem *_Right) { // test if string <= NTCS return (!(_Right < _Left)); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator>=( const basic_string<_Elem, _Traits, _Alloc>& _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test if string >= string return (!(_Left < _Right)); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator>=( const _Elem * _Left, const basic_string<_Elem, _Traits, _Alloc>& _Right) { // test if NTCS >= string return (!(_Left < _Right)); } template<class _Elem, class _Traits, class _Alloc> inline bool __cdecl operator>=( const basic_string<_Elem, _Traits, _Alloc>& _Left, const _Elem *_Right) { // test if string >= NTCS return (!(_Left < _Right)); } #ifdef _DLL_CPPLIB template class _CRTIMP2 basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+( const basic_string<char, char_traits<char>, allocator<char> >&, const basic_string<char, char_traits<char>, allocator<char> >&); template class _CRTIMP2 basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+( const char *, const basic_string<char, char_traits<char>, allocator<char> >&); template class _CRTIMP2 basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+( const char, const basic_string<char, char_traits<char>, allocator<char> >&); template class _CRTIMP2 basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+( const basic_string<char, char_traits<char>, allocator<char> >&, const char *); template class _CRTIMP2 basic_string<char, char_traits<char>, allocator<char> > __cdecl operator+( const basic_string<char, char_traits<char>, allocator<char> >&, const char); template _CRTIMP2 bool __cdecl operator==( const basic_string<char, char_traits<char>, allocator<char> >&, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator==( const char *, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator==( const basic_string<char, char_traits<char>, allocator<char> >&, const char *); template _CRTIMP2 bool __cdecl operator!=( const basic_string<char, char_traits<char>, allocator<char> >&, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator!=( const char *, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator!=( const basic_string<char, char_traits<char>, allocator<char> >&, const char *); template _CRTIMP2 bool __cdecl operator<( const basic_string<char, char_traits<char>, allocator<char> >&, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator<( const char *, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator<( const basic_string<char, char_traits<char>, allocator<char> >&, const char *); template _CRTIMP2 bool __cdecl operator>( const basic_string<char, char_traits<char>, allocator<char> >&, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator>( const char *, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator>( const basic_string<char, char_traits<char>, allocator<char> >&, const char *); template _CRTIMP2 bool __cdecl operator<=( const basic_string<char, char_traits<char>, allocator<char> >&, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator<=( const char *, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator<=( const basic_string<char, char_traits<char>, allocator<char> >&, const char *); template _CRTIMP2 bool __cdecl operator>=( const basic_string<char, char_traits<char>, allocator<char> >&, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator>=( const char *, const basic_string<char, char_traits<char>, allocator<char> >&); template _CRTIMP2 bool __cdecl operator>=( const basic_string<char, char_traits<char>, allocator<char> >&, const char *); template class _CRTIMP2 basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template class _CRTIMP2 basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+( const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template class _CRTIMP2 basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+( const wchar_t, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template class _CRTIMP2 basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *); template class _CRTIMP2 basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > __cdecl operator+( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t); template _CRTIMP2 bool __cdecl operator==( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator==( const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator==( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *); template _CRTIMP2 bool __cdecl operator!=( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator!=( const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator!=( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *); template _CRTIMP2 bool __cdecl operator<( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator<( const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator<( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *); template _CRTIMP2 bool __cdecl operator>( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator>( const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator>( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *); template _CRTIMP2 bool __cdecl operator<=( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator<=( const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator<=( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *); template _CRTIMP2 bool __cdecl operator>=( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator>=( const wchar_t *, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template _CRTIMP2 bool __cdecl operator>=( const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t *); #endif /* _DLL_CPPLIB */ // basic_string INSERTERS AND EXTRACTORS template<class _Elem, class _Traits, class _Alloc> inline basic_istream<_Elem, _Traits>& __cdecl operator>>( basic_istream<_Elem, _Traits>& _Istr, basic_string<_Elem, _Traits, _Alloc>& _Str) { // extract a string typedef ctype<_Elem> _Ctype; typedef basic_istream<_Elem, _Traits> _Myis; typedef basic_string<_Elem, _Traits, _Alloc> _Mystr; typedef typename _Mystr::size_type _Mysizt; ios_base::iostate _State = ios_base::goodbit; bool _Changed = false; const typename _Myis::sentry _Ok(_Istr); if (_Ok) { // state okay, extract characters const _Ctype& _Ctype_fac = _USE(_Istr.getloc(), _Ctype); _Str.erase(); _TRY_IO_BEGIN _Mysizt _Size = 0 < _Istr.width() && (_Mysizt)_Istr.width() < _Str.max_size() ? (_Mysizt)_Istr.width() : _Str.max_size(); typename _Traits::int_type _Meta = _Istr.rdbuf()->sgetc(); for (; 0 < _Size; --_Size, _Meta = _Istr.rdbuf()->snextc()) if(_Traits::eq_int_type(_Traits::eof(), _Meta)) { // end of file, quit _State |= ios_base::eofbit; break; } else if (_Ctype_fac.is(_Ctype::space, _Traits::to_char_type(_Meta))) break; // whitespace, quit else { // add character to string _Str.append(1, _Traits::to_char_type(_Meta)); _Changed = true; } _CATCH_IO_(_Istr) } _Istr.width(0); if (!_Changed) _State |= ios_base::failbit; _Istr.setstate(_State); return (_Istr); } template<class _Elem, class _Traits, class _Alloc> inline basic_istream<_Elem, _Traits>& __cdecl getline( basic_istream<_Elem, _Traits>& _Istr, basic_string<_Elem, _Traits, _Alloc>& _Str, const _Elem _Delim) { // get characters into string, discard delimiter typedef basic_istream<_Elem, _Traits> _Myis; ios_base::iostate _State = ios_base::goodbit; bool _Changed = false; const typename _Myis::sentry _Ok(_Istr, true); if (_Ok) { // state okay, extract characters _TRY_IO_BEGIN _Str.erase(); const typename _Traits::int_type _Metadelim = _Traits::to_int_type(_Delim); typename _Traits::int_type _Meta = _Istr.rdbuf()->sgetc(); for (; ; _Meta = _Istr.rdbuf()->snextc()) if (_Traits::eq_int_type(_Traits::eof(), _Meta)) { // end of file, quit _State |= ios_base::eofbit; break; } else if (_Traits::eq_int_type(_Meta, _Metadelim)) { // got a delimiter, discard it and quit _Changed = true; _Istr.rdbuf()->sbumpc(); break; } else if (_Str.max_size() <= _Str.size()) { // string too large, quit _State |= ios_base::failbit; break; } else { // got a character, add it to string _Str += _Traits::to_char_type(_Meta); _Changed = true; } _CATCH_IO_(_Istr) } if (!_Changed) _State |= ios_base::failbit; _Istr.setstate(_State); return (_Istr); } template<class _Elem, class _Traits, class _Alloc> inline basic_istream<_Elem, _Traits>& __cdecl getline( basic_istream<_Elem, _Traits>& _Istr, basic_string<_Elem, _Traits, _Alloc>& _Str) { // get characters into string, discard newline return (getline(_Istr, _Str, _Istr.widen('\n'))); } template<class _Elem, class _Traits, class _Alloc> inline basic_ostream<_Elem, _Traits>& __cdecl operator<<( basic_ostream<_Elem, _Traits>& _Ostr, const basic_string<_Elem, _Traits, _Alloc>& _Str) { // insert a string typedef basic_ostream<_Elem, _Traits> _Myos; typedef basic_string<_Elem, _Traits, _Alloc> _Mystr; typedef typename _Mystr::size_type _Mysizt; ios_base::iostate _State = ios_base::goodbit; _Mysizt _Size = _Str.size(); _Mysizt _Pad = _Ostr.width() <= 0 || (_Mysizt)_Ostr.width() <= _Size ? 0 : (_Mysizt)_Ostr.width() - _Size; const typename _Myos::sentry _Ok(_Ostr); if (!_Ok) _State |= ios_base::badbit; else { // state okay, insert characters _TRY_IO_BEGIN if ((_Ostr.flags() & ios_base::adjustfield) != ios_base::left) for (; 0 < _Pad; --_Pad) // pad on left if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { // insertion failed, quit _State |= ios_base::badbit; break; } if (_State == ios_base::goodbit) for (_Mysizt _Count = 0; _Count < _Size; ++_Count) if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Str[_Count]))) { // insertion failed, quit _State |= ios_base::badbit; break; } if (_State == ios_base::goodbit) for (; 0 < _Pad; --_Pad) // pad on right if (_Traits::eq_int_type(_Traits::eof(), _Ostr.rdbuf()->sputc(_Ostr.fill()))) { // insertion failed, quit _State |= ios_base::badbit; break; } _Ostr.width(0); _CATCH_IO_(_Ostr) } _Ostr.setstate(_State); return (_Ostr); } #ifdef _DLL_CPPLIB template class _CRTIMP2 basic_istream<char, char_traits<char> >& __cdecl operator>>( basic_istream<char, char_traits<char> >&, basic_string<char, char_traits<char>, allocator<char> >&); template class _CRTIMP2 basic_istream<char, char_traits<char> >& __cdecl getline( basic_istream<char, char_traits<char> >&, basic_string<char, char_traits<char>, allocator<char> >&); template class _CRTIMP2 basic_istream<char, char_traits<char> >& __cdecl getline( basic_istream<char, char_traits<char> >&, basic_string<char, char_traits<char>, allocator<char> >&, const char); template class _CRTIMP2 basic_ostream<char, char_traits<char> >& __cdecl operator<<( basic_ostream<char, char_traits<char> >&, const basic_string<char, char_traits<char>, allocator<char> >&); template class _CRTIMP2 basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl operator>>( basic_istream<wchar_t, char_traits<wchar_t> >&, basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template class _CRTIMP2 basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl getline( basic_istream<wchar_t, char_traits<wchar_t> >&, basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); template class _CRTIMP2 basic_istream<wchar_t, char_traits<wchar_t> >& __cdecl getline( basic_istream<wchar_t, char_traits<wchar_t> >&, basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&, const wchar_t); template class _CRTIMP2 basic_ostream<wchar_t, char_traits<wchar_t> >& __cdecl operator<<( basic_ostream<wchar_t, char_traits<wchar_t> >&, const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >&); #endif /* _DLL_CPPLIB */ _STD_END #pragma warning(default: 4189) #pragma warning(pop) #pragma pack(pop) #endif /* _STRING */ /* * Copyright (c) 1992-2002 by P.J. Plauger. ALL RIGHTS RESERVED. * Consult your license regarding permissions and restrictions. V3.13:0009 */
  11. Completely Lost

    I have tried to upgrade to the 2.0 version a couple of times, but each time something breaks and I put off messing with it for a while. Can someone please show me how to do something really simple? Below is a unit test, I converted to describe my problem. I have a class VertexBuffer which is defined by code. I want to have a script function which takes in this class as a pointer (reference, or whatever else there is), so that I can call functions on the class. Now from the code, I want to call the script defined function with the c++ VeretxBuffer pointer. How should I go about doing this? #include "utils.h" namespace TestImport { #define TESTNAME "TestClassPointer" //! Really simple VertexBuffer class for testing class VertexBuffer { public: //! Doesn't really do anything, just here so we can call it from a script virtual void Vertex3f( float x, float y, float z) { float xlocal = x; /* Just make sure we reached here */ } }; //! Really simple script to test the vertex buffer loading static const char *script1 = "void VertexBufferCreate( VertexBuffer *vb ) \n" "{ \n" " vb->Vertex3f(1,2,3); \n" "} \n"; bool Test() { bool fail = false; int number = 0; int r; asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); r = engine->RegisterObjectType("VertexBuffer", 0, asOBJ_CLASS); assert( r >= 0 ); r = engine->RegisterObjectMethod("VertexBuffer", "void Vertex3f( float x, float y, float z)", asMETHOD(VertexBuffer, Vertex3f), asCALL_THISCALL); assert( r >= 0 ); //! Is there a way to register a global vertex buffer object static VertexBuffer *vb = NULL; /* How would I register VB with the script so that it is accessed as a global property? */ COutStream out; engine->AddScriptSection(0, TESTNAME ":1", script1, strlen(script1), 0); engine->Build(0, &out); /* How do I call VertexBufferCreate in the script and pass vb as an argument to it? */ engine->ExecuteString(0, "VertexBufferCreate( NULL )", &out); engine->Release(); if( number != 1 ) { fail = true; } // Success return fail; } } // namespace I really love angelscript, but even since the introduction of @, in, out, etc.. I have been really lost. I just want to get back on track so any help would be appreciated.
  12. Registerring Strings

    This seems to work, so I am using it for now. static bool StringEqual(const String& s1, const String& s2) { return operator==(s1, s2); } static bool StringNotEqual(const String& s1, const String& s2) { return operator!=(s1, s2); } static bool StringLeEqual(const String& s1, const String& s2) { return operator<=(s1, s2); } static bool StringGeEqual(const String& s1, const String& s2) { return operator>=(s1, s2); } static bool StringLessThan(const String& s1, const String& s2) { return operator<(s1, s2); } static bool StringGreaterThan(const String& s1, const String& s2) { return operator>(s1, s2); } // Register the global operator overloads // Note: We can use std::string's methods directly because the // internal std::string is placed at the beginning of the class r = engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(StringEqual, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(StringNotEqual, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_LEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(StringLeEqual, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_GEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(StringGeEqual, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN, "bool f(const string &in, const string &in)", asFUNCTIONPR(StringLessThan, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, "bool f(const string &in, const string &in)", asFUNCTIONPR(StringGreaterThan, (const string&, const string&), bool), asCALL_CDECL); assert( r >= 0 );
  13. Registerring Strings

    I am trying to test out the new release, but run into trouble registerring variables. It appears to be the following lines. When I run the included projects using msvc 7.1 (2003) it compiles cleanly. When I compile from my project, I get the following error for the lines stated below : error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'bool (__cdecl *)(const std::string &,const std::string &)' None of the functions with this name in scope match the target type This happens if I use the AC string or the std string (since they both use the same piece of code here). Anybody have a clue whats going on? r = engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator==, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator!=, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_LEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator<=, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_GEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator>=, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator <, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator >, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 );
  14. Is asIScriptGeneric::Prepare necessary?

    Since we are on the topic...which do you recommend. When doing operations on a WxH array block of pixels with a function DoSomething(float r, float g, float b, float g), do you suggest calling Prepare and executing the function for every pixel or creating a for loop in the script to call the function for every pixel? The Prepare takes time to set up, but does calling the function from the script take more,less or the same time to execute? I don't really have anything solid I use AS for yet, just toying around with it in a couple of areas.
  15. Resetting the script

    Just curious, but wasn't there some work done to save the state of a script? Couldn't he save the start state, then restore it later?