#ifndef BYONDAPI_H
#define BYONDAPI_H
#if defined(WIN32) || defined(WIN64)
#define IS_WINDOWS
#else
#define IS_LINUX
#endif
#if defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__X86__)
#define _X86
#define _X86ORX64
#define DM_32BIT
#elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(_WIN64) || defined(WIN64)
#define _X64
#define _X86ORX64
#define DM_64BIT
#elif defined(__arm__) || defined(_M_ARM)
#define _ARM
#if defined(__LP64__) || defined(_LP64)
#define DM_64BIT
#else
#define DM_32BIT
#endif
#endif
typedef unsigned char u1c;
typedef signed char s1c;
typedef unsigned short u2c;
typedef signed short s2c;
#ifdef DM_64BIT
typedef unsigned int u4c;
typedef signed int s4c;
#else
typedef unsigned long u4c;
typedef signed long s4c;
#endif
#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 s8c;
typedef unsigned __int64 u8c;
#else
typedef long long int s8c;
typedef unsigned long long int u8c;
#endif
union u4cOrPointer {
u4c num;
void *ptr;
};
#ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#else
#define GCC_VERSION 0
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1800
#define _SUPPORT_MOVES
#elif defined(__GNUC__) && GCC_VERSION >= 50000
#define _SUPPORT_MOVES
#endif
#define u1cMASK ((u1c)0xff)
#define u2cMASK ((u2c)0xffff)
#define u3cMASK ((u4c)0xffffffL)
#define u4cMASK ((u4c)0xffffffffL)
#define u1cMAX u1cMASK
#define u2cMAX u2cMASK
#define u3cMAX u3cMASK
#define u4cMAX u4cMASK
#define s1cMAX 0x7f
#define s1cMIN (-0x7f)
#define s2cMAX 0x7fff
#define s2cMIN (-0x7fff)
#define s4cMAX 0x7fffffffL
#define s4cMIN (-0x7fffffffL)
#define NONE u2cMAX
#define NOCH u1cMAX
#ifdef WIN32
#define THREAD_VAR __declspec(thread)
#else
#define THREAD_VAR __thread
#endif
#ifdef WIN32
#define DUNGPUB __declspec(dllimport)
#define BYOND_EXPORT __declspec(dllexport)
#else
#define DUNGPUB
#define BYOND_EXPORT __attribute__ ((visibility("default")))
#endif
extern "C" {
DUNGPUB char const *Byond_LastError();
DUNGPUB void Byond_GetVersion(u4c *version, u4c *build);
DUNGPUB u4c Byond_GetDMBVersion();
typedef u1c ByondValueType;
union ByondValueData {
u4c ref; float num; };
struct CByondValue {
ByondValueType type; u1c junk1, junk2, junk3; ByondValueData data; };
DUNGPUB void ByondValue_Clear(CByondValue *v);
DUNGPUB ByondValueType ByondValue_Type(CByondValue const *v);
DUNGPUB bool ByondValue_IsNull(CByondValue const *v);
DUNGPUB bool ByondValue_IsNum(CByondValue const *v);
DUNGPUB bool ByondValue_IsStr(CByondValue const *v);
DUNGPUB bool ByondValue_IsList(CByondValue const *v);
DUNGPUB bool ByondValue_IsTrue(CByondValue const *v);
DUNGPUB float ByondValue_GetNum(CByondValue const *v);
DUNGPUB u4c ByondValue_GetRef(CByondValue const *v);
DUNGPUB void ByondValue_SetNum(CByondValue *v, float f);
DUNGPUB void ByondValue_SetStr(CByondValue *v, char const *str);
DUNGPUB void ByondValue_SetRef(CByondValue *v, ByondValueType type, u4c ref);
DUNGPUB bool ByondValue_Equals(CByondValue const *a, CByondValue const *b);
struct CByondXYZ {
s2c x, y, z; s2c junk; };
typedef CByondValue (*ByondCallback)(void *);
DUNGPUB CByondValue Byond_ThreadSync(ByondCallback callback, void *data, bool block=false);
DUNGPUB u4c Byond_GetStrId(char const *str);
DUNGPUB u4c Byond_AddGetStrId(char const *str);
DUNGPUB bool Byond_ReadVar(CByondValue const *loc, char const *varname, CByondValue *result);
DUNGPUB bool Byond_ReadVarByStrId(CByondValue const *loc, u4c varname, CByondValue *result);
DUNGPUB bool Byond_WriteVar(CByondValue const *loc, char const *varname, CByondValue const *val);
DUNGPUB bool Byond_WriteVarByStrId(CByondValue const *loc, u4c varname, CByondValue const *val);
DUNGPUB bool Byond_CreateList(CByondValue *result);
DUNGPUB bool Byond_ReadList(CByondValue const *loc, CByondValue *list, u4c *len);
DUNGPUB bool Byond_WriteList(CByondValue const *loc, CByondValue const *list, u4c len);
DUNGPUB bool Byond_ReadListAssoc(CByondValue const *loc, CByondValue *list, u4c *len);
DUNGPUB bool Byond_ReadListIndex(CByondValue const *loc, CByondValue const *idx, CByondValue *result);
DUNGPUB bool Byond_WriteListIndex(CByondValue const *loc, CByondValue const *idx, CByondValue const *val);
DUNGPUB bool Byond_ReadPointer(CByondValue const *ptr, CByondValue *result);
DUNGPUB bool Byond_WritePointer(CByondValue const *ptr, CByondValue const *val);
DUNGPUB bool Byond_CallProc(CByondValue const *src, char const *name, CByondValue const *arg, u4c arg_count, CByondValue *result);
DUNGPUB bool Byond_CallProcByStrId(CByondValue const *src, u4c name, CByondValue const *arg, u4c arg_count, CByondValue *result);
DUNGPUB bool Byond_CallGlobalProc(char const *name, CByondValue const *arg, u4c arg_count, CByondValue *result);
DUNGPUB bool Byond_CallGlobalProcByStrId(u4c name, CByondValue const *arg, u4c arg_count, CByondValue *result);
DUNGPUB bool Byond_ToString(CByondValue const *src, char *buf, u4c *buflen);
DUNGPUB bool Byond_Block(CByondXYZ const *corner1, CByondXYZ const *corner2, CByondValue *list, u4c *len);
DUNGPUB bool Byond_Length(CByondValue const *src, CByondValue *result);
DUNGPUB bool Byond_LocateIn(CByondValue const *type, CByondValue const *list, CByondValue *result);
DUNGPUB bool Byond_LocateXYZ(CByondXYZ const *xyz, CByondValue *result);
DUNGPUB bool Byond_New(CByondValue const *type, CByondValue const *arg, u4c arg_count, CByondValue *result);
DUNGPUB bool Byond_NewArglist(CByondValue const *type, CByondValue const *arglist, CByondValue *result);
DUNGPUB bool Byond_Refcount(CByondValue const *src, u4c *result);
DUNGPUB bool Byond_XYZ(CByondValue const *src, CByondXYZ *xyz);
DUNGPUB void ByondValue_IncRef(CByondValue const *src);
DUNGPUB void ByondValue_DecRef(CByondValue const *src);
DUNGPUB bool Byond_TestRef(CByondValue *src);
};
#endif