mirror of
https://github.com/Gongxh0901/kunpolibrary
synced 2025-10-30 10:55:40 +00:00
仓库中添加内置的demo
This commit is contained in:
1
demo/native/engine/common/.gitignore
vendored
Normal file
1
demo/native/engine/common/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
localCfg.cmake
|
||||
64
demo/native/engine/common/CMakeLists.txt
Executable file
64
demo/native/engine/common/CMakeLists.txt
Executable file
@@ -0,0 +1,64 @@
|
||||
enable_language(C ASM)
|
||||
set(DEVELOPMENT_TEAM "" CACHE STRING "APPLE Developtment Team")
|
||||
set(RES_DIR "" CACHE STRING "Resource path")
|
||||
set(COCOS_X_PATH "" CACHE STRING "Path to engine/native/")
|
||||
|
||||
set(TARGET_OSX_VERSION "10.14" CACHE STRING "Target MacOSX version" FORCE)
|
||||
set(TARGET_IOS_VERSION "11.0" CACHE STRING "Target iOS version" FORCE)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
option(CC_DEBUG_FORCE "Force enable CC_DEBUG in release mode" OFF)
|
||||
option(USE_SE_V8 "Use V8 JavaScript Engine" ON)
|
||||
option(USE_SE_JSVM "Use JSVM JavaScript Engine" OFF)
|
||||
option(USE_SE_JSC "Use JavaScriptCore on MacOSX/iOS" OFF)
|
||||
option(USE_V8_DEBUGGER "Compile v8 inspector ws server" ON)
|
||||
option(USE_V8_DEBUGGER_FORCE "Force enable debugger in release mode" OFF)
|
||||
option(USE_SOCKET "Enable WebSocket & SocketIO" ON)
|
||||
option(USE_AUDIO "Enable Audio" ON) #Enable AudioEngine
|
||||
option(USE_EDIT_BOX "Enable EditBox" ON)
|
||||
option(USE_VIDEO "Enable VideoPlayer Component" ON)
|
||||
option(USE_WEBVIEW "Enable WebView Component" ON)
|
||||
option(USE_MIDDLEWARE "Enable Middleware" ON)
|
||||
option(USE_DRAGONBONES "Enable Dragonbones" ON)
|
||||
option(USE_SPINE_3_8 "Enable Spine 3.8" ON)
|
||||
option(USE_SPINE_4_2 "Enable Spine 4.2" OFF)
|
||||
option(USE_WEBSOCKET_SERVER "Enable WebSocket Server" OFF)
|
||||
option(USE_JOB_SYSTEM_TASKFLOW "Use taskflow as job system backend" OFF)
|
||||
option(USE_JOB_SYSTEM_TBB "Use tbb as job system backend" OFF)
|
||||
option(USE_PHYSICS_PHYSX "Use PhysX Physics" ON)
|
||||
option(USE_OCCLUSION_QUERY "Use Occlusion Query" ON)
|
||||
option(USE_DEBUG_RENDERER "Use Debug Renderer" ON)
|
||||
option(USE_GEOMETRY_RENDERER "Use Geometry Renderer" ON)
|
||||
option(USE_WEBP "Use Webp" ON)
|
||||
|
||||
if(NOT RES_DIR)
|
||||
message(FATAL_ERROR "RES_DIR is not set!")
|
||||
endif()
|
||||
|
||||
include(${RES_DIR}/proj/cfg.cmake)
|
||||
|
||||
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/localCfg.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/localCfg.cmake)
|
||||
endif()
|
||||
|
||||
if(NOT COCOS_X_PATH)
|
||||
message(FATAL_ERROR "COCOS_X_PATH is not set!")
|
||||
endif()
|
||||
|
||||
if(USE_XR OR USE_AR_MODULE)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/xr.cmake)
|
||||
endif()
|
||||
|
||||
include(${COCOS_X_PATH}/CMakeLists.txt)
|
||||
|
||||
list(APPEND CC_COMMON_SOURCES
|
||||
${CMAKE_CURRENT_LIST_DIR}/Classes/Game.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/Classes/Game.cpp
|
||||
|
||||
############### 添加生成的绑定类 ##############
|
||||
${CMAKE_CURRENT_LIST_DIR}/Classes/SDKHelper.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/Classes/SDKHelper.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/Classes/bindings/auto/jsb_SDKHelper_auto.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/Classes/bindings/auto/jsb_SDKHelper_auto.cpp
|
||||
)
|
||||
67
demo/native/engine/common/Classes/Game.cpp
Normal file
67
demo/native/engine/common/Classes/Game.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You
|
||||
shall not use Cocos Creator software for developing other software or tools
|
||||
that's used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to
|
||||
you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "Game.h"
|
||||
#include "bindings/auto/jsb_SDKHelper_auto.h" // 添加新生成的绑定类头文件
|
||||
|
||||
#ifndef GAME_NAME
|
||||
#define GAME_NAME "CocosGame";
|
||||
#endif
|
||||
|
||||
#ifndef SCRIPT_XXTEAKEY
|
||||
#define SCRIPT_XXTEAKEY "";
|
||||
#endif
|
||||
|
||||
Game::Game() = default;
|
||||
|
||||
int Game::init() {
|
||||
_windowInfo.title = GAME_NAME;
|
||||
// configurate window size
|
||||
// _windowInfo.height = 600;
|
||||
// _windowInfo.width = 800;
|
||||
|
||||
#if CC_DEBUG
|
||||
_debuggerInfo.enabled = true;
|
||||
#else
|
||||
_debuggerInfo.enabled = false;
|
||||
#endif
|
||||
_debuggerInfo.port = 6086;
|
||||
_debuggerInfo.address = "0.0.0.0";
|
||||
_debuggerInfo.pauseOnStart = false;
|
||||
|
||||
_xxteaKey = SCRIPT_XXTEAKEY;
|
||||
se::ScriptEngine::getInstance()->addRegisterCallback(register_all_SDKHelper); // 注册
|
||||
|
||||
BaseGame::init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Game::onPause() { BaseGame::onPause(); }
|
||||
|
||||
void Game::onResume() { BaseGame::onResume(); }
|
||||
|
||||
void Game::onClose() { BaseGame::onClose(); }
|
||||
|
||||
CC_REGISTER_APPLICATION(Game);
|
||||
44
demo/native/engine/common/Classes/Game.h
Normal file
44
demo/native/engine/common/Classes/Game.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You
|
||||
shall not use Cocos Creator software for developing other software or tools
|
||||
that's used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to
|
||||
you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "cocos/cocos.h"
|
||||
|
||||
/**
|
||||
@brief The cocos2d Application.
|
||||
|
||||
The reason for implement as private inheritance is to hide some interface call
|
||||
by Director.
|
||||
*/
|
||||
class Game : public cc::BaseGame {
|
||||
public:
|
||||
Game();
|
||||
int init() override;
|
||||
// bool init() override;
|
||||
void onPause() override;
|
||||
void onResume() override;
|
||||
void onClose() override;
|
||||
};
|
||||
38
demo/native/engine/common/Classes/JNIAndroid/JniTools.cpp
Normal file
38
demo/native/engine/common/Classes/JNIAndroid/JniTools.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// JniTools.cpp
|
||||
// kungpowGame
|
||||
//
|
||||
// Created by GongXH on 2021/3/26.
|
||||
//
|
||||
|
||||
#include "JniTools.h"
|
||||
#include "../SDKHelper.h"
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
#include <java/jni/JniHelper.h>
|
||||
#include "application/ApplicationManager.h"
|
||||
using namespace cc;
|
||||
|
||||
#define KUNPO_HELPER "com/kunpo/KunpoHelper"
|
||||
|
||||
std::string JniTools::getVersionCode() {
|
||||
return JniHelper::callStaticStringMethod(KUNPO_HELPER,"getVersionCode");
|
||||
}
|
||||
|
||||
int JniTools::getBuildCode() {
|
||||
return JniHelper::callStaticIntMethod(KUNPO_HELPER,"getBuildCode");
|
||||
}
|
||||
|
||||
#pragma -mark java回调c++
|
||||
#if (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT void Java_com_kunpo_KunpoHelper_CallJS(JNIEnv* env, jclass thiz, jstring jsjson)
|
||||
{
|
||||
std::string json = JniHelper::jstring2string(jsjson);
|
||||
CC_CURRENT_ENGINE()->getScheduler()->performFunctionInCocosThread([=]() {
|
||||
KunpoSDK::SDKHelper::getInstance()->callJS(json.c_str());
|
||||
});
|
||||
}
|
||||
}
|
||||
#endif
|
||||
18
demo/native/engine/common/Classes/JNIAndroid/JniTools.h
Normal file
18
demo/native/engine/common/Classes/JNIAndroid/JniTools.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// JniTools.hpp
|
||||
// ZumaGame
|
||||
//
|
||||
// Created by GongXH on 2021/3/26.
|
||||
//
|
||||
|
||||
#ifndef JniTools_hpp
|
||||
#define JniTools_hpp
|
||||
#include "cocos.h"
|
||||
class JniTools
|
||||
{
|
||||
public:
|
||||
//调用Java的方法
|
||||
static std::string getVersionCode();
|
||||
static int getBuildCode();
|
||||
};
|
||||
#endif /* JniTools_hpp */
|
||||
65
demo/native/engine/common/Classes/SDKHelper.cpp
Normal file
65
demo/native/engine/common/Classes/SDKHelper.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-03-21
|
||||
* @Description:
|
||||
*/
|
||||
#include "SDKHelper.h"
|
||||
#if (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#include "JNIAndroid/JniTools.h"
|
||||
#elif (CC_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
#endif
|
||||
|
||||
using namespace KunpoSDK;
|
||||
namespace KunpoSDK {
|
||||
}
|
||||
|
||||
static SDKHelper helper;
|
||||
|
||||
SDKHelper * SDKHelper::getInstance() {
|
||||
return &helper;
|
||||
}
|
||||
|
||||
SDKHelper::SDKHelper() {
|
||||
|
||||
}
|
||||
|
||||
/** 获取系统信息 */
|
||||
void SDKHelper::getSystemInfo() {
|
||||
#if (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// return JniTools::getSystemInfo();
|
||||
#elif (CC_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string SDKHelper::getVersionCode() {
|
||||
CC_LOG_DEBUG("SDKHelper 获取版本号");
|
||||
#if (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
return JniTools::getVersionCode();
|
||||
#elif (CC_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
#endif
|
||||
|
||||
return "0.0.1";
|
||||
}
|
||||
|
||||
int SDKHelper::getBuildCode() {
|
||||
CC_LOG_DEBUG("SDKHelper 获取Build号");
|
||||
#if (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
return JniTools::getBuildCode();
|
||||
#elif (CC_PLATFORM == CC_PLATFORM_IOS)
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SDKHelper::callJS(const char *jsonString) {
|
||||
se::Value callJsHandler;
|
||||
if (se::ScriptEngine::getInstance()->getGlobalObject()->getProperty("KunpoNativeCallJsHandler", &callJsHandler) && callJsHandler.isObject()) {
|
||||
se::ValueArray args;
|
||||
args.push_back(se::Value(jsonString));
|
||||
callJsHandler.toObject()->call(args, callJsHandler.toObject());
|
||||
}
|
||||
}
|
||||
34
demo/native/engine/common/Classes/SDKHelper.h
Normal file
34
demo/native/engine/common/Classes/SDKHelper.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @Author: Gongxh
|
||||
* @Date: 2025-03-21
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "cocos/cocos.h"
|
||||
|
||||
namespace KunpoSDK {
|
||||
|
||||
class SDKHelper {
|
||||
public:
|
||||
/** 单例 */
|
||||
static SDKHelper * getInstance();
|
||||
|
||||
SDKHelper();
|
||||
|
||||
/** 获取系统信息 */
|
||||
void getSystemInfo();
|
||||
/** 获取版本号 */
|
||||
std::string getVersionCode();
|
||||
/** 获取build号 */
|
||||
int getBuildCode();
|
||||
|
||||
/**
|
||||
* c++ 回调 js
|
||||
* 参数:jsonString 格式 { function: string, args: string }
|
||||
*/
|
||||
void callJS(const char* jsonString);
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
// clang-format off
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.0
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4101)
|
||||
#endif
|
||||
|
||||
|
||||
#define SWIG_STD_MOVE(OBJ) std::move(OBJ)
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "bindings/jswrapper/SeApi.h"
|
||||
#include "bindings/manual/jsb_conversions.h"
|
||||
#include "bindings/manual/jsb_global.h"
|
||||
|
||||
|
||||
#include "jsb_SDKHelper_auto.h"
|
||||
|
||||
|
||||
|
||||
se::Class* __jsb_KunpoSDK_SDKHelper_class = nullptr;
|
||||
se::Object* __jsb_KunpoSDK_SDKHelper_proto = nullptr;
|
||||
SE_DECLARE_FINALIZE_FUNC(js_delete_KunpoSDK_SDKHelper)
|
||||
|
||||
static bool js_KunpoSDK_SDKHelper_getInstance_static(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
KunpoSDK::SDKHelper *result = 0 ;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
result = (KunpoSDK::SDKHelper *)KunpoSDK::SDKHelper::getInstance();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_KunpoSDK_SDKHelper_getInstance_static)
|
||||
|
||||
static bool js_new_KunpoSDK_SDKHelper(se::State& s) // NOLINT(readability-identifier-naming)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
|
||||
KunpoSDK::SDKHelper *result;
|
||||
result = (KunpoSDK::SDKHelper *)new KunpoSDK::SDKHelper();
|
||||
|
||||
|
||||
auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result);
|
||||
s.thisObject()->setPrivateObject(ptr);
|
||||
return true;
|
||||
}
|
||||
SE_BIND_CTOR(js_new_KunpoSDK_SDKHelper, __jsb_KunpoSDK_SDKHelper_class, js_delete_KunpoSDK_SDKHelper)
|
||||
|
||||
static bool js_KunpoSDK_SDKHelper_getSystemInfo(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
KunpoSDK::SDKHelper *arg1 = (KunpoSDK::SDKHelper *) NULL ;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<KunpoSDK::SDKHelper>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
(arg1)->getSystemInfo();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_KunpoSDK_SDKHelper_getSystemInfo)
|
||||
|
||||
static bool js_KunpoSDK_SDKHelper_getVersionCode(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
KunpoSDK::SDKHelper *arg1 = (KunpoSDK::SDKHelper *) NULL ;
|
||||
std::string result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<KunpoSDK::SDKHelper>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (arg1)->getVersionCode();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_KunpoSDK_SDKHelper_getVersionCode)
|
||||
|
||||
static bool js_KunpoSDK_SDKHelper_getBuildCode(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
KunpoSDK::SDKHelper *arg1 = (KunpoSDK::SDKHelper *) NULL ;
|
||||
int result;
|
||||
|
||||
if(argc != 0) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<KunpoSDK::SDKHelper>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (int)(arg1)->getBuildCode();
|
||||
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_KunpoSDK_SDKHelper_getBuildCode)
|
||||
|
||||
static bool js_KunpoSDK_SDKHelper_callJS(se::State& s)
|
||||
{
|
||||
CC_UNUSED bool ok = true;
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
KunpoSDK::SDKHelper *arg1 = (KunpoSDK::SDKHelper *) NULL ;
|
||||
char *arg2 = (char *) NULL ;
|
||||
ccstd::string temp2 ;
|
||||
|
||||
if(argc != 1) {
|
||||
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
|
||||
return false;
|
||||
}
|
||||
arg1 = SE_THIS_OBJECT<KunpoSDK::SDKHelper>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &temp2);
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = (char *) temp2.c_str();
|
||||
(arg1)->callJS((char const *)arg2);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FUNC(js_KunpoSDK_SDKHelper_callJS)
|
||||
|
||||
static bool js_delete_KunpoSDK_SDKHelper(se::State& s)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
SE_BIND_FINALIZE_FUNC(js_delete_KunpoSDK_SDKHelper)
|
||||
|
||||
bool js_register_KunpoSDK_SDKHelper(se::Object* obj) {
|
||||
auto* cls = se::Class::create("SDKHelper", obj, nullptr, _SE(js_new_KunpoSDK_SDKHelper));
|
||||
|
||||
cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE);
|
||||
|
||||
cls->defineFunction("getSystemInfo", _SE(js_KunpoSDK_SDKHelper_getSystemInfo));
|
||||
cls->defineFunction("getVersionCode", _SE(js_KunpoSDK_SDKHelper_getVersionCode));
|
||||
cls->defineFunction("getBuildCode", _SE(js_KunpoSDK_SDKHelper_getBuildCode));
|
||||
cls->defineFunction("callJS", _SE(js_KunpoSDK_SDKHelper_callJS));
|
||||
|
||||
|
||||
cls->defineStaticFunction("getInstance", _SE(js_KunpoSDK_SDKHelper_getInstance_static));
|
||||
|
||||
|
||||
cls->defineFinalizeFunction(_SE(js_delete_KunpoSDK_SDKHelper));
|
||||
|
||||
|
||||
cls->install();
|
||||
JSBClassType::registerClass<KunpoSDK::SDKHelper>(cls);
|
||||
|
||||
__jsb_KunpoSDK_SDKHelper_proto = cls->getProto();
|
||||
__jsb_KunpoSDK_SDKHelper_class = cls;
|
||||
se::ScriptEngine::getInstance()->clearException();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool register_all_SDKHelper(se::Object* obj) {
|
||||
// Get the ns
|
||||
se::Value nsVal;
|
||||
if (!obj->getProperty("KunpoSDK", &nsVal, true))
|
||||
{
|
||||
se::HandleObject jsobj(se::Object::createPlainObject());
|
||||
nsVal.setObject(jsobj);
|
||||
obj->setProperty("KunpoSDK", nsVal);
|
||||
}
|
||||
se::Object* ns = nsVal.toObject();
|
||||
/* Register classes */
|
||||
js_register_KunpoSDK_SDKHelper(ns);
|
||||
|
||||
/* Register global variables & global functions */
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
#pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
// clang-format on
|
||||
@@ -0,0 +1,51 @@
|
||||
// clang-format off
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.0
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/****************************************************************************
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include "bindings/jswrapper/SeApi.h"
|
||||
#include "bindings/manual/jsb_conversions.h"
|
||||
#include "cocos/cocos.h"
|
||||
|
||||
#include "../../SDKHelper.h" // 添加这行,%include 指令表示让 swig 解析此文件,并且为此文件中的类生成绑定代码。
|
||||
|
||||
|
||||
|
||||
bool register_all_SDKHelper(se::Object* obj);
|
||||
|
||||
|
||||
JSB_REGISTER_OBJECT_TYPE(KunpoSDK::SDKHelper);
|
||||
extern se::Object *__jsb_KunpoSDK_SDKHelper_proto; // NOLINT
|
||||
extern se::Class * __jsb_KunpoSDK_SDKHelper_class; // NOLINT
|
||||
|
||||
// clang-format on
|
||||
1
demo/native/engine/common/cocos-version.json
Normal file
1
demo/native/engine/common/cocos-version.json
Normal file
@@ -0,0 +1 @@
|
||||
{"version":"3.8.6","skipCheck":false}
|
||||
20
demo/native/engine/common/xr.cmake
Normal file
20
demo/native/engine/common/xr.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
include(${COCOS_X_PATH}/cmake/predefine.cmake)
|
||||
|
||||
if(NOT DEFINED XR_COMMON_SOURCES)
|
||||
set(XR_COMMON_SOURCES)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED XR_LIBS)
|
||||
set(XR_LIBS)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED XR_COMMON_PATH)
|
||||
set(XR_COMMON_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../extensions/xr-plugin/common)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED XR_LIBRARY_PATH)
|
||||
set(XR_LIBRARY_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../extensions/xr-plugin/platforms)
|
||||
endif()
|
||||
|
||||
include(${XR_COMMON_PATH}/xr.cmake)
|
||||
Reference in New Issue
Block a user