Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

build(native): the DragonBones ABI is declared where a native host can find it

esengine6dbdfa280f81
diff --git a/build-tools/tasks/native.js b/build-tools/tasks/native.js
index 3aef38765..f116b6c27 100644
--- a/build-tools/tasks/native.js
+++ b/build-tools/tasks/native.js
@@ -69,6 +69,7 @@ export const MODULE_BINDING_HEADERS = [
'PhysicsBindings.hpp',
'VideoBindings.hpp',
'SpineBindings.hpp',
+ 'DragonBonesBindings.hpp',
];
export const NATIVE_BINDING_HEADERS = [...ENGINE_BINDING_HEADERS, ...MODULE_BINDING_HEADERS];
diff --git a/src/esengine/bindings/DragonBonesBindings.hpp b/src/esengine/bindings/DragonBonesBindings.hpp
new file mode 100644
index 000000000..b10eb4e36
--- /dev/null
+++ b/src/esengine/bindings/DragonBonesBindings.hpp
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file DragonBonesBindings.hpp
+ * @brief The DragonBones module's exported ABI, declared apart from its bodies.
+ *
+ * @details The web reaches these through embind; a native host reaches them
+ * through QuickJS wrappers EHT generates from THIS header. Declaring them
+ * here rather than inline in the entry is what makes the second path
+ * exist at all — a module whose ABI lives only in its .cpp links into the
+ * host and cannot be called from it.
+ *
+ * `@heapreturn` marks an entry point that writes through a pointer the
+ * caller allocated, so the generator knows to marshal rather than return.
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the Apache License, Version 2.0.
+ */
+#pragma once
+
+#include <cstddef>
+#include <cstdint>
+
+extern "C" {
+
+// — Resources ——————————————————————————————————————————————————————————————
+int db_loadSkeleton(uintptr_t skeletonPtr, int skeletonLen, uintptr_t atlasPtr, int atlasLen);
+const char* db_getLastError();
+void db_unloadSkeleton(int handle);
+/** `["armatureA","armatureB"]` — a DragonBones file names more than one. */
+const char* db_getArmatures(int handle);
+const char* db_getAtlasImageName(int handle);
+void db_setAtlasTexture(int handle, uint32_t textureId);
+
+// — Instances ——————————————————————————————————————————————————————————————
+int db_createInstance(int skeletonHandle, const char* armatureName);
+void db_destroyInstance(int instanceId);
+
+// — Animation ——————————————————————————————————————————————————————————————
+/** `playTimes`: -1 keeps what the data says, 0 loops, n plays n times. */
+int db_playAnimation(int instanceId, const char* name, int playTimes);
+/** Where Spine would set a mix duration: DragonBones fades at the moment of play. */
+int db_fadeInAnimation(int instanceId, const char* name, float fadeSeconds, int playTimes);
+void db_stopAnimation(int instanceId, const char* name);
+void db_setTimeScale(int instanceId, float scale);
+void db_update(int instanceId, float dt);
+const char* db_getAnimations(int instanceId);
+
+// — Geometry readback ——————————————————————————————————————————————————————
+int db_getMeshBatchCount(int instanceId);
+int db_getMeshBatchVertexCount(int instanceId, int batchIndex);
+int db_getMeshBatchIndexCount(int instanceId, int batchIndex);
+/** @heapreturn outVerticesPtr, outIndicesPtr, outTextureIdPtr, outBlendModePtr */
+void db_getMeshBatchData(int instanceId, int batchIndex, uintptr_t outVerticesPtr, uintptr_t outIndicesPtr,
+ uintptr_t outTextureIdPtr, uintptr_t outBlendModePtr);
+/** @heapreturn outXPtr, outYPtr, outWPtr, outHPtr */
+void db_getBounds(int instanceId, uintptr_t outXPtr, uintptr_t outYPtr, uintptr_t outWPtr, uintptr_t outHPtr);
+/** The DragonBones data format this runtime reads, for the SDK's version gate. */
+int db_runtimeVersion();
+
+} // extern "C"
diff --git a/src/esengine/bindings/DragonBonesModuleEntry.cpp b/src/esengine/bindings/DragonBonesModuleEntry.cpp
index 9b8873b01..66993dd08 100644
--- a/src/esengine/bindings/DragonBonesModuleEntry.cpp
+++ b/src/esengine/bindings/DragonBonesModuleEntry.cpp
@@ -42,6 +42,7 @@
#include <vector>
#include "DragonBonesAdapter.hpp"
+#include "DragonBonesBindings.hpp"
#include "SkeletalModule.hpp"
namespace {