Skip to content

Commit

Permalink
feat(api): enhance and organize API bindings and references
Browse files Browse the repository at this point in the history
  • Loading branch information
engsr6982 committed Jan 18, 2025
1 parent cd658d1 commit aa7aa32
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 28 deletions.
29 changes: 26 additions & 3 deletions lib/dts/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
/* enum */
/// <reference path="./enum/PermissionDefault.d.ts"/>
/// <reference path="./enum/LoggerLevel.d.ts"/>
/// <reference path="./enum/PluginLoadOrder.d.ts"/>

/* actor */
/// <reference path="./api/actor/Actor.d.ts"/>
/// <reference path="./api/actor/Mob.d.ts"/>

/* command */
/// <reference path="./api/command/Command.d.ts"/>
/// <reference path="./api/command/CommandSender.d.ts"/>

/* jse */
/// <reference path="./api/jse/File.d.ts"/>
/// <reference path="./api/jse/JSE.d.ts"/>
/// <reference path="./api/plugin/Plugin.d.ts"/>
/// <reference path="./api/plugin/PluginDescription.d.ts"/>

/* lang */
/// <reference path="./api/lang/Translatable.d.ts"/>

/* level */
/// <reference path="./api/level/Level.d.ts"/>
/// <reference path="./api/level/Dimension.d.ts"/>

/* permissions */
/// <reference path="./api/permissions/Permissible.d.ts"/>
/// <reference path="./api/permissions/Permission.d.ts"/>
/// <reference path="./api/lang/Translatable.d.ts"/>

/* plugin */
/// <reference path="./api/plugin/Plugin.d.ts"/>
/// <reference path="./api/plugin/PluginDescription.d.ts"/>

/* util */
/// <reference path="./api/util/UUID.d.ts"/>
/// <reference path="./api/util/Vector.d.ts"/>

/* other */
/// <reference path="./api/Logger.d.ts"/>
/// <reference path="./api/Player.d.ts"/>
/// <reference path="./api/Server.d.ts"/>
/// <reference path="./api/ColorFormat.d.ts"/>
57 changes: 32 additions & 25 deletions src/manager/BindAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,50 @@
namespace jse {

inline void BindAPI(ScriptEngine* engine) {

// enum class
EnumAPI::RegisterEnum(engine);

// static class
engine->registerNativeClass(JSEAPI::builder);
engine->registerNativeClass(FileAPI::builder);
engine->registerNativeClass(ColorFormatAPI::builder);
#define STATIC_CLASS(CLASS) engine->registerNativeClass(CLASS::builder)
#define INSTANCE_CLASS(CLASS) engine->registerNativeClass<CLASS>(CLASS::builder)

// instance class
#define REGISTER_CLASS(CLASS) engine->registerNativeClass<CLASS>(CLASS::builder)
/* actor */
INSTANCE_CLASS(ActorAPI);
INSTANCE_CLASS(MobAPI);

REGISTER_CLASS(PluginAPI);
REGISTER_CLASS(PluginDescriptionAPI);
/* command */
INSTANCE_CLASS(CommandAPI);
INSTANCE_CLASS(CommandSenderAPI);

REGISTER_CLASS(TranslatableAPI);
/* jse */
STATIC_CLASS(JSEAPI);
STATIC_CLASS(FileAPI);

REGISTER_CLASS(LevelAPI);
REGISTER_CLASS(DimensionAPI);
/* lang */
INSTANCE_CLASS(TranslatableAPI);

REGISTER_CLASS(PermissibleAPI);
REGISTER_CLASS(PermissionAPI);
/* level */
INSTANCE_CLASS(LevelAPI);
INSTANCE_CLASS(DimensionAPI);

REGISTER_CLASS(CommandAPI);
REGISTER_CLASS(CommandSenderAPI);
/* permissions */
INSTANCE_CLASS(PermissibleAPI);
INSTANCE_CLASS(PermissionAPI);

REGISTER_CLASS(ActorAPI);
REGISTER_CLASS(MobAPI);
/* plugin */
INSTANCE_CLASS(PluginAPI);
INSTANCE_CLASS(PluginDescriptionAPI);

REGISTER_CLASS(LoggerAPI);
REGISTER_CLASS(PlayerAPI);
/* util */
INSTANCE_CLASS(UUIDAPI);
INSTANCE_CLASS(VectorAPI);

REGISTER_CLASS(UUIDAPI);
REGISTER_CLASS(VectorAPI);
REGISTER_CLASS(ServerAPI);
/* other */
INSTANCE_CLASS(LoggerAPI);
INSTANCE_CLASS(PlayerAPI);
INSTANCE_CLASS(ServerAPI);
STATIC_CLASS(ColorFormatAPI);

#undef REGISTER_CLASS
#undef STATIC_CLASS
#undef INSTANCE_CLASS
}


Expand Down

0 comments on commit aa7aa32

Please sign in to comment.