Skip to content

Commit

Permalink
Fix some links and document public API
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Nov 30, 2024
1 parent 7c6b9e2 commit 1ebd2ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions docs/godot_docs/cppapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ sidebar_position: 11

# C++ API Reference

The current C++ API is likely to change over time. Feel free to contribute improvements to the API.
The current C++ API is likely to change over time, however it is mostly complete. Feel free to contribute improvements to the API. The run-time generated API comes in addition to this API and covers the rest of Godot by adding all classes known at run-time, including loaded extensions.

You can find the [source of the API here](https://github.com/libriscv/godot-sandbox/blob/main/program/cpp/api/api.hpp).
You can find the [source of the API here](https://github.com/libriscv/godot-sandbox/tree/main/program/cpp/docker/api/api.hpp).


## General
Expand Down Expand Up @@ -89,6 +89,29 @@ inline void halt();
/// @brief Check if the program is running in the Godot editor.
/// @return True if running in the editor, false otherwise.
inline bool is_editor();
inline bool is_editor_hint(); // Alias

/// @brief Create a public API for the program.
/// @param ... The list of public API functions.
/// @example
/// SANDBOX_API({
/// .name = "hello_world",
/// .address = (void *)hello_world,
/// .description = "Prints 'Hello, world!' to the console.",
/// .return_type = "void",
/// .arguments = "",
/// });
extern "C" struct PublicAPI {
const char * const name;
const void * const address;
const char * const description;
const char * const return_type;
// Simple comma-separated list of arguments: "int a, double b, String c"
const char * const arguments;
};
#define NUM_APIARGS(...) (sizeof((PublicAPI[]){PublicAPI{}, ##__VA_ARGS__})/sizeof(PublicAPI))
#define SANDBOX_API(...) \
extern "C" const PublicAPI public_api[NUM_APIARGS(__VA_ARGS__)] { __VA_ARGS__, {0} };
```
Expand Down
2 changes: 1 addition & 1 deletion docs/godot_intro/cppprogram.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ If it is not working, you need to set the docker path manually by going to **Pro
## The C++ API
The C++ API tries to mimick godot-cpp when it makes sense to do so, and it otherwise provides the entire GDScript API. You can find [the C++ API implementation here](https://github.com/libriscv/godot-sandbox/tree/main/program/cpp/api), and [the C++ API reference here](../godot_docs/cppapi.md). For everything else, you can refer to the official Godot documentation.
The C++ API tries to mimick godot-cpp when it makes sense to do so, and it otherwise provides the entire GDScript API. You can find [the C++ API implementation here](https://github.com/libriscv/godot-sandbox/tree/main/program/cpp/docker/api), and [the C++ API reference here](../godot_docs/cppapi.md). For everything else, you can refer to the official Godot documentation.
## ELF Script
Expand Down

0 comments on commit 1ebd2ac

Please sign in to comment.