feat: add minimal HarmonyOS native napi skeleton

This commit is contained in:
OpenClaw committed 2026-03-09 17:05:17 +08:00
1 parent e328780ee5
commit 8b6e24fa61
11 files changed
+565

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
#include "MrpRuntime.h"
CommonResult MrpRuntime::Init(int32_t width, int32_t height, bool debug)
{
width_ = width > 0 ? width : 240;
height_ = height > 0 ? height : 320;
debug_ = debug;
frameId_ = 0;
state_ = State::Initialized;
return CommonResult{true, 0, ""};
}
CommonResult MrpRuntime::LoadPackage(const std::string &packagePath)
{
if (state_ != State::Initialized && state_ != State::Released) {
return CommonResult{false, 1001, "runtime not initialized"};
}
(void)packagePath;
state_ = State::Loaded;
return CommonResult{true, 0, ""};
}
CommonResult MrpRuntime::Start()
{
if (state_ != State::Loaded && state_ != State::Paused) {
return CommonResult{false, 1002, "runtime not ready to start"};
}
state_ = State::Running;
return CommonResult{true, 0, ""};
}
CommonResult MrpRuntime::Pause()
{
if (state_ != State::Running) {
return CommonResult{false, 1003, "runtime not running"};
}
state_ = State::Paused;
return CommonResult{true, 0, ""};
}
CommonResult MrpRuntime::Resume()
{
if (state_ != State::Paused) {
return CommonResult{false, 1004, "runtime not paused"};
}
state_ = State::Running;
return CommonResult{true, 0, ""};
}
CommonResult MrpRuntime::Release()
{
state_ = State::Released;
frameId_ = 0;
return CommonResult{true, 0, ""};
}
int32_t MrpRuntime::Width() const
{
return width_;
}
int32_t MrpRuntime::Height() const
{
return height_;
}
int64_t MrpRuntime::NextFrameId()
{
return ++frameId_;
}
int64_t MrpRuntime::CurrentFrameId() const
{
return frameId_;
}
+37
View File
@@ -0,0 +1,37 @@
#ifndef MRP_RUNTIME_MRP_RUNTIME_H
#define MRP_RUNTIME_MRP_RUNTIME_H
#include "../platform/MrpFacade.h"
class MrpRuntime {
public:
CommonResult Init(int32_t width, int32_t height, bool debug);
CommonResult LoadPackage(const std::string &packagePath);
CommonResult Start();
CommonResult Pause();
CommonResult Resume();
CommonResult Release();
int32_t Width() const;
int32_t Height() const;
int64_t NextFrameId();
int64_t CurrentFrameId() const;
private:
enum class State {
Idle,
Initialized,
Loaded,
Running,
Paused,
Released,
};
State state_ = State::Idle;
int32_t width_ = 240;
int32_t height_ = 320;
bool debug_ = false;
int64_t frameId_ = 0;
};
#endif