mirror of
				https://github.com/Gongxh0901/kunpolibrary
				synced 2025-10-30 19:05:44 +00:00 
			
		
		
		
	仓库中添加内置的demo
This commit is contained in:
		| @@ -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 | ||||
		Reference in New Issue
	
	Block a user