-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added mecha-style comment docs to a bunch of headers
- Loading branch information
1 parent
3d7d117
commit cdfe17a
Showing
20 changed files
with
1,165 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ bin/ | |
*.stackdump | ||
*.tb | ||
*.filters | ||
[Dd]ocs/ | ||
|
||
#Shell files | ||
*.bat | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,76 @@ | ||
#pragma once | ||
|
||
/*! | ||
# toy_drive_system.h | ||
When accessing the file system through toy (such as with the runner library), it's best practice to utilize Toy's built-in drive system - this system (tries to) prevent malicious accessing of files outside of the designated folders. It does this by causing an error when a script tries to access a parent directory. | ||
To use the drive system, first you must designate specific folders which can be accessed, like so: | ||
```c | ||
#include "toy_drive_system.h" | ||
int main(int argc, char* argv[]) { | ||
//the drive system uses a LiteralDictionary, which must be initialized with this | ||
Toy_initDriveSystem(); | ||
Toy_setDrivePath("scripts", "assets/scripts"); | ||
Toy_setDrivePath("sprites", "assets/sprites"); | ||
Toy_setDrivePath("fonts", "assets/fonts"); | ||
//TODO: do you stuff here | ||
//clean up the drive dictionary when you're done | ||
Toy_freeDriveSystem(); | ||
return 0; | ||
} | ||
``` | ||
This utility is intended mainly for libraries to use - as such, the core of Toy does not utilize it. | ||
### Implementation Details | ||
The drive system uses a Toy's Dictionary structure to store the mappings between keys and values - this dictionary object is a static global which persists for the lifetime of the program. | ||
!*/ | ||
|
||
#include "toy_common.h" | ||
|
||
#include "toy_literal.h" | ||
#include "toy_interpreter.h" | ||
|
||
//file system API - these need to be set by the host | ||
/*! | ||
## Defined Functions | ||
!*/ | ||
|
||
/*! | ||
### void Toy_initDriveSystem() | ||
This function initializes the drive system. | ||
!*/ | ||
TOY_API void Toy_initDriveSystem(); | ||
|
||
/*! | ||
### void Toy_freeDriveSystem() | ||
This function cleans up after the drive system is no longer needed. | ||
!*/ | ||
TOY_API void Toy_freeDriveSystem(); | ||
|
||
//file system API - for use with libs | ||
/*! | ||
### void Toy_setDrivePath(char* drive, char* path) | ||
This function sets a key-value pair in the drive system. It uses C strings, since its intended to be called directly from `main()`. | ||
!*/ | ||
TOY_API void Toy_setDrivePath(char* drive, char* path); | ||
|
||
/*! | ||
### Toy_Literal Toy_getDrivePathLiteral(Toy_Interpreter* interpreter, Toy_Literal* drivePathLiteral) | ||
This function, when given a string literal of the correct format, will return a new string literal containing the relative filepath to a specified file. | ||
The correct format is `drive:/path/to/filename`, where `drive` is a drive that was specified with `Toy_setDrivePath()`. | ||
On failure, this function returns a null literal. | ||
!*/ | ||
TOY_API Toy_Literal Toy_getDrivePathLiteral(Toy_Interpreter* interpreter, Toy_Literal* drivePathLiteral); |
Oops, something went wrong.