Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 Mar 2012
Offline Last Active Yesterday, 12:35 PM

Topics I've Started

About using old objects after recompiling scripts

21 July 2015 - 08:44 AM

Hi Andreas. I have a small question regarding the usage of script objects...let me explain my situation so you can better understand what´s going on here:


I have 3 threads. One thread (let´s call it "main") can recompile the script upon user request. The other 2 threads (let´s call them "workers") create script objects and call their methods regularly. Both workers work at their own rate and can call objects´ methods a couple of times per second or several thousand times per second. Workers will be notified when the script has been recompiled by the main thread, and they will destroy the old objects (by calling their Release() method) and create new objects based on the new version of the script. The problem is that a recompilation can occur at any time and the workers may continue to use the old objects for some time before they have the opportunity to update them.


Now, as far as I´ve been able to test, having objects created with an old version of the script (even if the script has been recompiled) causes no problem at all. I´ve even had objects created with 3 different versions of the script, all living together, even if the older objects call global functions that no longer exist in the current compiled version of the script.


Is it ok to do it this way? Does Angelscript include some magic to make all of this work, or I have just been lucky, using some kind of ghost code that might eventually get cleaned up and cause my code to finally crash?


ps: I don´t care much about serializing my objects right now.

Angelscript on Raspberry Pi

09 November 2012 - 07:31 PM

Hi. I´ve been trying to build Angelscript on a Raspberry Pi computer (ARM processor). I made some modifications to the makefile and I´ve got mixed results.

First, after the

else ifeq($(TARGERPLATFORM), android)
	OBJ += $(OBJDIR)/as_callfunc_arm_gcc.o

I added:

	OBJ += $(OBJDIR)/as_callfunc_arm_gcc.o

Since the RPi is ARM based, and since I´m using gcc, this looked like the right thing to do.
I also had to add -DAS_NO_THREADS to avoid getting some "unreferences".

The Tutorial and Game examples build fine with this setup, but in the tutorial project I´ve found some problems. When running it, the program outputs this:

Received: 1000, 1000
System has been running for 1000 seconds.
The script function returned: 8.53973

So as you can see, the received values are wrong. (Interestingly enough, the value returned at the end is correct).

I have the same problem with an application I made. Everything seems to be working fine as long as I use ints or string within my scripts, but as soon as I use floats or doubles the values get corrupted. (I haven´t tested the game project enough, BTW).

If I build the library with -DAS_MAX_PORTABILITY then the tutorial project build ok and works as expected:

Received: 3.14159, 2.71828
System has been running for 3.89004e+06 seconds.
The script function returned: 8.53973

Any ideas on what could be the problem or what to look for in order to find a solution?


Segmentation fault - void asCScriptEngine::CallObjectMethod(...)

30 May 2012 - 12:20 PM

Hi, I'm getting a segmentation fault here:

void asCScriptEngine::CallObjectMethod(...)
.....f(obj, param);			  // <- line 3373 - causes segmentation fault

"f" comes out with some weird value.

This function is being called by the asCScriptEngine::WriteMessage(...). I'm registering my callback function like this:
void scriptInterface::setMessageCallback(asIScriptEngine* compiler)
compiler->SetMessageCallback( asMETHOD(scriptInterface,MessageCallback),this,asCALL_THISCALL );

virtual void scriptInterface::MessageCallback(const asSMessageInfo *msg)
// Implement a simple message callback function
const char *type = "ERR ";
if( msg->type == asMSGTYPE_WARNING )
type = "WARN";
else if( msg->type == asMSGTYPE_INFORMATION )
type = "INFO";

printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message);

I have the feeling that the problem is here (file angelscript.h line 1024)

// Template specialization
template <>
struct asSMethodPtr<SINGLE_PTR_SIZE>
template<class M>
static asSFuncPtr Convert(M Mthd)
  asSFuncPtr p;
  asMemClear(&p, sizeof(p));
  asMemCopy(&p, &Mthd, SINGLE_PTR_SIZE); //<- after this, "f" (inside "p") gets wrong value
  // Mark this as a class method
  p.flag = 3;
  return p;

To make things even weirder, everything works as expected under Windows XP. I'm getting this error under Linux (Ubuntu) - using Code::Blocks as IDE.

Any ideas?


What to use if I wan to send a negative value to a script function?

29 May 2012 - 09:24 AM

What the title says.... The manual mentions:

int SetArgDWord(int arg, asDWORD value);
int SetArgQWord(int arg, asQWORD value);
int SetArgFloat(int arg, float value);
int SetArgDouble(int arg, double value);
int SetArgByte(int arg, asBYTE value);
int SetArgWord(int arg, asWORD value);

But all values are of unsigned type! How can I send a "-1" to my script?



Performance: global functions vs. object methods.

08 May 2012 - 02:40 PM

Hi. Is there any overhead when calling C++ member functions, compared to calling C++ global functions (from a script)?