🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Unknown error
Hello Andreas.
I bring below a code which works incorrectly. I use the version 2.4.1a.
In the text of a code, comments which specify a place of a mistake are resulted.
Inform, what I doing not so or was a mistake in a code of your library?
//This line not working
ret=Get(0)+(Get(1)*2.0f);
//but this line, correct working
ret=(Get(1)*2.0f)+Get(0);
Error in this function:
float __cdecl OpPlusRF(cFloat *self, float other)
self == NULL
//////////////////
// start my code
#define AS_DEPRECATED
#include "angelscript.h"
#include <iostream>
using namespace std;
struct cFloat
{
float m_Float;
cFloat()
{
m_Float = 0.0f;
}
cFloat(float Float)
{
m_Float = Float;
}
float operator = (float f);
operator float()
{
return m_Float;
}
float operator += (cFloat v );
float operator += (float v );
float operator -= (cFloat v );
float operator -= (float v );
float operator /= (cFloat v );
float operator /= (float v );
float operator *= (cFloat v );
float operator *= (float v );
};
float cFloat::operator = (float f)
{
float old = m_Float;
m_Float = f;
return m_Float;
}
float cFloat::operator += (cFloat v )
{
float old = m_Float;
m_Float += v;
return m_Float;
}
float cFloat::operator += (float v )
{
float old = m_Float;
m_Float += v;
return m_Float;
}
float cFloat::operator -= (cFloat v )
{
float old = m_Float;
m_Float -= v;
return m_Float;
}
float cFloat::operator -= (float v )
{
float old = m_Float;
m_Float -= v;
return m_Float;
}
float cFloat::operator /= (cFloat v )
{
float old = m_Float;
m_Float /= v;
return m_Float;
}
float cFloat::operator /= (float v )
{
float old = m_Float;
m_Float /= v;
return m_Float;
}
float cFloat::operator *= (cFloat v )
{
float old = m_Float;
m_Float *= v;
return m_Float;
}
float cFloat::operator *= (float v )
{
float old = m_Float;
m_Float *= v;
return m_Float;
}
float __cdecl AssignFloat2Float(float a,cFloat &b)
{
b=a;
return b;
}
float __cdecl OpPlusRR(cFloat *self, cFloat* other)
{
return (float)(*self)+(float)(*other);
}
float __cdecl OpPlusRF(cFloat *self, float other)
{
//////////////////////////////////Error in this call!
//// Get(0) + (Get(1)*2.0f)
//// ^
//// Is null, Why?
if(!self)
{
cout<<"Error!!!???"<<endl;
return 0;
//throw 1;
}
return (float)(*self)+(float)(other);
}
float __cdecl OpPlusFR(float self, cFloat* other)
{
return (self)+(float)(*other);
}
float __cdecl OpMulRR(cFloat *self, cFloat* other)
{
return (float)(*self)*(float)(*other);
}
float __cdecl OpMulRF(cFloat *self, float other)
{
return (float)(*self)*(float)(other);
}
float __cdecl OpMulFR(float self, cFloat* other)
{
return (float)(self)*(float)(*other);
}
bool Register(asIScriptEngine* pSE)
{
pSE->RegisterObjectType("Float", sizeof(cFloat), asOBJ_CLASS);
if(pSE->RegisterObjectBehaviour("Float",asBEHAVE_ASSIGNMENT,"Float& f(float
)",asFUNCTION(AssignFloat2Float),asCALL_CDECL_OBJLAST))
return false;
// asBEHAVE_ADD
if(pSE->RegisterGlobalBehaviour(asBEHAVE_ADD,"float f(Float
∈ ,Float ∈)",asFUNCTION(OpPlusRR), asCALL_CDECL))
return false;
if(pSE->RegisterGlobalBehaviour(asBEHAVE_ADD,"float f(Float
∈ ,float)",asFUNCTION(OpPlusRF), asCALL_CDECL))
return false;
if(pSE->RegisterGlobalBehaviour(asBEHAVE_ADD,"float f(float
,Float ∈)",asFUNCTION(OpPlusFR), asCALL_CDECL))
return false;
// asBEHAVE_MULTIPLY
if(pSE->RegisterGlobalBehaviour(asBEHAVE_MULTIPLY, "float
f(Float ∈ ,Float ∈)",asFUNCTION(OpMulRR), asCALL_CDECL))
return false;
if(pSE->RegisterGlobalBehaviour(asBEHAVE_MULTIPLY, "float
f(Float ∈ ,float)",asFUNCTION(OpMulRF), asCALL_CDECL))
return false;
if(pSE->RegisterGlobalBehaviour(asBEHAVE_MULTIPLY, "float
f(float ,Float ∈)",asFUNCTION(OpMulFR), asCALL_CDECL))
return false;
return true;
}
cFloat& Get(int index)
{
static cFloat m_arr[10];
return m_arr[index];
}
void Print(float f)
{
cout<<f<<endl;
}
void main()
{
asIScriptEngine* pSE;
pSE=asCreateScriptEngine(ANGELSCRIPT_VERSION);
Register(pSE);
pSE->RegisterGlobalFunction("Float&
Get(int32)",asFUNCTION(Get),asCALL_CDECL);
pSE->RegisterGlobalFunction("void
Print(float)",asFUNCTION(Print),asCALL_CDECL);
const char script[]=" float ret=10;\n Get(0)=10.0f;\n Get(1)=10.0f;\n Get(2)=10.0f;\n
ret=Get(0)+(Get(1)*2.0f);\n Print(ret);\n \n";
cout<<script<<endl;
pSE->ExecuteString("",script);
}
// end my code
//////////////////
I received your e-mail about this as well. But to save time I'll only answer here :)
I'll investigate this as soon as I can. Though at first glance this seems to be similar to the bug that Dentoid reported and that I believed I corrected in the 2.4.1a release. Maybe you stumbled on a minor variation of that bug that was not corrected? I'll be back with more information soon (hopefully within the next couple of days).
Regards,
Andreas
I'll investigate this as soon as I can. Though at first glance this seems to be similar to the bug that Dentoid reported and that I believed I corrected in the 2.4.1a release. Maybe you stumbled on a minor variation of that bug that was not corrected? I'll be back with more information soon (hopefully within the next couple of days).
Regards,
Andreas
Excuse, that the mistake rather critical was necessary to duplicate to you on e-mail and in a forum, but.
I have specified, that I use last version of your library (2.4.1a). What sort the detailed information is necessary for you?
In a file sent on your address there is a code in which the mistake of a script is available, you can check up it having started it at yourselves. As it can be corrected or when to expect correction from you.
I have specified, that I use last version of your library (2.4.1a). What sort the detailed information is necessary for you?
In a file sent on your address there is a code in which the mistake of a script is available, you can check up it having started it at yourselves. As it can be corrected or when to expect correction from you.
Quote: Original post by WitchLord
I received your e-mail about this as well. But to save time I'll only answer here :)
I'll investigate this as soon as I can. Though at first glance this seems to be similar to the bug that Dentoid reported and that I believed I corrected in the 2.4.1a release. Maybe you stumbled on a minor variation of that bug that was not corrected? I'll be back with more information soon (hopefully within the next couple of days).
Regards,
Andreas
I believe you have given me all the information that I need to find the problem. I just need to find the time to actually do the investigation, i.e. debug the library with your example code and find out where it goes wrong.
I'm in a very busy schedule right now at work so I don't have the time to any testing on this project at this moment (AngelScript is non-work related). I hope I will be able to find the time to do so within the next couple of days, but I can't promise anything.
Until I can provide the definite solution for this problem I hope you can keep your own project going using the work-around that you yourself found.
I hope this doesn't cause too much inconvenience for you.
Regards,
Andreas
I'm in a very busy schedule right now at work so I don't have the time to any testing on this project at this moment (AngelScript is non-work related). I hope I will be able to find the time to do so within the next couple of days, but I can't promise anything.
Until I can provide the definite solution for this problem I hope you can keep your own project going using the work-around that you yourself found.
I hope this doesn't cause too much inconvenience for you.
Regards,
Andreas
I managed to do some tests in between the meetings and all the work that needs to be done, and I discovered the cause of this problem. I've sent the changes to __Avatar__ by e-mail, but the official release of the fixes should be out soon as well.
Hello Andreas
Thank big, that have found time for corrections of my mistake. So quickly and qualitatively, simply there are no words.
Thank big, that have found time for corrections of my mistake. So quickly and qualitatively, simply there are no words.
Quote: Original post by WitchLord
I managed to do some tests in between the meetings and all the work that needs to be done, and I discovered the cause of this problem. I've sent the changes to __Avatar__ by e-mail, but the official release of the fixes should be out soon as well.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement