mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Added MSVC build support, likely broke tests
This commit is contained in:
@@ -15,8 +15,6 @@ STATIC_ASSERT(sizeof(unsigned char) == 1);
|
||||
STATIC_ASSERT(sizeof(unsigned short) == 2);
|
||||
STATIC_ASSERT(sizeof(unsigned int) == 4);
|
||||
|
||||
#ifndef TOY_EXPORT
|
||||
|
||||
//declare the singleton
|
||||
Toy_CommandLine Toy_commandLine;
|
||||
|
||||
@@ -121,5 +119,3 @@ void Toy_copyrightCommandLine(int argc, const char* argv[]) {
|
||||
printf("2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n\n");
|
||||
printf("3. This notice may not be removed or altered from any source distribution.\n\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,17 +11,22 @@
|
||||
|
||||
//platform-specific specifications
|
||||
#if defined(__linux__)
|
||||
|
||||
#define TOY_API extern
|
||||
|
||||
#elif defined(_WIN32) || defined(WIN32)
|
||||
#define TOY_API
|
||||
#elif defined(_WIN32) || defined(_MSC_VER)
|
||||
|
||||
#ifndef TOY_EXPORT
|
||||
#define TOY_API __declspec(dllimport)
|
||||
#else
|
||||
#define TOY_API __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define TOY_API
|
||||
#define TOY_API extern
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef TOY_EXPORT
|
||||
//for processing the command line arguments
|
||||
typedef struct {
|
||||
bool error;
|
||||
@@ -35,11 +40,10 @@ typedef struct {
|
||||
bool verbose;
|
||||
} Toy_CommandLine;
|
||||
|
||||
extern Toy_CommandLine Toy_commandLine;
|
||||
TOY_API Toy_CommandLine Toy_commandLine;
|
||||
|
||||
void Toy_initCommandLine(int argc, const char* argv[]);
|
||||
TOY_API void Toy_initCommandLine(int argc, const char* argv[]);
|
||||
|
||||
void Toy_usageCommandLine(int argc, const char* argv[]);
|
||||
void Toy_helpCommandLine(int argc, const char* argv[]);
|
||||
void Toy_copyrightCommandLine(int argc, const char* argv[]);
|
||||
#endif
|
||||
TOY_API void Toy_usageCommandLine(int argc, const char* argv[]);
|
||||
TOY_API void Toy_helpCommandLine(int argc, const char* argv[]);
|
||||
TOY_API void Toy_copyrightCommandLine(int argc, const char* argv[]);
|
||||
|
||||
@@ -2356,7 +2356,7 @@ void Toy_initInterpreter(Toy_Interpreter* interpreter) {
|
||||
Toy_resetInterpreter(interpreter);
|
||||
}
|
||||
|
||||
void Toy_runInterpreter(Toy_Interpreter* interpreter, const unsigned char* bytecode, int length) {
|
||||
void Toy_runInterpreter(Toy_Interpreter* interpreter, const unsigned char* bytecode, size_t length) {
|
||||
//initialize here instead of initInterpreter()
|
||||
Toy_initLiteralArray(&interpreter->literalCache);
|
||||
interpreter->bytecode = NULL;
|
||||
|
||||
@@ -48,6 +48,6 @@ TOY_API void Toy_setInterpreterError(Toy_Interpreter* interpreter, Toy_PrintFn e
|
||||
|
||||
//main access
|
||||
TOY_API void Toy_initInterpreter(Toy_Interpreter* interpreter); //start of program
|
||||
TOY_API void Toy_runInterpreter(Toy_Interpreter* interpreter, const unsigned char* bytecode, int length); //run the code
|
||||
TOY_API void Toy_runInterpreter(Toy_Interpreter* interpreter, const unsigned char* bytecode, size_t length); //run the code
|
||||
TOY_API void Toy_resetInterpreter(Toy_Interpreter* interpreter); //use this to reset the interpreter's environment between runs
|
||||
TOY_API void Toy_freeInterpreter(Toy_Interpreter* interpreter); //end of program
|
||||
|
||||
@@ -21,9 +21,9 @@ typedef struct {
|
||||
} Toy_Token;
|
||||
|
||||
TOY_API void Toy_initLexer(Toy_Lexer* lexer, const char* source);
|
||||
Toy_Token Toy_scanLexer(Toy_Lexer* lexer);
|
||||
TOY_API Toy_Token Toy_scanLexer(Toy_Lexer* lexer);
|
||||
|
||||
//for debugging
|
||||
void Toy_printToken(Toy_Token* token);
|
||||
TOY_API void Toy_printToken(Toy_Token* token);
|
||||
|
||||
void Toy_private_setComments(Toy_Lexer* lexer, bool enabled);
|
||||
TOY_API void Toy_private_setComments(Toy_Lexer* lexer, bool enabled);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define TOY_FREE_ARRAY(type, pointer, oldCount) Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), 0)
|
||||
|
||||
//implementation details
|
||||
void* Toy_reallocate(void* pointer, size_t oldSize, size_t newSize);
|
||||
TOY_API void* Toy_reallocate(void* pointer, size_t oldSize, size_t newSize);
|
||||
|
||||
//assign the memory allocator
|
||||
typedef void* (*Toy_MemoryAllocatorFn)(void* pointer, size_t oldSize, size_t newSize);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "toy_common.h"
|
||||
|
||||
//memory allocation hook
|
||||
typedef void* (*Toy_RefStringAllocatorFn)(void* pointer, size_t oldSize, size_t newSize);
|
||||
void Toy_setRefStringAllocatorFn(Toy_RefStringAllocatorFn);
|
||||
@@ -15,13 +17,13 @@ typedef struct Toy_RefString {
|
||||
} Toy_RefString;
|
||||
|
||||
//API
|
||||
Toy_RefString* Toy_createRefString(const char* cstring);
|
||||
Toy_RefString* Toy_createRefStringLength(const char* cstring, size_t length);
|
||||
void Toy_deleteRefString(Toy_RefString* refString);
|
||||
int Toy_countRefString(Toy_RefString* refString);
|
||||
size_t Toy_lengthRefString(Toy_RefString* refString);
|
||||
Toy_RefString* Toy_copyRefString(Toy_RefString* refString);
|
||||
Toy_RefString* Toy_deepCopyRefString(Toy_RefString* refString);
|
||||
const char* Toy_toCString(Toy_RefString* refString);
|
||||
bool Toy_equalsRefString(Toy_RefString* lhs, Toy_RefString* rhs);
|
||||
bool Toy_equalsRefStringCString(Toy_RefString* lhs, char* cstring);
|
||||
TOY_API Toy_RefString* Toy_createRefString(const char* cstring);
|
||||
TOY_API Toy_RefString* Toy_createRefStringLength(const char* cstring, size_t length);
|
||||
TOY_API void Toy_deleteRefString(Toy_RefString* refString);
|
||||
TOY_API int Toy_countRefString(Toy_RefString* refString);
|
||||
TOY_API size_t Toy_lengthRefString(Toy_RefString* refString);
|
||||
TOY_API Toy_RefString* Toy_copyRefString(Toy_RefString* refString);
|
||||
TOY_API Toy_RefString* Toy_deepCopyRefString(Toy_RefString* refString);
|
||||
TOY_API const char* Toy_toCString(Toy_RefString* refString);
|
||||
TOY_API bool Toy_equalsRefString(Toy_RefString* lhs, Toy_RefString* rhs);
|
||||
TOY_API bool Toy_equalsRefStringCString(Toy_RefString* lhs, char* cstring);
|
||||
|
||||
@@ -10,16 +10,16 @@ typedef struct Toy_Scope {
|
||||
int references; //how many scopes point here
|
||||
} Toy_Scope;
|
||||
|
||||
Toy_Scope* Toy_pushScope(Toy_Scope* scope);
|
||||
Toy_Scope* Toy_popScope(Toy_Scope* scope);
|
||||
Toy_Scope* Toy_copyScope(Toy_Scope* original);
|
||||
TOY_API Toy_Scope* Toy_pushScope(Toy_Scope* scope);
|
||||
TOY_API Toy_Scope* Toy_popScope(Toy_Scope* scope);
|
||||
TOY_API Toy_Scope* Toy_copyScope(Toy_Scope* original);
|
||||
|
||||
//returns false if error
|
||||
bool Toy_declareScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal type);
|
||||
bool Toy_isDelcaredScopeVariable(Toy_Scope* scope, Toy_Literal key);
|
||||
TOY_API bool Toy_declareScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal type);
|
||||
TOY_API bool Toy_isDelcaredScopeVariable(Toy_Scope* scope, Toy_Literal key);
|
||||
|
||||
//return false if undefined
|
||||
bool Toy_setScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal value, bool constCheck);
|
||||
bool Toy_getScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal* value);
|
||||
TOY_API bool Toy_setScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal value, bool constCheck);
|
||||
TOY_API bool Toy_getScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal* value);
|
||||
|
||||
Toy_Literal Toy_getScopeType(Toy_Scope* scope, Toy_Literal key);
|
||||
TOY_API Toy_Literal Toy_getScopeType(Toy_Scope* scope, Toy_Literal key);
|
||||
|
||||
Reference in New Issue
Block a user