Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Mar 2008
Offline Last Active Apr 13 2015 02:44 AM

Topics I've Started

Script object reference in C++

19 September 2013 - 07:09 AM



I'm writing a debugger for my project using AngelScript 2.27.1. I've registered a callback and able to extract the variables. I have a nice display showing the variables. For references I'd like to write if it is null or not.

for ( int varIx = 0; varIx < context->GetVarCount( level ); varIx++ )
  watch->Show( context->GetVarName( varIx, level )
             , context->GetVarTypeId( varIx, level )
             , context->GetAddressOfVar( varIx, level ) );

This way I enumerate the variables. In Show, I get the object type:

asIObjectType* objType = ScriptEngine::Instance().GetAsEngine()->GetObjectTypeById( typeId );

And then I have a TODO now smile.png

if ( objType->GetFlags() & asOBJ_REF )
  const asIScriptObject* object = (const asIScriptObject*)address;
  bool isValidRef = true; // TODO
  item->setText( 2, isValidRef ? "valid ref" : "null ref" );

I can cast the address of the property to an asIScriptObject, but I can't still determine if it is null reference or not. I've checked if the address pointer is maybe null, but it is not null even for null ref objects.


Is there a way to check if it is a null ref or not?


Thank you.

Native vs Generic calling conventions performance?

02 September 2012 - 03:50 AM

Just wondering if anyone has some measurements about the difference between using native or generic calling conventions on different platforms?
I'm in the phase of porting my engine to as many platforms as I can. Some of them like the Android MIPS or the Windows Runtime ARM are working only with generic (the code itself can be compiled on any platforms to use generic) and I'm really curious if the difference is significant or not so much, so I can use generic in the final code.

Autohandles with generic callconv

29 August 2012 - 04:57 AM

Since I use AS there is a bug in the generic calling convention when returning auto handles.

When a function returns an autohandle, the generic callconv doesn't increase it's reference counter and later it is going to cause crashes. I've managed to fix this by adding

[source lang="cpp"] if ( sysFunction->returnType.IsObject() && !sysFunction->returnType.IsReference() && sysFunction->returnType.IsObjectHandle() && sysFunc->returnAutoHandle && m_regs.objectRegister ) m_engine->CallObjectMethod( m_regs.objectRegister, sysFunction->returnType.GetObjectType()->beh.addref );[/source]

to the asCContext::CallGeneric function before "Clean up function parameters" (line 4382 in 2.24.1).

I'm using this for a long time now (copying it over upon AS upgrade), but not sure if this is the correct solution. It works though.

Running on Android with MIPS

23 August 2012 - 06:13 AM

My project works like a charm on Android now. With 2.24.0 it is now fully working on Android ARM. However my MIPS based tablet is not so lucky. If I just compile the project with MIPS abi and run, the application will not be able to register a thing, every call to registering application interface fails.

I noticed from as_config.h that AS_MIPS will only get detected with the snsystems compiler or PSP. I could add AS_MIPS manually but I'm not sure about the other configuration macros like CDECL_RETURN_SIMPLE_IN_MEMORY and stuff.

Is there any experience about setting AS up for Android on MIPS?

Memory leak

16 August 2012 - 03:20 AM

Just switched to as 2.24.0 and got a memory leak in the library.

In angelscript\source\as_builder.cpp(3438)

signature = asNEW(sExplicitSignature);

This allocation is later passed to RegisterScriptFunctionWithSignature, but if the virtual property is an interface, it is not going to be stored and therefore not going to be freed.