[Scummvm-git-logs] scummvm master -> 426609e01db7c4ba359cc239a416b06ab29450dc

grisenti noreply at scummvm.org
Sun Oct 8 20:19:31 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
426609e01d HPL1: backport changes from newer AS library release


Commit: 426609e01db7c4ba359cc239a416b06ab29450dc
    https://github.com/scummvm/scummvm/commit/426609e01db7c4ba359cc239a416b06ab29450dc
Author: grisenti (emanuele at grisenti.net)
Date: 2023-10-08T22:19:10+02:00

Commit Message:
HPL1: backport changes from newer AS library release

allows for non-portable features to be disabled

Changed paths:
    engines/hpl1/engine/libraries/angelscript/angelscript.h
    engines/hpl1/engine/libraries/angelscript/sources/as_builder.cpp
    engines/hpl1/engine/libraries/angelscript/sources/as_outputbuffer.h
    engines/hpl1/engine/libraries/angelscript/sources/as_scriptengine.cpp
    engines/hpl1/engine/libraries/angelscript/sources/as_scriptfunction.cpp
    engines/hpl1/engine/libraries/angelscript/sources/as_scriptobject.cpp


diff --git a/engines/hpl1/engine/libraries/angelscript/angelscript.h b/engines/hpl1/engine/libraries/angelscript/angelscript.h
index 551269fb1fa..50b0268a3e4 100644
--- a/engines/hpl1/engine/libraries/angelscript/angelscript.h
+++ b/engines/hpl1/engine/libraries/angelscript/angelscript.h
@@ -482,7 +482,7 @@ T _implicit_cast(T val) {
 
 struct asSFuncPtr {
 	asSFuncPtr(asBYTE f) {
-		for (int n = 0; n < sizeof(ptr.dummy); n++)
+		for (size_t n = 0; n < sizeof(ptr.dummy); n++)
 			ptr.dummy[n] = 0;
 		flag = f;
 	}
diff --git a/engines/hpl1/engine/libraries/angelscript/sources/as_builder.cpp b/engines/hpl1/engine/libraries/angelscript/sources/as_builder.cpp
index 6b956c75a22..b5f92f4f41b 100644
--- a/engines/hpl1/engine/libraries/angelscript/sources/as_builder.cpp
+++ b/engines/hpl1/engine/libraries/angelscript/sources/as_builder.cpp
@@ -236,7 +236,7 @@ void asCBuilder::EvaluateTemplateInstances(asUINT startIdx, bool keepSilent) {
 	// Set the new temporary message stream
 	asCOutputBuffer outBuffer;
 	if (keepSilent)
-		engine->SetMessageCallback(asMETHOD(asCOutputBuffer, Callback), &outBuffer, asCALL_THISCALL);
+		engine->SetMessageCallback(asFUNCTION(asCOutputBuffer::CDeclCallback), &outBuffer, asCALL_CDECL_OBJLAST);
 
 	// Evaluate each of the template instances that have been created since the start of the build
 	// TODO: This is not exactly correct, since another thread may have created template instances in parallel
@@ -2238,7 +2238,7 @@ void asCBuilder::CompileGlobalVariables() {
 
 	// Set the new temporary message stream
 	asCOutputBuffer outBuffer;
-	engine->SetMessageCallback(asMETHOD(asCOutputBuffer, Callback), &outBuffer, asCALL_THISCALL);
+	engine->SetMessageCallback(asFUNCTION(asCOutputBuffer::CDeclCallback), &outBuffer, asCALL_CDECL_OBJLAST);
 
 	asCOutputBuffer finalOutput;
 	asCScriptFunction *initFunc = 0;
diff --git a/engines/hpl1/engine/libraries/angelscript/sources/as_outputbuffer.h b/engines/hpl1/engine/libraries/angelscript/sources/as_outputbuffer.h
index cef5db5b592..3dec58ff183 100644
--- a/engines/hpl1/engine/libraries/angelscript/sources/as_outputbuffer.h
+++ b/engines/hpl1/engine/libraries/angelscript/sources/as_outputbuffer.h
@@ -1,6 +1,6 @@
 /*
    AngelCode Scripting Library
-   Copyright (c) 2003-2012 Andreas Jonsson
+   Copyright (c) 2003-2023 Andreas Jonsson
 
    This software is provided 'as-is', without any express or implied
    warranty. In no event will the authors be held liable for any
@@ -57,6 +57,7 @@ public:
 	~asCOutputBuffer();
 	void Clear();
 	void Callback(asSMessageInfo *msg);
+   static void CDeclCallback(asSMessageInfo* msg, asCOutputBuffer* buf) { buf->Callback(msg); }
 	void Append(asCOutputBuffer &in);
 	void SendToCallback(asCScriptEngine *engine, asSSystemFunctionInterface *func, void *obj);
 
diff --git a/engines/hpl1/engine/libraries/angelscript/sources/as_scriptengine.cpp b/engines/hpl1/engine/libraries/angelscript/sources/as_scriptengine.cpp
index f3d3ed1e260..0887147b856 100644
--- a/engines/hpl1/engine/libraries/angelscript/sources/as_scriptengine.cpp
+++ b/engines/hpl1/engine/libraries/angelscript/sources/as_scriptengine.cpp
@@ -3737,18 +3737,20 @@ void asCScriptEngine::CallObjectMethod(void *obj, asSSystemFunctionInterface *i,
 		asCGeneric gen(const_cast<asCScriptEngine *>(this), s, obj, 0);
 		void (*f)(asIScriptGeneric *) = (void (*)(asIScriptGeneric *))(i->func);
 		f(&gen);
-	} else if (i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL) {
+	}
+#ifndef AS_NO_CLASS_METHODS
+	else if (i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL) {
 		// For virtual thiscalls we must call the method as a true class method
 		// so that the compiler will lookup the function address in the vftable
 		union {
 			asSIMPLEMETHOD_t mthd;
 			struct {
 				asFUNCTION_t func;
-				asPWORD baseOffset;  // Same size as the pointer
+				asPWORD baseOffset; // Same size as the pointer
 			} f;
 		} p;
 
-		obj = (void *)((char *) obj +  i->compositeOffset);
+		obj = (void *)((char *)obj + i->compositeOffset);
 		if (i->isCompositeIndirect)
 			obj = *((void **)obj);
 
@@ -3756,7 +3758,9 @@ void asCScriptEngine::CallObjectMethod(void *obj, asSSystemFunctionInterface *i,
 		p.f.baseOffset = asPWORD(i->baseOffset);
 		void (asCSimpleDummy::*f)() = p.mthd;
 		(((asCSimpleDummy *)obj)->*f)();
-	} else { /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
+	}
+#endif
+	else { /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
 		void (*f)(void *) = (void (*)(void *))(i->func);
 		f(obj);
 	}
@@ -3800,7 +3804,9 @@ bool asCScriptEngine::CallObjectMethodRetBool(void *obj, int func) const {
 		void (*f)(asIScriptGeneric *) = (void (*)(asIScriptGeneric *))(i->func);
 		f(&gen);
 		return *(bool *)gen.GetReturnPointer();
-	} else if (i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL) {
+	}
+#ifndef AS_NO_CLASS_METHODS
+	else if (i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL) {
 		// For virtual thiscalls we must call the method as a true class method so that the compiler will lookup the function address in the vftable
 		union {
 			asSIMPLEMETHOD_t mthd;
@@ -3810,15 +3816,17 @@ bool asCScriptEngine::CallObjectMethodRetBool(void *obj, int func) const {
 			} f;
 		} p;
 
-		obj = (void *)((char *) obj +  i->compositeOffset);
+		obj = (void *)((char *)obj + i->compositeOffset);
 		if (i->isCompositeIndirect)
 			obj = *((void **)obj);
 
 		p.f.func = (asFUNCTION_t)(i->func);
 		p.f.baseOffset = asPWORD(i->baseOffset);
-		bool (asCSimpleDummy::*f)() = (bool (asCSimpleDummy::*)())(p.mthd);
+		bool (asCSimpleDummy::*f)() = (bool(asCSimpleDummy::*)())(p.mthd);
 		return (((asCSimpleDummy *)obj)->*f)();
-	} else { /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
+	}
+#endif
+	else { /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
 		bool (*f)(void *) = (bool (*)(void *))(i->func);
 		return f(obj);
 	}
@@ -3863,7 +3871,9 @@ int asCScriptEngine::CallObjectMethodRetInt(void *obj, int func) const {
 		void (*f)(asIScriptGeneric *) = (void (*)(asIScriptGeneric *))(i->func);
 		f(&gen);
 		return *(int *)gen.GetReturnPointer();
-	} else if (i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL) {
+	}
+#ifndef AS_NO_CLASS_METHODS
+	else if (i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL) {
 		// For virtual thiscalls we must call the method as a true class method so that the compiler will lookup the function address in the vftable
 		union {
 			asSIMPLEMETHOD_t mthd;
@@ -3875,13 +3885,15 @@ int asCScriptEngine::CallObjectMethodRetInt(void *obj, int func) const {
 		p.f.func = (asFUNCTION_t)(i->func);
 		p.f.baseOffset = asPWORD(i->baseOffset);
 
-		obj = (void *)((char *) obj +  i->compositeOffset);
+		obj = (void *)((char *)obj + i->compositeOffset);
 		if (i->isCompositeIndirect)
 			obj = *((void **)obj);
 
-		int (asCSimpleDummy::*f)() = (int (asCSimpleDummy::*)())(p.mthd);
+		int (asCSimpleDummy::*f)() = (int(asCSimpleDummy::*)())(p.mthd);
 		return (((asCSimpleDummy *)obj)->*f)();
-	} else { /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
+	}
+#endif
+	else { /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
 		int (*f)(void *) = (int (*)(void *))(i->func);
 		return f(obj);
 	}
@@ -3926,7 +3938,9 @@ void *asCScriptEngine::CallObjectMethodRetPtr(void *obj, int func) const {
 		void (*f)(asIScriptGeneric *) = (void (*)(asIScriptGeneric *))(i->func);
 		f(&gen);
 		return *(void **)gen.GetReturnPointer();
-	} else if (i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL) {
+	}
+#ifndef AS_NO_CLASS_METHODS
+	else if (i->callConv == ICC_THISCALL || i->callConv == ICC_VIRTUAL_THISCALL) {
 		// For virtual thiscalls we must call the method as a true class method so that the compiler will lookup the function address in the vftable
 		union {
 			asSIMPLEMETHOD_t mthd;
@@ -3938,13 +3952,15 @@ void *asCScriptEngine::CallObjectMethodRetPtr(void *obj, int func) const {
 		p.f.func = (asFUNCTION_t)(i->func);
 		p.f.baseOffset = asPWORD(i->baseOffset);
 
-		obj = (void *)((char *) obj +  i->compositeOffset);
+		obj = (void *)((char *)obj + i->compositeOffset);
 		if (i->isCompositeIndirect)
 			obj = *((void **)obj);
 
 		void *(asCSimpleDummy::*f)() = (void *(asCSimpleDummy::*)())(p.mthd);
 		return (((asCSimpleDummy *)obj)->*f)();
-	} else { /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
+	}
+#endif
+	else { /*if( i->callConv == ICC_CDECL_OBJLAST || i->callConv == ICC_CDECL_OBJFIRST )*/
 		void *(*f)(void *) = (void *(*)(void *))(i->func);
 		return f(obj);
 	}
@@ -4093,26 +4109,30 @@ void asCScriptEngine::CallObjectMethod(void *obj, void *param, asSSystemFunction
 		asCGeneric gen(const_cast<asCScriptEngine *>(this), s, obj, (asDWORD *)&param);
 		void (*f)(asIScriptGeneric *) = (void (*)(asIScriptGeneric *))(i->func);
 		f(&gen);
-	} else if (i->callConv == ICC_VIRTUAL_THISCALL || i->callConv == ICC_THISCALL) {
+	}
+#ifndef AS_NO_CLASS_METHODS
+	else if (i->callConv == ICC_VIRTUAL_THISCALL || i->callConv == ICC_THISCALL) {
 		// For virtual thiscalls we must call the method as a true class method
 		// so that the compiler will lookup the function address in the vftable
 		union {
 			asSIMPLEMETHOD_t mthd;
 			struct {
 				asFUNCTION_t func;
-				asPWORD baseOffset;  // Same size as the pointer
+				asPWORD baseOffset; // Same size as the pointer
 			} f;
 		} p;
 		p.f.func = (asFUNCTION_t)(i->func);
 		p.f.baseOffset = asPWORD(i->baseOffset);
 
-		obj = (void *)((char *) obj +  i->compositeOffset);
+		obj = (void *)((char *)obj + i->compositeOffset);
 		if (i->isCompositeIndirect)
 			obj = *((void **)obj);
 
-		void (asCSimpleDummy::*f)(void *) = (void (asCSimpleDummy::*)(void *))(p.mthd);
+		void (asCSimpleDummy::*f)(void *) = (void(asCSimpleDummy::*)(void *))(p.mthd);
 		(((asCSimpleDummy *)obj)->*f)(param);
-	} else { /*if( i->callConv == ICC_CDECL_OBJFIRST */
+	}
+#endif
+	else { /*if( i->callConv == ICC_CDECL_OBJFIRST */
 		void (*f)(void *, void *) = (void (*)(void *, void *))(i->func);
 		f(obj, param);
 	}
diff --git a/engines/hpl1/engine/libraries/angelscript/sources/as_scriptfunction.cpp b/engines/hpl1/engine/libraries/angelscript/sources/as_scriptfunction.cpp
index aaf642a3622..c08f52cd63d 100644
--- a/engines/hpl1/engine/libraries/angelscript/sources/as_scriptfunction.cpp
+++ b/engines/hpl1/engine/libraries/angelscript/sources/as_scriptfunction.cpp
@@ -1,6 +1,6 @@
 /*
    AngelCode Scripting Library
-   Copyright (c) 2003-2021 Andreas Jonsson
+   Copyright (c) 2003-2023 Andreas Jonsson
 
    This software is provided 'as-is', without any express or implied
    warranty. In no event will the authors be held liable for any
@@ -11,15 +11,15 @@
    redistribute it freely, subject to the following restrictions:
 
    1. The origin of this software must not be misrepresented; you
-      must not claim that you wrote the original software. If you use
-      this software in a product, an acknowledgment in the product
-      documentation would be appreciated but is not required.
+	  must not claim that you wrote the original software. If you use
+	  this software in a product, an acknowledgment in the product
+	  documentation would be appreciated but is not required.
 
    2. Altered source versions must be plainly marked as such, and
-      must not be misrepresented as being the original software.
+	  must not be misrepresented as being the original software.
 
    3. This notice may not be removed or altered from any source
-      distribution.
+	  distribution.
 
    The original version of this library can be located at:
    http://www.angelcode.com/angelscript/
@@ -52,7 +52,7 @@
 
 BEGIN_AS_NAMESPACE
 
-#ifdef AS_MAX_PORTABILITY
+#if defined(AS_MAX_PORTABILITY) || defined(AS_NO_CLASS_METHODS)
 
 static void ScriptFunction_AddRef_Generic(asIScriptGeneric *gen) {
 	asCScriptFunction *self = (asCScriptFunction *)gen->GetObject();
@@ -91,11 +91,13 @@ static void ScriptFunction_ReleaseAllHandles_Generic(asIScriptGeneric *gen) {
 	self->ReleaseAllHandles(engine);
 }
 
+#ifdef AS_MAX_PORTABILITY
 static void ScriptFunction_CreateDelegate_Generic(asIScriptGeneric *gen) {
 	asCScriptFunction *func = (asCScriptFunction *)gen->GetArgAddress(0);
 	void *obj = gen->GetArgAddress(1);
 	gen->SetReturnAddress(CreateDelegate(func, obj));
 }
+#endif
 
 // TODO: operator==
 /*static void ScriptFunction_opEquals_Generic(asIScriptGeneric *gen)
diff --git a/engines/hpl1/engine/libraries/angelscript/sources/as_scriptobject.cpp b/engines/hpl1/engine/libraries/angelscript/sources/as_scriptobject.cpp
index ef5b67c4b19..8f235b2e281 100644
--- a/engines/hpl1/engine/libraries/angelscript/sources/as_scriptobject.cpp
+++ b/engines/hpl1/engine/libraries/angelscript/sources/as_scriptobject.cpp
@@ -1,6 +1,6 @@
 /*
    AngelCode Scripting Library
-   Copyright (c) 2003-2019 Andreas Jonsson
+   Copyright (c) 2003-2023 Andreas Jonsson
 
    This software is provided 'as-is', without any express or implied
    warranty. In no event will the authors be held liable for any
@@ -189,7 +189,7 @@ asIScriptObject *ScriptObjectCopyFactory(const asCObjectType *objType, void *ori
 	return ptr;
 }
 
-#ifdef AS_MAX_PORTABILITY
+#if defined(AS_MAX_PORTABILITY) || defined(AS_NO_CLASS_METHODS)
 
 static void ScriptObject_AddRef_Generic(asIScriptGeneric *gen) {
 	asCScriptObject *self = (asCScriptObject *)gen->GetObject();
@@ -258,7 +258,7 @@ void RegisterScriptObject(asCScriptEngine *engine) {
 	engine->scriptTypeBehaviours.engine = engine;
 	engine->scriptTypeBehaviours.flags = asOBJ_SCRIPT_OBJECT | asOBJ_REF | asOBJ_GC;
 	engine->scriptTypeBehaviours.name = "$obj";
-#ifndef AS_MAX_PORTABILITY
+#if !defined(AS_MAX_PORTABILITY) && !defined(AS_NO_CLASS_METHODS)
 	r = engine->RegisterBehaviourToObjectType(&engine->scriptTypeBehaviours, asBEHAVE_CONSTRUCT, "void f(int&in)", asFUNCTION(ScriptObject_Construct), asCALL_CDECL_OBJLAST, 0);
 	asASSERT(r >= 0);
 	r = engine->RegisterBehaviourToObjectType(&engine->scriptTypeBehaviours, asBEHAVE_ADDREF, "void f()", asMETHOD(asCScriptObject, AddRef), asCALL_THISCALL, 0);




More information about the Scummvm-git-logs mailing list