Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Dec 2011
Offline Last Active Feb 28 2016 02:02 AM

Topics I've Started

passing anonymous arrays from Angelscript to C

10 September 2015 - 03:35 AM

Hi There


I'm trying to pass arrays from angelscript to C - and having a few problems


The problems being it doesn't work at all - doesn't fill the vec array - and probably will eventually crash - I can't really tell what is going - because the C code is compiled at run time and my shabby system has no really debugging at the moment.


here's my C code:


typedef struct
int maxElements;
int numElements;
unsigned char  data[1];
}  SArrayBuffer;

typedef struct
int       refCount;
_Bool      gcFlag;
void*     objType;
SArrayBuffer*     buffer;
int       elementSize;
int       subTypeId;
} ASarray;

void Init(void)
Debug("TCC init called");
//asRegisterGlobalFunction("float TestFunk(float)",TestFunk);
//asRegisterGlobalFunction("vec3 vectest(vec3)",vectest);
//asRegisterGlobalFunction("vec3 vecpointer(const vec3 &in)",vecpointer);
asRegisterGlobalFunction("void vecfill(vec3[]@,int)",vecfill);

void vecfill(ASarray *a,int l)
vec3* v=(vec3*)a->buffer->data;

for (int a=0;a<l;a++)


here's my angelscript code

array<vec3> TestArray(50);


I am doing it this way because 1) I want to be able to pass arrays anonymously without having to define a specific class or struct

2) I'm using TCC so the C code is compile at runtime - it's actually called from angelscript:


I realise this is probably as dodgy as hell - but it's  not a commercial thing, pure R&D - so I just hope it is possible.




Help BCB 6.00

22 November 2013 - 10:03 AM

Hi All

I've got a problem with the Latest version of angelscript and borlands BCB 6.00 - I got it to compile (there were a few compile issues - but very easily fixed). It all worked fine - Building angelscript code exectuing e.t.c. - The problem happens when using the STDSTRING extension,

using strings in script works fine and it compiles and runs - the problem is that my EXE hangs when exiting back to windows - I've tried to track down the issue - but no joy yet - anybody got any similar issues?


I've tried the following scenarios:


Exe hangs when exiting back to window - even if my script code has no string usage
Exe is fine and exits back to windows properly


Exe hangs when exiting back to window - even if my script code has no string usage
I'm thinking it's some kind of STL Issue - but who knows?
here's the call stack from the hang
005599F2 _STL::__node_alloc<1, 0>::_M_deallocate
00532B94 _STL::__node_alloc<1, 0>::_M_deallocate
004ABC13 TForm2::~TForm2
004AD53B TForm2::~TForm2
00534D54 _STL::__node_alloc<1, 0>::_M_deallocate
0053409C _STL::__node_alloc<1, 0>::_M_deallocate
00533FFF _STL::__node_alloc<1, 0>::_M_deallocate
005196C3 __init_exit_proc
00519712 __cleanup
005189D4 _exit
005198E8 __startup

many thanks




p.s. anybody else trying to uses BCB 6.00 you have to change any of the macros that have a ; after them, bcb wont compile class with ; and no definitions.







and some of the object pointers have to be explicitly cast before the compile will swallow them (forget which ones - easy fix tho).

noob help with global class functions

04 May 2013 - 11:38 AM

Hi All


I've just discovered angelscript and totally love it - having used lua,squirrel e.t.c. it's just awesome - everything I've need in a script lang - typed fast and easy to convert to native code.


I've currently got a problem with my vec3 class - I'm using global functions instead of member functions so I can directly match GLSL - this is so I can easily convert code from native c++ to GLSL and to script if needed.


I'm trying to register a global func:



r = gScriptEngine->RegisterGlobalFunction("vec3 normalize( vec3 &v1)", asFUNCTION(normalize), asCALL_CDECL);
but I get error -10 and
"Failed in call to function 'RegisterGlobalFunction' with 'vec3 normalize( vec3 &v1)' (Code: -10)"
and I just can't figure out the issue, apologies in advance if it's silly problem - I've looked at all the various vector3 classes out there and search the net for answers - but no joy yet :(

Sequencing Code

07 December 2011 - 06:58 AM

HI I'm trying to come up with a way to sequence code easily and without using a million classes.

I want to be able to execute code x frames in the future for y frame duration - something like this:

if (HitSomething)
Seq(10,20,PlaySound,"CrashHit.wav"); // Call fun Playsound("CrashHit.wav") in 10 frames time for 20 frames
Seq(10,50,StarFlare,10,20,1.5,4); // Call func StarFlare(10,20,1.5,5) in 10 frames time for 50 frames

This is great because it can handle any function, and the code is localised. I can do this - but it's alot of work to get the Variadic stuff working across different platform - requires some hardcore asm to calc the Param stack Size and setup the epilog code e.t.c.

wondering if there are any neat tricks to get something similar.