Jump to content

  • Log In with Google      Sign In   
  • Create Account

zerochen

Member Since 19 Jul 2012
Offline Last Active May 19 2014 02:39 PM

Posts I've Made

In Topic: AngelScript 2.27.1 is here (so soon? yes)

22 August 2013 - 10:52 AM

Hi,

 

This release of AngelScript is quite small as I wanted to get started on the next big update. ...

what are the next big features / addons / updates that you will add?


In Topic: constructor + templates => constructor isnt called

29 November 2012 - 11:08 AM

hi,

i finally found the problem. the problem was that i register the default constructor for the vector and the matrix with the same functionname in different source files.
so the defaullt constructor of the maxtrix overrides the vectors default constructor because they have the same structure & name.

thanks anyway

In Topic: constructor + templates => constructor isnt called

27 November 2012 - 07:46 AM

hi,

i use visual studio 2012, the lastest angelscript rev and win 7 64bit.

i also noticed that this only happens with the default constructor (no arguments are passed). for other methods and behaviours it works.

In Topic: Bind method with this for call as global function in AS

27 October 2012 - 11:41 AM

hi,

i wrote a patch for this some time ago

Index: include/angelscript.h
===================================================================
--- include/angelscript.h (Revision 1359)
+++ include/angelscript.h (Arbeitskopie)
@@ -520,6 +520,7 @@
  virtual asIJITCompiler *GetJITCompiler() const = 0;
  // Global functions
+ virtual int    RegisterGlobalFunction(const char* declaration, const asSFuncPtr &funcPointer, void* obj, asDWORD callConv) = 0;
  virtual int						   RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0;
  virtual asUINT						 GetGlobalFunctionCount() const = 0;
#ifdef AS_DEPRECATED
Index: source/as_callfunc.cpp
===================================================================
--- source/as_callfunc.cpp (Revision 1359)
+++ source/as_callfunc.cpp (Arbeitskopie)
@@ -409,12 +409,8 @@
  if( callConv >= ICC_THISCALL )
  {
-  if( objectPointer )
+  if(!((obj = objectPointer) || (obj = descr->GetUserData())))
   {
-   obj = objectPointer;
-  }
-  else
-  {
	    // The object pointer should be popped from the context stack
	    popSize += AS_PTR_SIZE;
Index: source/as_scriptengine.cpp
===================================================================
--- source/as_scriptengine.cpp (Revision 1359)
+++ source/as_scriptengine.cpp (Arbeitskopie)
@@ -2458,6 +2458,83 @@
}
// interface
+int asCScriptEngine::RegisterGlobalFunction(const char* declaration, const asSFuncPtr &funcPointer, void* obj, asDWORD callConv)
+{
+ asSSystemFunctionInterface internal;
+
+ int r = DetectCallingConvention(true, funcPointer, callConv, &internal);
+ if( r < 0 )
+  return ConfigError(r, "RegisterGlobalFunction", declaration, 0);
+
+ if( callConv != asCALL_THISCALL)
+  return ConfigError(asNOT_SUPPORTED, "RegisterGlobalFunction", declaration, 0);
+
+ isPrepared = false;
+
+ // Put the system function in the list of system functions
+ asSSystemFunctionInterface *newInterface = asNEW(asSSystemFunctionInterface)(internal);
+
+ if( newInterface == 0 )
+  return ConfigError(asOUT_OF_MEMORY, "RegisterGlobalFunction", declaration, 0);
+
+ asCScriptFunction *func = asNEW(asCScriptFunction)(this, 0, asFUNC_SYSTEM);
+
+ if( func == 0 )
+ {
+  asDELETE(newInterface, asSSystemFunctionInterface);
+  return ConfigError(asOUT_OF_MEMORY, "RegisterGlobalFunction", declaration, 0);
+ }
+
+ func->sysFuncIntf = newInterface;
+ func->SetUserData(obj);
+
+ asCBuilder bld(this, 0);
+ r = bld.ParseFunctionDeclaration(0, declaration, func, true, &newInterface->paramAutoHandles, &newInterface->returnAutoHandle, defaultNamespace);
+ if( r < 0 )
+ {
+  // Set as dummy function before deleting
+  func->funcType = asFUNC_DUMMY;
+  asDELETE(func,asCScriptFunction);
+  return ConfigError(asINVALID_DECLARATION, "RegisterGlobalFunction", declaration, 0);
+ }
+
+ // TODO: namespace: What if the declaration defined an explicit namespace?
+ func->nameSpace = defaultNamespace;
+
+ // Check name conflicts
+ r = bld.CheckNameConflict(func->name.AddressOf(), 0, 0, defaultNamespace);
+ if( r < 0 )
+ {
+  asDELETE(func,asCScriptFunction);
+  return ConfigError(asNAME_TAKEN, "RegisterGlobalFunction", declaration, 0);
+ }
+
+ func->id = GetNextScriptFunctionId();
+ SetScriptFunction(func);
+
+ currentGroup->scriptFunctions.PushLast(func);
+ func->accessMask = defaultAccessMask;
+ registeredGlobalFuncs.PushLast(func);
+
+ // If parameter type from other groups are used, add references
+ if( func->returnType.GetObjectType() )
+ {
+  asCConfigGroup *group = FindConfigGroupForObjectType(func->returnType.GetObjectType());
+  currentGroup->RefConfigGroup(group);
+ }
+ for( asUINT n = 0; n < func->parameterTypes.GetLength(); n++ )
+ {
+  if( func->parameterTypes[n].GetObjectType() )
+  {
+   asCConfigGroup *group = FindConfigGroupForObjectType(func->parameterTypes[n].GetObjectType());
+   currentGroup->RefConfigGroup(group);
+  }
+ }
+
+ // Return the function id as success
+ return func->id;
+}
+
int asCScriptEngine::RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv)
{
  asSSystemFunctionInterface internal;
Index: source/as_scriptengine.h
===================================================================
--- source/as_scriptengine.h (Revision 1359)
+++ source/as_scriptengine.h (Arbeitskopie)
@@ -100,6 +100,7 @@
		 virtual asIJITCompiler *GetJITCompiler() const;
  // Global functions
+ virtual int	  RegisterGlobalFunction(const char* declaration, const asSFuncPtr &funcPointer, void* obj, asDWORD callConv);
  virtual int						   RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv);
  virtual asUINT						 GetGlobalFunctionCount() const;
#ifdef AS_DEPRECATED


example usage:
engine->RegisterGlobalFunction("void Println(const string& in)", asMETHODPR(CScriptFunction, println, (const std::string&), void), this /*pointer to obj of CScriptFunction*/, asCALL_THISCALL);

In Topic: ref count fails

18 October 2012 - 03:15 AM

ok thx that solved the problem. i thought it was because the createScriptObject func returns sometimes an obj with ref count 2

PARTNERS