Changeset - r21475:389627bb83bb
[Not reviewed]
master
0 5 0
rubidium - 10 years ago 2014-05-11 20:16:37
rubidium@openttd.org
(svn r26584) -Codechange: [Squirrel] Make the internal integer for scripts always 64 bits, so scripts behave the same on 32 or 64 bits architectures
5 files changed with 12 insertions and 50 deletions:
0 comments (0 inline, 0 general)
src/3rdparty/squirrel/include/squirrel.h
Show inline comments
 
@@ -49,33 +49,14 @@ extern "C" {
 
#define SQUIRREL_API extern
 
#endif
 

	
 
#if (defined(_WIN64) || defined(_LP64))
 
#ifndef _SQ64
 
#define _SQ64
 
#endif
 
#if defined(__GNUC__)
 
	#define __int64 long long
 
#endif
 

	
 
#ifdef _SQ64
 
#ifdef _MSC_VER
 
typedef __int64 SQInteger;
 
typedef unsigned __int64 SQUnsignedInteger;
 
typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
 
#elif defined(_WIN32)
 
typedef long long SQInteger;
 
typedef unsigned long long SQUnsignedInteger;
 
typedef unsigned long long SQHash; /*should be the same size of a pointer*/
 
#else
 
typedef long SQInteger;
 
typedef unsigned long SQUnsignedInteger;
 
typedef unsigned long SQHash; /*should be the same size of a pointer*/
 
#endif
 
typedef int SQInt32;
 
#else
 
typedef int SQInteger;
 
typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/
 
typedef unsigned int SQUnsignedInteger;
 
typedef unsigned int SQHash; /*should be the same size of a pointer*/
 
#endif
 

	
 

	
 
#ifdef SQUSEDOUBLE
 
@@ -84,17 +65,8 @@ typedef double SQFloat;
 
typedef float SQFloat;
 
#endif
 

	
 
#if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64)
 
#ifdef _MSC_VER
 
typedef __int64 SQRawObjectVal; //must be 64bits
 
#else
 
typedef long long SQRawObjectVal; //must be 64bits
 
#endif
 
#define SQ_OBJECT_RAWINIT() { _unVal.raw = 0; }
 
#else
 
typedef SQUnsignedInteger SQRawObjectVal; //is 32 bits on 32 bits builds and 64 bits otherwise
 
#define SQ_OBJECT_RAWINIT()
 
#endif
 

	
 
typedef void* SQUserPointer;
 
typedef SQUnsignedInteger SQBool;
 
@@ -186,6 +158,12 @@ typedef char SQChar;
 
#define MAX_CHAR 0xFFFF
 
#endif
 

	
 
#if defined(_MSC_VER) || defined(__MINGW32__)
 
	#define SQ_PRINTF64 _SC("%I64d")
 
#else
 
	#define SQ_PRINTF64 _SC("%lld")
 
#endif
 

	
 
#define SQUIRREL_VERSION	_SC("Squirrel 2.2.5 stable - With custom OpenTTD modifications")
 
#define SQUIRREL_COPYRIGHT	_SC("Copyright (C) 2003-2010 Alberto Demichelis")
 
#define SQUIRREL_AUTHOR		_SC("Alberto Demichelis")
src/3rdparty/squirrel/squirrel/sqdebug.cpp
Show inline comments
 
@@ -75,11 +75,7 @@ SQString *SQVM::PrintObjVal(const SQObje
 
	switch(type(o)) {
 
	case OT_STRING: return _string(o);
 
	case OT_INTEGER:
 
#if defined(_SQ64)
 
		scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%ld"), _integer(o));
 
#else
 
		scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%d"), _integer(o));
 
#endif
 
		scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), SQ_PRINTF64, _integer(o));
 
		return SQString::Create(_ss(this), _spval);
 
		break;
 
	case OT_FLOAT:
src/3rdparty/squirrel/squirrel/sqfuncstate.cpp
Show inline comments
 
@@ -80,11 +80,7 @@ void DumpLiteral(SQObjectPtr &o)
 
	switch(type(o)){
 
		case OT_STRING:	scprintf(_SC("\"%s\""),_stringval(o));break;
 
		case OT_FLOAT: scprintf(_SC("{%f}"),_float(o));break;
 
#if defined(_SQ64)
 
		case OT_INTEGER: scprintf(_SC("{%ld}"),_integer(o));break;
 
#else
 
		case OT_INTEGER: scprintf(_SC("{%d}"),_integer(o));break;
 
#endif
 
		case OT_INTEGER: scprintf(_SC("{") SQ_PRINTF64 _SC("}"),_integer(o));break;
 
		case OT_BOOL: scprintf(_SC("%s"),_integer(o)?_SC("true"):_SC("false"));break;
 
		default: scprintf(_SC("(%s %p)"),GetTypeName(o),(void*)_rawval(o));break; break; //shut up compiler
 
	}
src/3rdparty/squirrel/squirrel/sqvm.cpp
Show inline comments
 
@@ -259,11 +259,7 @@ void SQVM::ToString(const SQObjectPtr &o
 
		scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%g"),_float(o));
 
		break;
 
	case OT_INTEGER:
 
#if defined(_SQ64)
 
		scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%ld"),_integer(o));
 
#else
 
		scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%d"),_integer(o));
 
#endif
 
		scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),SQ_PRINTF64,_integer(o));
 
		break;
 
	case OT_BOOL:
 
		scsprintf(_sp(rsl(6)),_integer(o)?_SC("true"):_SC("false"));
src/script/squirrel.cpp
Show inline comments
 
@@ -31,11 +31,7 @@ void Squirrel::CompileError(HSQUIRRELVM 
 
{
 
	SQChar buf[1024];
 

	
 
#ifdef _SQ64
 
	scsnprintf(buf, lengthof(buf), _SC("Error %s:%ld/%ld: %s"), source, line, column, desc);
 
#else
 
	scsnprintf(buf, lengthof(buf), _SC("Error %s:%d/%d: %s"), source, line, column, desc);
 
#endif
 
	scsnprintf(buf, lengthof(buf), _SC("Error %s:") SQ_PRINTF64 _SC("/") SQ_PRINTF64 _SC(": %s"), source, line, column, desc);
 

	
 
	/* Check if we have a custom print function */
 
	Squirrel *engine = (Squirrel *)sq_getforeignptr(vm);
0 comments (0 inline, 0 general)