diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index db7773e958..7f7bd950f7 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -834,8 +834,6 @@ if(WINDOWS) cocos_source_files( cocos/platform/win32/compat cocos/platform/win32/compat/stdint.h - cocos/platform/win32/inet_pton_mingw.cpp - cocos/platform/win32/inet_pton_mingw.h ) cocos_source_files(MODULE ccfilesystem cocos/platform/win32/FileUtils-win32.cpp @@ -2446,12 +2444,12 @@ cocos_source_files( ) #### storage -cocos_source_files( - cocos/storage/local-storage/LocalStorage.cpp - cocos/storage/local-storage/LocalStorage.h -) - -if(ANDROID) +if(NOT ANDROID) + cocos_source_files( + cocos/storage/local-storage/LocalStorage.cpp + cocos/storage/local-storage/LocalStorage.h + ) +else() cocos_source_files( cocos/storage/local-storage/LocalStorage-android.cpp ) diff --git a/native/cocos/audio/android/AudioDecoderWav.cpp b/native/cocos/audio/android/AudioDecoderWav.cpp index 032a362894..693819882d 100644 --- a/native/cocos/audio/android/AudioDecoderWav.cpp +++ b/native/cocos/audio/android/AudioDecoderWav.cpp @@ -29,8 +29,6 @@ THE SOFTWARE. #include "audio/android/tinysndfile.h" #include "platform/FileUtils.h" -#include - namespace cc { AudioDecoderWav::AudioDecoderWav() { @@ -82,7 +80,7 @@ bool AudioDecoderWav::decodeToPcm() { size_t bufSize = sizeof(int16_t) * info.frames * info.channels; auto * buf = static_cast(malloc(bufSize)); sf_count_t readFrames = sf_readf_short(handle, reinterpret_cast(buf), info.frames); - assert(readFrames == info.frames); + CC_ASSERT(readFrames == info.frames); _result.pcmBuffer->insert(_result.pcmBuffer->end(), buf, buf + bufSize); _result.numChannels = info.channels; diff --git a/native/cocos/audio/apple/AudioPlayer.mm b/native/cocos/audio/apple/AudioPlayer.mm index 05832048c9..f04d79cf21 100644 --- a/native/cocos/audio/apple/AudioPlayer.mm +++ b/native/cocos/audio/apple/AudioPlayer.mm @@ -207,7 +207,7 @@ bool AudioPlayer::play2d() { ALint state; alGetSourcei(_alSource, AL_SOURCE_STATE, &state); - assert(state == AL_PLAYING); + CC_ASSERT(state == AL_PLAYING); _ready = true; ret = true; } while (false); diff --git a/native/cocos/base/Macros.h b/native/cocos/base/Macros.h index cd588c2b38..0538acd903 100644 --- a/native/cocos/base/Macros.h +++ b/native/cocos/base/Macros.h @@ -31,7 +31,7 @@ #include // To include uint8_t, uint16_t and so on. -#include +#include #define CC_ASSERT(cond) assert(cond) #if (CC_PLATFORM == CC_PLATFORM_WINDOWS) diff --git a/native/cocos/base/ZipUtils.cpp b/native/cocos/base/ZipUtils.cpp index 05ccef2aa1..ff850cf468 100644 --- a/native/cocos/base/ZipUtils.cpp +++ b/native/cocos/base/ZipUtils.cpp @@ -38,7 +38,6 @@ #include #include -#include #include #include "base/Data.h" #include "base/Locked.h" diff --git a/native/cocos/base/job-system/job-system-dummy/DummyJobGraph.cpp b/native/cocos/base/job-system/job-system-dummy/DummyJobGraph.cpp index 761dda2640..f143589cf0 100644 --- a/native/cocos/base/job-system/job-system-dummy/DummyJobGraph.cpp +++ b/native/cocos/base/job-system/job-system-dummy/DummyJobGraph.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "DummyJobGraph.h" -#include +#include "base/Macros.h" #define DUMMY_GRAPH_NODE_CHUNK_SIZE 64 @@ -47,7 +47,7 @@ void DummyGraphNode::reset() { } void DummyGraphNode::succeed(DummyGraphNode *other) { - assert(this != other); + CC_ASSERT(this != other); // Run after other this->_predecessors.emplace(other); other->_successors.emplace(this); @@ -59,7 +59,7 @@ void DummyGraphNode::precede(DummyGraphNode *other) { } void DummyGraphNode::allocChunk() { - assert(freeList == nullptr); + CC_ASSERT(freeList == nullptr); freeList = ccnew DummyGraphNode[DUMMY_GRAPH_NODE_CHUNK_SIZE](); allocatedChunks.emplace_back(freeList); for (auto i = 0; i < DUMMY_GRAPH_NODE_CHUNK_SIZE - 1; i++) { diff --git a/native/cocos/base/threading/MessageQueue.cpp b/native/cocos/base/threading/MessageQueue.cpp index aa0600df78..b083235376 100644 --- a/native/cocos/base/threading/MessageQueue.cpp +++ b/native/cocos/base/threading/MessageQueue.cpp @@ -193,7 +193,7 @@ uint8_t *MessageQueue::allocateImpl(uint32_t allocatedSize, uint32_t const reque if (_immediateMode) { pushMessages(); pullMessages(); - assert(_reader.newMessageCount == 2); + CC_ASSERT(_reader.newMessageCount == 2); executeMessages(); executeMessages(); } @@ -244,7 +244,7 @@ Message *MessageQueue::readMessage() noexcept { Message *const msg = _reader.lastMessage->getNext(); _reader.lastMessage = msg; --_reader.newMessageCount; - assert(msg); + CC_ASSERT(msg); return msg; } diff --git a/native/cocos/base/threading/MessageQueue.h b/native/cocos/base/threading/MessageQueue.h index f1a918a76b..38e3bca993 100644 --- a/native/cocos/base/threading/MessageQueue.h +++ b/native/cocos/base/threading/MessageQueue.h @@ -230,7 +230,7 @@ template std::enable_if_t::value, T *> MessageQueue::allocate(uint32_t const count) noexcept { uint32_t const requestSize = sizeof(T) * count; - assert(requestSize); + CC_ASSERT(requestSize); uint32_t allocatedSize = 0; uint8_t *const allocatedMemory = allocateImpl(allocatedSize, requestSize); _writer.lastMessage->_next = reinterpret_cast(_writer.currentMemoryChunk + _writer.offset); diff --git a/native/cocos/base/threading/ThreadPool.cpp b/native/cocos/base/threading/ThreadPool.cpp index 2e33939fe4..08f789bc9f 100644 --- a/native/cocos/base/threading/ThreadPool.cpp +++ b/native/cocos/base/threading/ThreadPool.cpp @@ -60,7 +60,7 @@ void ThreadPool::stop() { } void ThreadPool::addThread() { - assert(_workers.size() < MAX_THREAD_COUNT); + CC_ASSERT(_workers.size() < MAX_THREAD_COUNT); auto workerLoop = [this]() { while (_running) { diff --git a/native/cocos/base/threading/ThreadPool.h b/native/cocos/base/threading/ThreadPool.h index 7ac13936e5..d24606eb27 100644 --- a/native/cocos/base/threading/ThreadPool.h +++ b/native/cocos/base/threading/ThreadPool.h @@ -26,12 +26,12 @@ #pragma once #include -#include #include #include #include #include #include "Event.h" +#include "base/Macros.h" #include "base/std/container/list.h" #include "concurrentqueue/concurrentqueue.h" @@ -71,14 +71,14 @@ private: template auto ThreadPool::dispatchTask(Function &&func, Args &&...args) -> std::future(args)...))> { - assert(_running); + CC_ASSERT(_running); using ReturnType = decltype(func(std::forward(args)...)); auto task = std::make_shared>(std::bind(std::forward(func), std::forward(args)...)); bool const succeed = _tasks.enqueue([task]() { (*task)(); }); - assert(succeed); + CC_ASSERT(succeed); _event.signal(); return task->get_future(); } diff --git a/native/cocos/bindings/event/EventDispatcher.cpp b/native/cocos/bindings/event/EventDispatcher.cpp index 0df4881f8b..c29eadf6fd 100644 --- a/native/cocos/bindings/event/EventDispatcher.cpp +++ b/native/cocos/bindings/event/EventDispatcher.cpp @@ -138,7 +138,7 @@ void EventDispatcher::dispatchTouchEvent(const TouchEvent &touchEvent) { eventName = "onTouchCancel"; break; default: - assert(false); + CC_ASSERT(false); break; } @@ -189,7 +189,7 @@ void EventDispatcher::dispatchMouseEvent(const MouseEvent &mouseEvent) { jsFunctionName = "onMouseWheel"; break; default: - assert(false); + CC_ASSERT(false); break; } @@ -215,7 +215,7 @@ void EventDispatcher::dispatchKeyboardEvent(const KeyboardEvent &keyboardEvent) eventName = "onKeyUp"; break; default: - assert(false); + CC_ASSERT(false); break; } @@ -271,7 +271,7 @@ void EventDispatcher::dispatchOrientationChangeEvent(int orientation) { } se::AutoHandleScope scope; - assert(inited); + CC_ASSERT(inited); if (jsOrientationEventObj == nullptr) { jsOrientationEventObj = se::Object::createPlainObject(); @@ -337,7 +337,7 @@ void EventDispatcher::doDispatchEvent(const char *eventName, const char *jsFunct } se::AutoHandleScope scope; - assert(inited); + CC_ASSERT(inited); se::Value func; __jsbObj->getProperty(jsFunctionName, &func); @@ -357,7 +357,7 @@ uint32_t EventDispatcher::addCustomEventListener(const ccstd::string &eventName, listeners.emplace(eventName, newNode); } else { Node *node = iter->second; - assert(node != nullptr); + CC_ASSERT(node != nullptr); Node *prev = nullptr; while (node != nullptr) { prev = node; diff --git a/native/cocos/bindings/jswrapper/HandleObject.cpp b/native/cocos/bindings/jswrapper/HandleObject.cpp index f3034254a3..62dfb2ef26 100644 --- a/native/cocos/bindings/jswrapper/HandleObject.cpp +++ b/native/cocos/bindings/jswrapper/HandleObject.cpp @@ -33,7 +33,7 @@ HandleObject::HandleObject(Object *obj) : _obj(obj) { if (_obj != nullptr) { // se::HandleObject could not be used for native binding object. - assert(!_obj->_getClass()); + CC_ASSERT(!_obj->_getClass()); _obj->root(); } } diff --git a/native/cocos/bindings/jswrapper/PrivateObject.h b/native/cocos/bindings/jswrapper/PrivateObject.h index 08c6332c1d..ac90b735f3 100644 --- a/native/cocos/bindings/jswrapper/PrivateObject.h +++ b/native/cocos/bindings/jswrapper/PrivateObject.h @@ -25,7 +25,6 @@ #pragma once -#include #include #include #include @@ -58,7 +57,7 @@ public: virtual const char *getName() const = 0; virtual void * getRaw() const = 0; virtual void allowDestroyInGC() const { - assert(false); + CC_ASSERT(false); } virtual void tryAllowDestroyInGC() const {} @@ -149,7 +148,7 @@ public: } void *getRaw() const override { - //assert(_validate); + //CC_ASSERT(_validate); return _ptr; } @@ -164,12 +163,12 @@ inline std::shared_ptr TypedPrivateObject::share() { if (isSharedPtr()) { return reinterpret_cast *>(this)->getData(); } - assert(false); + CC_ASSERT(false); return std::shared_ptr(nullptr); } template inline cc::IntrusivePtr &TypedPrivateObject::ccShared() { - assert(isCCShared()); + CC_ASSERT(isCCShared()); return reinterpret_cast *>(this)->_ptr; } @@ -180,7 +179,7 @@ inline void inHeap(void *ptr) { auto anchor = reinterpret_cast(&a); auto p = reinterpret_cast(ptr); // must be in heaps - assert(abs(anchor - p) > r); + CC_ASSERT(abs(anchor - p) > r); } #endif diff --git a/native/cocos/bindings/jswrapper/Value.cpp b/native/cocos/bindings/jswrapper/Value.cpp index 3fd3c3b625..2cfbefd8ef 100644 --- a/native/cocos/bindings/jswrapper/Value.cpp +++ b/native/cocos/bindings/jswrapper/Value.cpp @@ -429,12 +429,12 @@ uint32_t Value::toUint32() const { } int64_t Value::toInt64() const { - assert(isBigInt() || isNumber()); + CC_ASSERT(isBigInt() || isNumber()); return _type == Type::BigInt ? _u._bigint : CONVERT_TO_TYPE(int64_t); } uint64_t Value::toUint64() const { - assert(isBigInt() || isNumber()); + CC_ASSERT(isBigInt() || isNumber()); return _type == Type::BigInt ? static_cast(_u._bigint) : CONVERT_TO_TYPE(uint64_t); } @@ -443,7 +443,7 @@ float Value::toFloat() const { } double Value::toDouble() const { - assert(_type == Type::Number || _type == Type::Boolean || _type == Type::BigInt || _type == Type::String); + CC_ASSERT(_type == Type::Number || _type == Type::Boolean || _type == Type::BigInt || _type == Type::String); if (LIKELY(_type == Type::Number)) { return _u._number; } @@ -460,12 +460,12 @@ double Value::toDouble() const { } bool Value::toBoolean() const { - assert(_type == Type::Boolean); + CC_ASSERT(_type == Type::Boolean); return _u._boolean; } const ccstd::string &Value::toString() const { - assert(_type == Type::String); + CC_ASSERT(_type == Type::String); return *_u._string; } @@ -488,7 +488,7 @@ ccstd::string Value::toStringForce() const { } else if (_type == Type::Undefined) { ss << "undefined"; } else { - assert(false); + CC_ASSERT(false); ss << "[[BadValueType]]"; } return ss.str(); diff --git a/native/cocos/bindings/jswrapper/ValueArrayPool.cpp b/native/cocos/bindings/jswrapper/ValueArrayPool.cpp index f5d6cb2a0f..f819470bd1 100644 --- a/native/cocos/bindings/jswrapper/ValueArrayPool.cpp +++ b/native/cocos/bindings/jswrapper/ValueArrayPool.cpp @@ -25,7 +25,7 @@ ****************************************************************************/ #include "ValueArrayPool.h" -#include +#include "base/Macros.h" #include "config.h" namespace se { @@ -45,13 +45,13 @@ ValueArray &ValueArrayPool::get(uint32_t argc) { if (SE_UNLIKELY(_depth >= _pools.size())) { auto *ptr = _pools.data(); _pools.resize(_depth + 1); - assert(_pools.data() == ptr); + CC_ASSERT(_pools.data() == ptr); initPool(_depth); } - assert(argc <= MAX_ARGS); + CC_ASSERT(argc <= MAX_ARGS); auto &ret = _pools[_depth][argc]; - assert(ret.size() == argc); + CC_ASSERT(ret.size() == argc); return ret; } diff --git a/native/cocos/bindings/jswrapper/v8/Base.h b/native/cocos/bindings/jswrapper/v8/Base.h index b94fb5d97b..8e60cf3022 100644 --- a/native/cocos/bindings/jswrapper/v8/Base.h +++ b/native/cocos/bindings/jswrapper/v8/Base.h @@ -34,7 +34,6 @@ #include "v8.h" -#include #include // Resolves that memset, memcpy aren't found while APP_PLATFORM >= 22 on Android #include // for std::find #include diff --git a/native/cocos/bindings/jswrapper/v8/Class.cpp b/native/cocos/bindings/jswrapper/v8/Class.cpp index a556e52086..f7d2e4d60a 100644 --- a/native/cocos/bindings/jswrapper/v8/Class.cpp +++ b/native/cocos/bindings/jswrapper/v8/Class.cpp @@ -229,7 +229,7 @@ bool Class::defineStaticProperty(const char *name, v8::AccessorNameGetterCallbac } bool Class::defineFinalizeFunction(V8FinalizeFunc finalizeFunc) { - assert(finalizeFunc != nullptr); + CC_ASSERT(finalizeFunc != nullptr); _finalizeFunc = finalizeFunc; return true; } @@ -249,7 +249,7 @@ bool Class::defineFinalizeFunction(V8FinalizeFunc finalizeFunc) { v8::Local Class::_createJSObjectWithClass(Class *cls) { //NOLINT v8::MaybeLocal ret = cls->_ctorTemplate.Get(__isolate)->InstanceTemplate()->NewInstance(__isolate->GetCurrentContext()); - assert(!ret.IsEmpty()); + CC_ASSERT(!ret.IsEmpty()); return ret.ToLocalChecked(); } diff --git a/native/cocos/bindings/jswrapper/v8/HelperMacros.h b/native/cocos/bindings/jswrapper/v8/HelperMacros.h index 1b2a2ef339..0eac8285f8 100644 --- a/native/cocos/bindings/jswrapper/v8/HelperMacros.h +++ b/native/cocos/bindings/jswrapper/v8/HelperMacros.h @@ -35,6 +35,7 @@ #include "../ValueArrayPool.h" #include "../config.h" #include "base/Log.h" +#include "base/Macros.h" #include "base/std/container/string.h" //#define RECORD_JSB_INVOKING @@ -226,7 +227,7 @@ void printJSBInvokeAtFrame(int n); do { \ if (!(cond)) { \ SE_LOGE("ASSERT (" __FILE__ ", " SE_QUOTEME(__LINE__) "): " fmt "\n", ##__VA_ARGS__); \ - assert(false); \ + CC_ASSERT(false); \ } \ } while (false) diff --git a/native/cocos/bindings/jswrapper/v8/Object.cpp b/native/cocos/bindings/jswrapper/v8/Object.cpp index 9b378bad09..178e0202b1 100644 --- a/native/cocos/bindings/jswrapper/v8/Object.cpp +++ b/native/cocos/bindings/jswrapper/v8/Object.cpp @@ -257,7 +257,7 @@ Object *Object::createTypedArray(TypedArrayType type, const void *data, size_t b arr = v8::Float64Array::New(jsobj, 0, byteLength / 8); break; default: - assert(false); // Should never go here. + CC_ASSERT(false); // Should never go here. break; } @@ -288,7 +288,7 @@ Object *Object::createTypedArrayWithBuffer(TypedArrayType type, const Object *ob } v8::Local typedArray; - assert(obj->isArrayBuffer()); + CC_ASSERT(obj->isArrayBuffer()); v8::Local jsobj = obj->_getJSObject().As(); switch (type) { case TypedArrayType::INT8: @@ -316,7 +316,7 @@ Object *Object::createTypedArrayWithBuffer(TypedArrayType type, const Object *ob typedArray = v8::Float64Array::New(jsobj, offset, byteLength / 8); break; default: - assert(false); // Should never go here. + CC_ASSERT(false); // Should never go here. break; } @@ -349,7 +349,7 @@ bool Object::init(Class *cls, v8::Local obj) { _obj.setFinalizeCallback(nativeObjectFinalizeHook); if (__objectMap) { - assert(__objectMap->find(this) == __objectMap->end()); + CC_ASSERT(__objectMap->find(this) == __objectMap->end()); __objectMap->emplace(this, nullptr); } @@ -363,7 +363,7 @@ bool Object::init(Class *cls, v8::Local obj) { } bool Object::getProperty(const char *name, Value *data, bool cachePropertyName) { - assert(data != nullptr); + CC_ASSERT(data != nullptr); data->setUndefined(); v8::HandleScope handleScope(__isolate); @@ -531,7 +531,7 @@ Object::TypedArrayType Object::getTypedArrayType() const { } bool Object::getTypedArrayData(uint8_t **ptr, size_t *length) const { - assert(isTypedArray()); + CC_ASSERT(isTypedArray()); v8::Local obj = const_cast(this)->_obj.handle(__isolate); v8::Local arr = v8::Local::Cast(obj); const auto & backingStore = arr->Buffer()->GetBackingStore(); @@ -548,7 +548,7 @@ bool Object::isArrayBuffer() const { } bool Object::getArrayBufferData(uint8_t **ptr, size_t *length) const { - assert(isArrayBuffer()); + CC_ASSERT(isArrayBuffer()); v8::Local obj = const_cast(this)->_obj.handle(__isolate); v8::Local arrBuf = v8::Local::Cast(obj); const auto & backingStore = arrBuf->GetBackingStore(); @@ -561,9 +561,9 @@ bool Object::getArrayBufferData(uint8_t **ptr, size_t *length) const { } void Object::setPrivateObject(PrivateObjectBase *data) { - assert(_privateObject == nullptr); + CC_ASSERT(_privateObject == nullptr); #if CC_DEBUG - //assert(NativePtrToObjectMap::find(data->getRaw()) == NativePtrToObjectMap::end()); + //CC_ASSERT(NativePtrToObjectMap::find(data->getRaw()) == NativePtrToObjectMap::end()); if (data != nullptr) { auto it = NativePtrToObjectMap::find(data->getRaw()); if (it != NativePtrToObjectMap::end()) { @@ -572,7 +572,7 @@ void Object::setPrivateObject(PrivateObjectBase *data) { #if JSB_TRACK_OBJECT_CREATION SE_LOGE(" previous object created at %s\n", it->second->_objectCreationStackFrame.c_str()); #endif - assert(false); + CC_ASSERT(false); } } #endif @@ -669,7 +669,7 @@ bool Object::call(const ValueArray &args, Object *thisObject, Value *rval /* = n SE_REPORT_ERROR("Invoking function (%p) failed!", this); se::ScriptEngine::getInstance()->clearException(); - // assert(false); + // CC_ASSERT(false); return false; } @@ -698,8 +698,8 @@ bool Object::isArray() const { } bool Object::getArrayLength(uint32_t *length) const { - assert(isArray()); - assert(length != nullptr); + CC_ASSERT(isArray()); + CC_ASSERT(length != nullptr); auto *thiz = const_cast(this); v8::MaybeLocal lengthStr = ScriptEngine::getInstance()->_getStringPool().get(__isolate, "length"); @@ -729,8 +729,8 @@ bool Object::getArrayLength(uint32_t *length) const { } bool Object::getArrayElement(uint32_t index, Value *data) const { - assert(isArray()); - assert(data != nullptr); + CC_ASSERT(isArray()); + CC_ASSERT(data != nullptr); auto * thiz = const_cast(this); v8::MaybeLocal result = thiz->_obj.handle(__isolate)->Get(__isolate->GetCurrentContext(), index); @@ -743,7 +743,7 @@ bool Object::getArrayElement(uint32_t index, Value *data) const { } bool Object::setArrayElement(uint32_t index, const Value &data) { - assert(isArray()); + CC_ASSERT(isArray()); v8::Local jsval; internal::seToJsValue(__isolate, data, &jsval); @@ -753,7 +753,7 @@ bool Object::setArrayElement(uint32_t index, const Value &data) { } bool Object::getAllKeys(ccstd::vector *allKeys) const { - assert(allKeys != nullptr); + CC_ASSERT(allKeys != nullptr); auto * thiz = const_cast(this); v8::Local context = __isolate->GetCurrentContext(); v8::MaybeLocal keys = thiz->_obj.handle(__isolate)->GetOwnPropertyNames(context); @@ -788,7 +788,7 @@ Class *Object::_getClass() const { // NOLINT(readability-identifier-naming) } void Object::_setFinalizeCallback(V8FinalizeFunc finalizeCb) { // NOLINT(readability-identifier-naming) - assert(finalizeCb != nullptr); + CC_ASSERT(finalizeCb != nullptr); _finalizeCb = finalizeCb; } @@ -818,7 +818,7 @@ bool Object::strictEquals(Object *o) const { } bool Object::attachObject(Object *obj) { - assert(obj); + CC_ASSERT(obj); Object *global = ScriptEngine::getInstance()->getGlobalObject(); Value jsbVal; @@ -841,7 +841,7 @@ bool Object::attachObject(Object *obj) { } bool Object::detachObject(Object *obj) { - assert(obj); + CC_ASSERT(obj); Object *global = ScriptEngine::getInstance()->getGlobalObject(); Value jsbVal; diff --git a/native/cocos/bindings/jswrapper/v8/ObjectWrap.cpp b/native/cocos/bindings/jswrapper/v8/ObjectWrap.cpp index 2a17962e91..9a0fb784fc 100644 --- a/native/cocos/bindings/jswrapper/v8/ObjectWrap.cpp +++ b/native/cocos/bindings/jswrapper/v8/ObjectWrap.cpp @@ -56,13 +56,13 @@ ObjectWrap::~ObjectWrap() { if (persistent().IsEmpty()) { return; } - //cjh assert(persistent().IsNearDeath()); + //cjh CC_ASSERT(persistent().IsNearDeath()); persistent().ClearWeak(); persistent().Reset(); } bool ObjectWrap::init(v8::Local handle, Object *parent, bool registerWeak) { - assert(persistent().IsEmpty()); + CC_ASSERT(persistent().IsEmpty()); _parent = parent; _registerWeak = registerWeak; persistent().Reset(v8::Isolate::GetCurrent(), handle); @@ -78,14 +78,14 @@ void ObjectWrap::setFinalizeCallback(FinalizeFunc finalizeCb) { /*static*/ void *ObjectWrap::unwrap(v8::Local handle, uint32_t fieldIndex) { - assert(!handle.IsEmpty()); - assert(handle->InternalFieldCount() > 1); - assert(fieldIndex >= 0 && fieldIndex < 2); + CC_ASSERT(!handle.IsEmpty()); + CC_ASSERT(handle->InternalFieldCount() > 1); + CC_ASSERT(fieldIndex >= 0 && fieldIndex < 2); return handle->GetAlignedPointerFromInternalField(static_cast(fieldIndex)); } void ObjectWrap::wrap(void *nativeObj, uint32_t fieldIndex) { - assert(handle()->InternalFieldCount() > 1); - assert(fieldIndex >= 0 && fieldIndex < 2); + CC_ASSERT(handle()->InternalFieldCount() > 1); + CC_ASSERT(fieldIndex >= 0 && fieldIndex < 2); handle()->SetAlignedPointerInInternalField(static_cast(fieldIndex), nativeObj); } @@ -119,15 +119,15 @@ void ObjectWrap::makeWeak() { } void ObjectWrap::ref() { - assert(!persistent().IsEmpty()); + CC_ASSERT(!persistent().IsEmpty()); persistent().ClearWeak(); _refs++; } void ObjectWrap::unref() { - assert(!persistent().IsEmpty()); - assert(!persistent().IsWeak()); - assert(_refs > 0); + CC_ASSERT(!persistent().IsEmpty()); + CC_ASSERT(!persistent().IsWeak()); + CC_ASSERT(_refs > 0); if (--_refs == 0 && _registerWeak) { makeWeak(); } @@ -138,12 +138,12 @@ void ObjectWrap::weakCallback(const v8::WeakCallbackInfo &data) { Object *seObj = data.GetParameter(); ObjectWrap *wrap = &seObj->_getWrap(); - assert(wrap->_refs == 0); + CC_ASSERT(wrap->_refs == 0); wrap->_handle.Reset(); if (wrap->_finalizeCb != nullptr) { wrap->_finalizeCb(seObj); } else { - assert(false); + CC_ASSERT(false); } } diff --git a/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp b/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp index 703ee96a2d..02c90a1b31 100644 --- a/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp +++ b/native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp @@ -219,7 +219,7 @@ public: } bool ok = v8::V8::Initialize(); - assert(ok); + CC_ASSERT(ok); } ~ScriptEngineV8Context() { @@ -275,7 +275,7 @@ void ScriptEngine::onMessageCallback(v8::Local message, v8::Local msg = message->Get(); Value msgVal; internal::jsToSeValue(v8::Isolate::GetCurrent(), msg, &msgVal); - assert(msgVal.isString()); + CC_ASSERT(msgVal.isString()); v8::ScriptOrigin origin = message->GetScriptOrigin(); Value resouceNameVal; internal::jsToSeValue(v8::Isolate::GetCurrent(), origin.ResourceName(), &resouceNameVal); @@ -463,7 +463,7 @@ void ScriptEngine::privateDataFinalize(PrivateObjectBase *privateObj) { Object::nativeObjectFinalizeHook(p->seObj); - assert(p->seObj->getRefCount() == 1); + CC_ASSERT(p->seObj->getRefCount() == 1); p->seObj->decRef(); @@ -704,7 +704,7 @@ void ScriptEngine::addAfterCleanupHook(const std::function &hook) { } void ScriptEngine::addRegisterCallback(RegisterCallback cb) { - assert(std::find(_registerCallbackArray.begin(), _registerCallbackArray.end(), cb) == _registerCallbackArray.end()); + CC_ASSERT(std::find(_registerCallbackArray.begin(), _registerCallbackArray.end(), cb) == _registerCallbackArray.end()); _registerCallbackArray.push_back(cb); } @@ -721,7 +721,7 @@ bool ScriptEngine::callRegisteredCallback() { for (auto cb : _permRegisterCallbackArray) { ok = cb(_globalObj); - assert(ok); + CC_ASSERT(ok); if (!ok) { break; } @@ -729,7 +729,7 @@ bool ScriptEngine::callRegisteredCallback() { for (auto cb : _registerCallbackArray) { ok = cb(_globalObj); - assert(ok); + CC_ASSERT(ok); if (!ok) { break; } @@ -759,7 +759,7 @@ bool ScriptEngine::start() { options.set_port(static_cast(_debuggerServerPort)); options.set_host_name(_debuggerServerAddr); bool ok = _env->inspector_agent()->Start(gSharedV8->platform, "", options); - assert(ok); + CC_ASSERT(ok); #endif } @@ -796,11 +796,11 @@ bool ScriptEngine::isValid() const { bool ScriptEngine::evalString(const char *script, uint32_t length /* = 0 */, Value *ret /* = nullptr */, const char *fileName /* = nullptr */) { if (_engineThreadId != std::this_thread::get_id()) { // `evalString` should run in main thread - assert(false); + CC_ASSERT(false); return false; } - assert(script != nullptr); + CC_ASSERT(script != nullptr); if (length == 0) { length = static_cast(strlen(script)); } @@ -979,7 +979,7 @@ bool ScriptEngine::runByteCodeFile(const ccstd::string &pathBc, Value *ret /* = codeBuffer[filesize] = '\0'; dummyCode = v8::String::NewFromUtf8(_isolate, codeBuffer.data(), v8::NewStringType::kNormal, filesize).ToLocalChecked(); - assert(dummyCode->Length() == filesize); + CC_ASSERT(dummyCode->Length() == filesize); } v8::ScriptCompiler::Source source(dummyCode, origin, v8CacheData); @@ -1021,8 +1021,8 @@ bool ScriptEngine::runByteCodeFile(const ccstd::string &pathBc, Value *ret /* = } bool ScriptEngine::runScript(const ccstd::string &path, Value *ret /* = nullptr */) { - assert(!path.empty()); - assert(_fileOperationDelegate.isValid()); + CC_ASSERT(!path.empty()); + CC_ASSERT(_fileOperationDelegate.isValid()); if (!cc::FileUtils::getInstance()->isFileExist(path)) { std::stringstream ss; @@ -1118,7 +1118,7 @@ bool ScriptEngine::callFunction(Object *targetObj, const char *funcName, uint32_ v8::TryCatch tryCatch(_isolate); #endif - assert(!funcVal.IsEmpty()); + CC_ASSERT(!funcVal.IsEmpty()); if (!funcVal.ToLocalChecked()->IsFunction()) { v8::String::Utf8Value funcStr(_isolate, funcVal.ToLocalChecked()); SE_REPORT_ERROR("%s is not a function: %s", funcName, *funcStr); diff --git a/native/cocos/bindings/jswrapper/v8/Utils.cpp b/native/cocos/bindings/jswrapper/v8/Utils.cpp index 18c35c06de..79cc410a03 100644 --- a/native/cocos/bindings/jswrapper/v8/Utils.cpp +++ b/native/cocos/bindings/jswrapper/v8/Utils.cpp @@ -44,7 +44,7 @@ void jsToSeArgs(const v8::FunctionCallbackInfo &v8args, ValueArray &o } void seToJsArgs(v8::Isolate *isolate, const ValueArray &args, v8::Local *outArr) { - assert(outArr != nullptr); + CC_ASSERT(outArr != nullptr); uint32_t i = 0; for (const auto &data : args) { v8::Local &jsval = outArr[i]; @@ -54,7 +54,7 @@ void seToJsArgs(v8::Isolate *isolate, const ValueArray &args, v8::Local *outJsVal) { - assert(outJsVal != nullptr); + CC_ASSERT(outJsVal != nullptr); switch (v.getType()) { case Value::Type::Number: *outJsVal = v8::Number::New(isolate, v.toDouble()); @@ -83,13 +83,13 @@ void seToJsValue(v8::Isolate *isolate, const Value &v, v8::Local *out *outJsVal = v8::BigInt::New(isolate, v.toInt64()); break; default: - assert(false); + CC_ASSERT(false); break; } } void jsToSeValue(v8::Isolate *isolate, v8::Local jsval, Value *v) { - assert(v != nullptr); + CC_ASSERT(v != nullptr); v8::HandleScope handleScope(isolate); if (jsval->IsUndefined()) { @@ -156,7 +156,7 @@ void setReturnValueTemplate(const Value &data, const T &argv) { argv.GetReturnValue().Set(v8::Number::New(argv.GetIsolate(), static_cast(data.toInt64()))); } else if (data.getType() == Value::Type::String) { v8::MaybeLocal value = v8::String::NewFromUtf8(argv.GetIsolate(), data.toString().c_str(), v8::NewStringType::kNormal); - assert(!value.IsEmpty()); + CC_ASSERT(!value.IsEmpty()); argv.GetReturnValue().Set(value.ToLocalChecked()); } else if (data.getType() == Value::Type::Boolean) { argv.GetReturnValue().Set(v8::Boolean::New(argv.GetIsolate(), data.toBoolean())); @@ -181,7 +181,7 @@ bool hasPrivate(v8::Isolate * /*isolate*/, v8::Local value) { void setPrivate(v8::Isolate *isolate, ObjectWrap &wrap, PrivateObjectBase *data, Object *thizObj, PrivateData **outInternalData) { v8::Local obj = wrap.handle(isolate); int c = obj->InternalFieldCount(); - assert(c > 1); + CC_ASSERT(c > 1); if (c > 1) { wrap.wrap(data, 0); wrap.wrap(thizObj, 1); @@ -199,7 +199,7 @@ void *getPrivate(v8::Isolate *isolate, v8::Local value, uint32_t inde return nullptr; } - assert(index >= 0 && index < 2); + CC_ASSERT(index >= 0 && index < 2); if (index > 1) { return nullptr; } diff --git a/native/cocos/bindings/manual/JavaScriptJavaBridge.cpp b/native/cocos/bindings/manual/JavaScriptJavaBridge.cpp index 9c657d725f..91ea0221d5 100644 --- a/native/cocos/bindings/manual/JavaScriptJavaBridge.cpp +++ b/native/cocos/bindings/manual/JavaScriptJavaBridge.cpp @@ -447,7 +447,7 @@ bool JavaScriptJavaBridge::CallInfo::getMethodInfo() { } bool JavaScriptJavaBridge::convertReturnValue(ReturnValue retValue, ValueType type, se::Value *ret) { - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); switch (type) { case JavaScriptJavaBridge::ValueType::INTEGER: ret->setInt32(retValue.intValue); @@ -613,7 +613,7 @@ SE_BIND_FUNC(JavaScriptJavaBridge_callStaticMethod) static bool ScriptNativeBridge_getCallback(se::State &s) { //NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); - assert(cobj == ScriptNativeBridge::bridgeCxxInstance); + CC_ASSERT(cobj == ScriptNativeBridge::bridgeCxxInstance); s.rval() = cobj->jsCb; SE_HOLD_RETURN_VALUE(cobj->jsCb, s.thisObject(), s.rval()); return true; @@ -622,14 +622,14 @@ SE_BIND_PROP_GET(ScriptNativeBridge_getCallback) static bool ScriptNativeBridge_setCallback(se::State &s) { //NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); - assert(cobj == ScriptNativeBridge::bridgeCxxInstance); + CC_ASSERT(cobj == ScriptNativeBridge::bridgeCxxInstance); const auto &args = s.args(); se::Value jsFunc = args[0]; cobj->jsCb = jsFunc; if (jsFunc.isNullOrUndefined()) { cobj->setCallback(nullptr); } else { - assert(jsFunc.isObject() && jsFunc.toObject()->isFunction()); + CC_ASSERT(jsFunc.isObject() && jsFunc.toObject()->isFunction()); s.thisObject()->attachObject(jsFunc.toObject()); cobj->setCallback([jsFunc](const ccstd::string &arg0, const ccstd::string &arg1) { se::AutoHandleScope hs; @@ -685,7 +685,7 @@ se::Class *__jsb_ScriptNativeBridge_class = nullptr; // NOLINT static bool ScriptNativeBridge_finalize(se::State &s) { //NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); - assert(cobj == ScriptNativeBridge::bridgeCxxInstance); + CC_ASSERT(cobj == ScriptNativeBridge::bridgeCxxInstance); delete cobj; ScriptNativeBridge::bridgeCxxInstance = nullptr; return true; diff --git a/native/cocos/bindings/manual/JavaScriptObjCBridge.mm b/native/cocos/bindings/manual/JavaScriptObjCBridge.mm index 7b3c11c698..f06494aa91 100644 --- a/native/cocos/bindings/manual/JavaScriptObjCBridge.mm +++ b/native/cocos/bindings/manual/JavaScriptObjCBridge.mm @@ -336,7 +336,7 @@ SE_BIND_FUNC(JavaScriptObjCBridge_callStaticMethod) static bool ScriptNativeBridge_getCallback(se::State &s){ ScriptNativeBridge *cobj = (ScriptNativeBridge *)s.nativeThisObject(); - assert(cobj == ScriptNativeBridge::bridgeCxxInstance); + CC_ASSERT(cobj == ScriptNativeBridge::bridgeCxxInstance); s.rval() = cobj->jsCb; SE_HOLD_RETURN_VALUE(cobj->jsCb, s.thisObject(), s.rval()); return true; @@ -345,7 +345,7 @@ SE_BIND_PROP_GET(ScriptNativeBridge_getCallback) static bool ScriptNativeBridge_setCallback(se::State &s){ //NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); - assert(cobj == ScriptNativeBridge::bridgeCxxInstance); + CC_ASSERT(cobj == ScriptNativeBridge::bridgeCxxInstance); const auto &args = s.args(); se::Value jsFunc = args[0]; cobj->jsCb = jsFunc; @@ -354,7 +354,7 @@ static bool ScriptNativeBridge_setCallback(se::State &s){ //NOLINT(readability-i cobj->setCallback(nullptr); } else{ - assert(jsFunc.isObject() && jsFunc.toObject()->isFunction()); + CC_ASSERT(jsFunc.isObject() && jsFunc.toObject()->isFunction()); s.thisObject()->attachObject(jsFunc.toObject()); cobj->setCallback([jsFunc](const ccstd::string& arg0, const ccstd::string& arg1){ se::AutoHandleScope hs; @@ -411,7 +411,7 @@ se::Class *__jsb_ScriptNativeBridge_class = nullptr; // NOLINT static bool ScriptNativeBridge_finalize(se::State &s) { //NOLINT(readability-identifier-naming) auto *cobj = static_cast(s.nativeThisObject()); - assert(cobj == ScriptNativeBridge::bridgeCxxInstance); + CC_ASSERT(cobj == ScriptNativeBridge::bridgeCxxInstance); delete cobj; ScriptNativeBridge::bridgeCxxInstance = nullptr; return true; diff --git a/native/cocos/bindings/manual/jsb_classtype.h b/native/cocos/bindings/manual/jsb_classtype.h index 5f4431649e..46c16ef3ac 100644 --- a/native/cocos/bindings/manual/jsb_classtype.h +++ b/native/cocos/bindings/manual/jsb_classtype.h @@ -34,7 +34,7 @@ public: template static void registerClass(se::Class *cls) { const char *typeName = typeid(T).name(); - assert(jsbClassTypeMap.find(typeName) == jsbClassTypeMap.end()); + CC_ASSERT(jsbClassTypeMap.find(typeName) == jsbClassTypeMap.end()); jsbClassTypeMap.emplace(typeName, cls); } diff --git a/native/cocos/bindings/manual/jsb_cocos_manual.cpp b/native/cocos/bindings/manual/jsb_cocos_manual.cpp index 297cf09f2b..46d69231cd 100644 --- a/native/cocos/bindings/manual/jsb_cocos_manual.cpp +++ b/native/cocos/bindings/manual/jsb_cocos_manual.cpp @@ -189,7 +189,7 @@ void JSPlistDelegator::textHandler(void * /*unused*/, const char *ch, int len) { static bool register_plist_parser(se::Object * /*obj*/) { // NOLINT(readability-identifier-naming) se::Value v; __jsbObj->getProperty("PlistParser", &v); - assert(v.isObject()); + CC_ASSERT(v.isObject()); v.toObject()->defineFunction("getInstance", _SE(js_PlistParser_getInstance)); __jsb_cc_SAXParser_proto->defineFunction("parse", _SE(js_PlistParser_parse)); diff --git a/native/cocos/bindings/manual/jsb_conversions.h b/native/cocos/bindings/manual/jsb_conversions.h index a41fddf044..4fad325a58 100644 --- a/native/cocos/bindings/manual/jsb_conversions.h +++ b/native/cocos/bindings/manual/jsb_conversions.h @@ -25,21 +25,20 @@ #pragma once -#include #include #include #include #include -#include "base/Ptr.h" -#include "base/RefCounted.h" -#include "base/std/container/vector.h" #include "bindings/jswrapper/HandleObject.h" #include "bindings/jswrapper/SeApi.h" #include "bindings/manual/jsb_classtype.h" -#include "cocos/base/Any.h" -#include "cocos/base/Optional.h" -#include "cocos/base/Variant.h" - +#include "base/Any.h" +#include "base/Macros.h" +#include "base/Optional.h" +#include "base/RefCounted.h" +#include "base/Ptr.h" +#include "base/Variant.h" +#include "base/std/container/vector.h" #include "jsb_conversions_spec.h" #if CC_USE_SPINE @@ -128,7 +127,7 @@ #define CC_CONSTEXPR constexpr #else #define CC_CONSTEXPR - #define CC_STATIC_ASSERT(cond, ...) assert(cond) + #define CC_STATIC_ASSERT(cond, ...) CC_ASSERT(cond) #endif #if __clang__ && (__cplusplus > 201402L) @@ -139,7 +138,7 @@ template bool seval_to_native_ptr(const se::Value &v, T *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (v.isObject()) { T ptr = static_cast(v.toObject()->getPrivateData()); @@ -224,10 +223,10 @@ seval_to_type(const se::Value &v, bool &ok) { // NOLINT(readability-identifier-n template typename std::enable_if::value && std::is_class::type>::value, bool>::type seval_to_std_vector(const se::Value &v, ccstd::vector *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); - assert(v.isObject()); + CC_ASSERT(ret != nullptr); + CC_ASSERT(v.isObject()); se::Object *obj = v.toObject(); - assert(obj->isArray()); + CC_ASSERT(obj->isArray()); bool ok = true; uint32_t len = 0; @@ -264,10 +263,10 @@ seval_to_std_vector(const se::Value &v, ccstd::vector *ret) { // NOLINT(reada template typename std::enable_if::value, bool>::type seval_to_std_vector(const se::Value &v, ccstd::vector *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); - assert(v.isObject()); + CC_ASSERT(ret != nullptr); + CC_ASSERT(v.isObject()); se::Object *obj = v.toObject(); - assert(obj->isArray()); + CC_ASSERT(obj->isArray()); bool ok = true; uint32_t len = 0; @@ -297,8 +296,8 @@ seval_to_std_vector(const se::Value &v, ccstd::vector *ret) { // NOLINT(reada template bool seval_to_Map_string_key(const se::Value &v, cc::RefMap *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); - assert(v.isObject()); + CC_ASSERT(ret != nullptr); + CC_ASSERT(v.isObject()); se::Object *obj = v.toObject(); ccstd::vector allKeys; @@ -346,7 +345,7 @@ native_ptr_to_seval(T &v_ref, se::Value *ret, bool *isReturnCachedValue = nullpt using DecayT = typename std::decay::type>::type; auto *v = const_cast(&v_ref); - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (v == nullptr) { ret->setNull(); return true; @@ -357,7 +356,7 @@ native_ptr_to_seval(T &v_ref, se::Value *ret, bool *isReturnCachedValue = nullpt if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt // CC_LOG_DEBUGWARN("WARNING: non-Ref type: (%s) isn't catched!", typeid(*v).name()); se::Class *cls = JSBClassType::findClass(v); - assert(cls != nullptr); + CC_ASSERT(cls != nullptr); obj = se::Object::createObjectWithClass(cls); ret->setObject(obj, true); cc_tmp_set_private_data(obj, v); @@ -379,7 +378,7 @@ template bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming) typename std::enable_if::value, T>::type *v, se::Value *ret, bool *isReturnCachedValue = nullptr) { - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (v == nullptr) { ret->setNull(); return true; @@ -389,7 +388,7 @@ bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming) auto iter = se::NativePtrToObjectMap::find(reinterpret_cast(v)); if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt se::Class *cls = JSBClassType::findClass(v); - assert(cls != nullptr); + CC_ASSERT(cls != nullptr); obj = se::Object::createObjectWithClass(cls); obj->root(); obj->setPrivateObject(se::rawref_private_object(v)); @@ -399,7 +398,7 @@ bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming) // CC_LOG_DEBUGWARN("WARNING: non-Ref type: (%s) isn't catched!", typeid(*v).name()); } else { obj = iter->second; - assert(obj->isRooted()); + CC_ASSERT(obj->isRooted()); if (isReturnCachedValue != nullptr) { *isReturnCachedValue = true; } @@ -414,7 +413,7 @@ template bool native_ptr_to_seval(T *vp, se::Class *cls, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) using DecayT = typename std::decay::type>::type; auto *v = const_cast(vp); - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (v == nullptr) { ret->setNull(); return true; @@ -424,7 +423,7 @@ bool native_ptr_to_seval(T *vp, se::Class *cls, se::Value *ret, bool *isReturnCa auto iter = se::NativePtrToObjectMap::find(v); if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt // CC_LOG_DEBUGWARN("WARNING: Ref type: (%s) isn't catched!", typeid(*v).name()); - assert(cls != nullptr); + CC_ASSERT(cls != nullptr); obj = se::Object::createObjectWithClass(cls); ret->setObject(obj, true); cc_tmp_set_private_data(obj, v); @@ -446,7 +445,7 @@ template bool native_ptr_to_seval(T *vp, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming) using DecayT = typename std::decay::type>::type; auto *v = const_cast(vp); - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (v == nullptr) { ret->setNull(); return true; @@ -457,7 +456,7 @@ bool native_ptr_to_seval(T *vp, se::Value *ret, bool *isReturnCachedValue = null if (iter == se::NativePtrToObjectMap::end()) { // If we couldn't find native object in map, then the native object is created from native code. e.g. TMXLayer::getTileAt // CC_LOG_DEBUGWARN("WARNING: Ref type: (%s) isn't catched!", typeid(*v).name()); se::Class *cls = JSBClassType::findClass(v); - assert(cls != nullptr); + CC_ASSERT(cls != nullptr); obj = se::Object::createObjectWithClass(cls); ret->setObject(obj, true); cc_tmp_set_private_data(obj, v); @@ -477,7 +476,7 @@ bool native_ptr_to_seval(T *vp, se::Value *ret, bool *isReturnCachedValue = null } template bool std_vector_to_seval(const ccstd::vector &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); bool ok = true; se::HandleObject obj(se::Object::createArrayObject(v.size())); @@ -496,8 +495,8 @@ bool std_vector_to_seval(const ccstd::vector &v, se::Value *ret) { // NOLINT( template bool seval_to_reference(const se::Value &v, T **ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); - assert(v.isObject()); + CC_ASSERT(ret != nullptr); + CC_ASSERT(v.isObject()); *ret = static_cast(v.toObject()->getPrivateData()); return true; } @@ -649,7 +648,7 @@ sevalue_to_native(const se::Value &from, T *to, se::Object * /*unused*/) { // NO if CC_CONSTEXPR (std::is_copy_assignable::value) { *to = *static_cast(obj->getPrivateData()); } else { - assert(false); // can not copy + CC_ASSERT(false); // can not copy } return true; } @@ -696,13 +695,13 @@ bool sevalue_to_native(const se::Value &from, cc::IntrusivePtr *to, se::Objec template bool sevalue_to_native(const se::Value &from, ccstd::array *to, se::Object *ctx) { // NOLINT(readability-identifier-naming) - assert(from.toObject()); + CC_ASSERT(from.toObject()); se::Object *array = from.toObject(); - assert(array->isArray()); + CC_ASSERT(array->isArray()); uint32_t len = 0; array->getArrayLength(&len); se::Value tmp; - assert(len >= CNT); + CC_ASSERT(len >= CNT); for (uint32_t i = 0; i < CNT; i++) { array->getArrayElement(i, &tmp); sevalue_to_native(tmp, &(*to)[i], ctx); @@ -712,9 +711,9 @@ bool sevalue_to_native(const se::Value &from, ccstd::array *to, se::Obje template bool sevalue_to_native(const se::Value &from, ccstd::array *to, se::Object *ctx) { // NOLINT(readability-identifier-naming) - assert(from.toObject()); + CC_ASSERT(from.toObject()); se::Object *array = from.toObject(); - assert(array->isArray() || array->isArrayBuffer() || array->isTypedArray()); + CC_ASSERT(array->isArray() || array->isArrayBuffer() || array->isTypedArray()); if (array->isTypedArray()) { uint8_t *data = nullptr; size_t size = 0; @@ -733,7 +732,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::array *to, se uint32_t len = 0; array->getArrayLength(&len); se::Value tmp; - assert(len >= CNT); + CC_ASSERT(len >= CNT); for (size_t i = 0; i < CNT; i++) { array->getArrayElement(static_cast(i), &tmp); sevalue_to_native(tmp, &(*to)[i], ctx); @@ -793,7 +792,7 @@ sevalue_to_native(const se::Value &from, T **to, se::Object * /*ctx*/) { // NOLI } else if (data->isTypedArray()) { data->getTypedArrayData(&tmp, nullptr); } else { - assert(false); // bad type + CC_ASSERT(false); // bad type return false; } *to = reinterpret_cast(tmp); @@ -821,7 +820,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::vector *to, se::Object * return true; } - assert(from.toObject()); + CC_ASSERT(from.toObject()); se::Object *array = from.toObject(); if (array->isArray()) { @@ -839,7 +838,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::vector *to, se::Object * } if (array->isTypedArray()) { - assert(std::is_arithmetic::value); + CC_ASSERT(std::is_arithmetic::value); uint8_t *data = nullptr; size_t dataLen = 0; array->getTypedArrayData(&data, &dataLen); @@ -887,7 +886,7 @@ inline bool sevalue_to_native(const se::Value &from, std::function * template inline bool sevalue_to_native(const se::Value & /*from*/, cc::variant * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) static_assert(sizeof...(Args) == 0, "should not pass variant from js -> native"); - assert(false); + CC_ASSERT(false); return false; } @@ -903,7 +902,7 @@ inline bool sevalue_to_native(const se::Value &from, HolderType if CC_CONSTEXPR (std::is_constructible::value) { holder->ptr = ccnew_placement (&holder->inlineObject) T; } else { - assert(false); // default construtor not provided + CC_ASSERT(false); // default construtor not provided } return sevalue_to_native(from, holder->ptr, ctx); @@ -1011,7 +1010,7 @@ bool sevalue_to_native(const se::Value &from, std::shared_ptr *out, se::Objec return true; } auto *privateObject = from.toObject()->getPrivateObject(); - assert(privateObject->isSharedPtr()); + CC_ASSERT(privateObject->isSharedPtr()); *out = static_cast>(privateObject).share(); return true; } @@ -1039,7 +1038,7 @@ bool sevalue_to_native(const se::Value &from, cc::IntrusivePtr *to, se::Objec return ok; } - assert(privateObject->isCCShared()); + CC_ASSERT(privateObject->isCCShared()); *to = static_cast *>(privateObject)->ccShared(); return true; } @@ -1384,10 +1383,10 @@ bool nativevalue_to_se(const spine::Vector &v, se::Value &ret, se::Object * template bool sevalue_to_native(const se::Value &v, spine::Vector *ret, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); - assert(v.isObject()); + CC_ASSERT(ret != nullptr); + CC_ASSERT(v.isObject()); se::Object *obj = v.toObject(); - assert(obj->isArray()); + CC_ASSERT(obj->isArray()); bool ok = true; uint32_t len = 0; @@ -1446,7 +1445,7 @@ inline bool nativevalue_to_se(const std::shared_ptr &from, se::Value &to, se: auto it = se::NativePtrToObjectMap::find(nativePtr); if (it == se::NativePtrToObjectMap::end()) { se::Class *cls = JSBClassType::findClass(nativePtr); - assert(cls); + CC_ASSERT(cls); se::Object *obj = se::Object::createObjectWithClass(cls); to.setObject(obj, true); obj->setPrivateObject(se::shared_private_object(from)); @@ -1467,7 +1466,7 @@ inline bool nativevalue_to_se(const cc::IntrusivePtr &from, se::Value &to, se auto it = se::NativePtrToObjectMap::find(nativePtr); if (it == se::NativePtrToObjectMap::end()) { se::Class *cls = JSBClassType::findClass(nativePtr); - assert(cls); + CC_ASSERT(cls); se::Object *obj = se::Object::createObjectWithClass(cls); to.setObject(obj, true); obj->setPrivateObject(se::ccshared_private_object(from)); diff --git a/native/cocos/bindings/manual/jsb_conversions_spec.cpp b/native/cocos/bindings/manual/jsb_conversions_spec.cpp index e7964a3af0..7bde1daa80 100644 --- a/native/cocos/bindings/manual/jsb_conversions_spec.cpp +++ b/native/cocos/bindings/manual/jsb_conversions_spec.cpp @@ -105,7 +105,7 @@ namespace { template bool std_vector_T_to_seval(const ccstd::vector &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); se::HandleObject obj(se::Object::createArrayObject(v.size())); bool ok = true; @@ -144,7 +144,7 @@ bool size_to_seval(size_t v, se::Value *ret) { // NOLINT(readability-identifier- } bool Vec2_to_seval(const cc::Vec2 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); se::HandleObject obj(se::Object::createPlainObject()); obj->setProperty("x", se::Value(v.x)); obj->setProperty("y", se::Value(v.y)); @@ -154,7 +154,7 @@ bool Vec2_to_seval(const cc::Vec2 &v, se::Value *ret) { // NOLINT(readability-id } bool Vec3_to_seval(const cc::Vec3 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); se::HandleObject obj(se::Object::createPlainObject()); obj->setProperty("x", se::Value(v.x)); obj->setProperty("y", se::Value(v.y)); @@ -165,7 +165,7 @@ bool Vec3_to_seval(const cc::Vec3 &v, se::Value *ret) { // NOLINT(readability-id } bool Vec4_to_seval(const cc::Vec4 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); se::HandleObject obj(se::Object::createPlainObject()); obj->setProperty("x", se::Value(v.x)); obj->setProperty("y", se::Value(v.y)); @@ -177,7 +177,7 @@ bool Vec4_to_seval(const cc::Vec4 &v, se::Value *ret) { // NOLINT(readability-id } bool Quaternion_to_seval(const cc::Quaternion &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); se::HandleObject obj(se::Object::createPlainObject()); obj->setProperty("x", se::Value(v.x)); obj->setProperty("y", se::Value(v.y)); @@ -189,7 +189,7 @@ bool Quaternion_to_seval(const cc::Quaternion &v, se::Value *ret) { // NOLINT(re } bool Mat4_to_seval(const cc::Mat4 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); se::HandleObject obj(se::Object::createArrayObject(16)); for (uint8_t i = 0; i < 16; ++i) { @@ -201,7 +201,7 @@ bool Mat4_to_seval(const cc::Mat4 &v, se::Value *ret) { // NOLINT(readability-id } bool Size_to_seval(const cc::Size &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); se::HandleObject obj(se::Object::createPlainObject()); obj->setProperty("width", se::Value(v.width)); obj->setProperty("height", se::Value(v.height)); @@ -210,7 +210,7 @@ bool Size_to_seval(const cc::Size &v, se::Value *ret) { // NOLINT(readability-id } bool Rect_to_seval(const cc::Rect &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); se::HandleObject obj(se::Object::createPlainObject()); obj->setProperty("x", se::Value(v.origin.x)); obj->setProperty("y", se::Value(v.origin.y)); @@ -296,7 +296,7 @@ void toMat(const float *data, int num, se::Value *ret) { // NOLINTNEXTLINE(readability-identifier-naming) bool seval_to_ccvalue(const se::Value &v, cc::Value *ret) { // NOLINT - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); bool ok = true; if (v.isObject()) { se::Object *jsobj = v.toObject(); @@ -330,7 +330,7 @@ bool seval_to_ccvalue(const se::Value &v, cc::Value *ret) { // NOLINT // NOLINTNEXTLINE(readability-identifier-naming) bool seval_to_ccvaluemap(const se::Value &v, cc::ValueMap *ret) { // NOLINT - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (v.isNullOrUndefined()) { ret->clear(); @@ -362,7 +362,7 @@ bool seval_to_ccvaluemap(const se::Value &v, cc::ValueMap *ret) { // NOLINT // NOLINTNEXTLINE(readability-identifier-naming) bool seval_to_ccvaluemapintkey(const se::Value &v, cc::ValueMapIntKey *ret) { - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (v.isNullOrUndefined()) { ret->clear(); return true; @@ -401,7 +401,7 @@ bool seval_to_ccvaluemapintkey(const se::Value &v, cc::ValueMapIntKey *ret) { // NOLINTNEXTLINE(readability-identifier-naming) bool seval_to_ccvaluevector(const se::Value &v, cc::ValueVector *ret) { // NOLINT - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); SE_PRECONDITION3(v.isObject(), false, ret->clear()); @@ -441,7 +441,7 @@ bool sevals_variadic_to_ccvaluevector(const se::ValueArray &args, cc::ValueVecto // NOLINTNEXTLINE(readability-identifier-naming) bool seval_to_Data(const se::Value &v, cc::Data *ret) { - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); SE_PRECONDITION2(v.isObject() && v.toObject()->isTypedArray(), false, "Convert parameter to Data failed!"); uint8_t *ptr = nullptr; size_t length = 0; @@ -458,7 +458,7 @@ bool seval_to_Data(const se::Value &v, cc::Data *ret) { // NOLINTNEXTLINE(readability-identifier-naming) bool seval_to_DownloaderHints(const se::Value &v, cc::network::DownloaderHints *ret) { const static cc::network::DownloaderHints ZERO{0, 0, ""}; - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); SE_PRECONDITION2(v.isObject(), false, "Convert parameter to DownloaderHints failed!"); se::Value tmp; se::Object *obj = v.toObject(); @@ -1040,12 +1040,12 @@ bool sevalue_to_native(const se::Value &from, cc::variantsetJSArrayBuffer(from.toObject()); return true; } bool sevalue_to_native(const se::Value &from, cc::ArrayBuffer **to, se::Object * /*ctx*/) { - assert(from.isObject()); + CC_ASSERT(from.isObject()); *to = ccnew cc::ArrayBuffer(); (*to)->addRef(); (*to)->setJSArrayBuffer(from.toObject()); @@ -1079,7 +1079,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::vector *to, return true; } - assert(from.isObject()); + CC_ASSERT(from.isObject()); se::Object *in = from.toObject(); if (in->isTypedArray()) { @@ -1181,9 +1181,9 @@ bool sevalue_to_native(const se::Value &val, spine::String *obj, se::Object * /* // NOLINTNEXTLINE(readability-identifier-naming) bool sevalue_to_native(const se::Value &v, spine::Vector *ret, se::Object * /*unused*/) { - assert(v.isObject()); + CC_ASSERT(v.isObject()); se::Object *obj = v.toObject(); - assert(obj->isArray()); + CC_ASSERT(obj->isArray()); bool ok = true; uint32_t len = 0; @@ -1212,8 +1212,8 @@ bool sevalue_to_native(const se::Value &v, spine::Vector *ret, se #if CC_USE_MIDDLEWARE // NOLINTNEXTLINE(readability-identifier-naming) bool seval_to_Map_string_key(const se::Value &v, cc::RefMap *ret) { - assert(ret != nullptr); - assert(v.isObject()); + CC_ASSERT(ret != nullptr); + CC_ASSERT(v.isObject()); se::Object *obj = v.toObject(); ccstd::vector allKeys; @@ -1252,7 +1252,7 @@ bool seval_to_Map_string_key(const se::Value &v, cc::RefMapsetProperty("md5", se::Value(v.md5)); obj->setProperty("path", se::Value(v.path)); @@ -1395,7 +1395,7 @@ bool ManifestAsset_to_seval(const cc::extension::ManifestAsset &v, se::Value *re // NOLINTNEXTLINE(readability-identifier-naming) bool Data_to_seval(const cc::Data &v, se::Value *ret) { - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (v.isNull()) { ret->setNull(); } else { @@ -1407,7 +1407,7 @@ bool Data_to_seval(const cc::Data &v, se::Value *ret) { // NOLINTNEXTLINE(readability-identifier-naming) bool DownloadTask_to_seval(const cc::network::DownloadTask &v, se::Value *ret) { - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); se::HandleObject obj(se::Object::createPlainObject()); obj->setProperty("identifier", se::Value(v.identifier)); @@ -1614,7 +1614,7 @@ bool nativevalue_to_se(const cc::physics::RaycastResult &from, se::Value &to, se } bool sevalue_to_native(const se::Value &from, cc::physics::ConvexDesc *to, se::Object *ctx) { - assert(from.isObject()); + CC_ASSERT(from.isObject()); se::Object *json = from.toObject(); auto * data = static_cast(json->getPrivateData()); if (data) { @@ -1650,7 +1650,7 @@ bool sevalue_to_native(const se::Value &from, cc::physics::TrimeshDesc *to, se:: return false; } - assert(from.isObject()); + CC_ASSERT(from.isObject()); se::Object *json = from.toObject(); auto * data = static_cast(json->getPrivateData()); if (data) { @@ -1685,7 +1685,7 @@ bool sevalue_to_native(const se::Value &from, cc::physics::TrimeshDesc *to, se:: } bool sevalue_to_native(const se::Value &from, cc::physics::HeightFieldDesc *to, se::Object *ctx) { - assert(from.isObject()); + CC_ASSERT(from.isObject()); se::Object *json = from.toObject(); auto * data = static_cast(json->getPrivateData()); if (data) { @@ -1720,7 +1720,7 @@ bool sevalue_to_native(const se::Value &from, cc::physics::HeightFieldDesc *to, } bool sevalue_to_native(const se::Value &from, cc::physics::RaycastOptions *to, se::Object *ctx) { - assert(from.isObject()); + CC_ASSERT(from.isObject()); se::Object *json = from.toObject(); auto * data = static_cast(json->getPrivateData()); if (data) { diff --git a/native/cocos/bindings/manual/jsb_conversions_spec.h b/native/cocos/bindings/manual/jsb_conversions_spec.h index cdf9b78f38..3fe8392205 100644 --- a/native/cocos/bindings/manual/jsb_conversions_spec.h +++ b/native/cocos/bindings/manual/jsb_conversions_spec.h @@ -240,7 +240,7 @@ inline bool sevalue_to_native(const se::Value &from, double *to, se::Object * /* } //inline bool sevalue_to_native(const se::Value & /*from*/, void * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) -// assert(false); // void not supported +// CC_ASSERT(false); // void not supported // return false; //} @@ -278,7 +278,7 @@ inline bool sevalue_to_native(const se::Value &from, ccstd::vector *t to->clear(); return true; } - assert(from.isObject() && from.toObject()->isArray()); + CC_ASSERT(from.isObject() && from.toObject()->isArray()); auto *array = from.toObject(); to->clear(); uint32_t size; @@ -293,7 +293,7 @@ inline bool sevalue_to_native(const se::Value &from, ccstd::vector *t ////////////////// cc::any inline bool sevalue_to_native(const se::Value & /*from*/, cc::any * /*to*/, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) - assert(false); + CC_ASSERT(false); SE_LOGE("Can not convert any to specific types"); return false; } @@ -303,13 +303,13 @@ bool sevalue_to_native(const se::Value &from, cc::TypedArray *to, se::Object * / bool sevalue_to_native(const se::Value &from, cc::IBArray *to, se::Object * /*ctx*/); // NOLINT(readability-identifier-naming) //bool sevalue_to_native(const se::Value &from, cc::gfx::Context **to, se::Object*) {// NOLINT(readability-identifier-naming) -// assert(from.isObject()); +// CC_ASSERT(from.isObject()); // *to = (cc::gfx::Context*)from.toObject()->getPrivateData(); // return true; //} inline bool sevalue_to_native(const se::Value &from, void **to, se::Object * /*ctx*/) { // NOLINT(readability-identifier-naming) - assert(to != nullptr); + CC_ASSERT(to != nullptr); if (from.isNumber() || from.isBigInt()) { // NOLINTNEXTLINE(performance-no-int-to-ptr) *to = reinterpret_cast(from.toUint64()); @@ -501,7 +501,7 @@ inline bool nativevalue_to_se(const cc::monostate & /*from*/, se::Value &to, se: } inline bool nativevalue_to_se(const cc::any &from, se::Value &to, se::Object *ctx) { //NOLINT - assert(false); + CC_ASSERT(false); SE_LOGE("should not convert cc::any"); return true; } diff --git a/native/cocos/bindings/manual/jsb_gfx_manual.cpp b/native/cocos/bindings/manual/jsb_gfx_manual.cpp index 0851a1e9c3..f9cab5827a 100644 --- a/native/cocos/bindings/manual/jsb_gfx_manual.cpp +++ b/native/cocos/bindings/manual/jsb_gfx_manual.cpp @@ -64,7 +64,7 @@ bool js_gfx_Device_copyBuffersToTexture(se::State &s) { // NOLINT(readability-id ok = obj->getTypedArrayData(&ptr, &dataLength); SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); } else { - assert(false); + CC_ASSERT(false); } } else { ptr = reinterpret_cast(value.asPtr()); // NOLINT(performance-no-int-to-ptr) script engine bad API design @@ -118,7 +118,7 @@ bool js_gfx_Device_copyTextureToBuffers(se::State &s) { // NOLINT(readability-id ok = obj->getTypedArrayData(&ptr, &dataLength); SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); } else { - assert(false); + CC_ASSERT(false); } } else { ptr = reinterpret_cast(value.asPtr()); // NOLINT(performance-no-int-to-ptr) script engine bad API design @@ -358,7 +358,7 @@ static bool js_gfx_CommandBuffer_execute(se::State &s) { // NOLINT(readability-i ok &= sevalue_to_native(args[1], &count); se::Object *jsarr = args[0].toObject(); - assert(jsarr->isArray()); + CC_ASSERT(jsarr->isArray()); uint32_t len = 0; ok &= jsarr->getArrayLength(&len); if (len < count) { @@ -455,7 +455,7 @@ static bool js_gfx_CommandBuffer_copyBuffersToTexture(se::State &s) { // NOLINT( ok = obj->getTypedArrayData(&ptr, &dataLength); SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); } else { - assert(false); + CC_ASSERT(false); } arg0[i] = ptr; } diff --git a/native/cocos/bindings/manual/jsb_global.cpp b/native/cocos/bindings/manual/jsb_global.cpp index 34de2b90ef..a4560afcf3 100644 --- a/native/cocos/bindings/manual/jsb_global.cpp +++ b/native/cocos/bindings/manual/jsb_global.cpp @@ -125,8 +125,8 @@ ccstd::unordered_map gModuleCache; static bool require(se::State &s) { //NOLINT const auto &args = s.args(); int argc = static_cast(args.size()); - assert(argc >= 1); - assert(args[0].isString()); + CC_ASSERT(argc >= 1); + CC_ASSERT(args[0].isString()); return jsb_run_script(args[0].toString(), &s.rval()); } @@ -134,10 +134,10 @@ SE_BIND_FUNC(require) static bool doModuleRequire(const ccstd::string &path, se::Value *ret, const ccstd::string &prevScriptFileDir) { //NOLINT se::AutoHandleScope hs; - assert(!path.empty()); + CC_ASSERT(!path.empty()); const auto &fileOperationDelegate = se::ScriptEngine::getInstance()->getFileOperationDelegate(); - assert(fileOperationDelegate.isValid()); + CC_ASSERT(fileOperationDelegate.isValid()); ccstd::string fullPath; @@ -227,21 +227,21 @@ static bool doModuleRequire(const ccstd::string &path, se::Value *ret, const ccs } else { gModuleCache[fullPath] = se::Value::Undefined; } - assert(succeed); + CC_ASSERT(succeed); return succeed; } SE_LOGE("doModuleRequire %s, buffer is empty!\n", path.c_str()); - assert(false); + CC_ASSERT(false); return false; } static bool moduleRequire(se::State &s) { //NOLINT const auto &args = s.args(); int argc = static_cast(args.size()); - assert(argc >= 2); - assert(args[0].isString()); - assert(args[1].isString()); + CC_ASSERT(argc >= 2); + CC_ASSERT(args[0].isString()); + CC_ASSERT(args[1].isString()); return doModuleRequire(args[0].toString(), &s.rval(), args[1].toString()); } @@ -275,7 +275,7 @@ static bool jsc_dumpNativePtrToSeObjectMap(se::State &s) { //NOLINT for (const auto &e : se::NativePtrToObjectMap::instance()) { se::Object *jsobj = e.second; - assert(jsobj->_getClass() != nullptr); + CC_ASSERT(jsobj->_getClass() != nullptr); NamePtrStruct tmp; tmp.name = jsobj->_getClass()->getName(); tmp.ptr = e.first; @@ -305,7 +305,7 @@ static bool jsc_dumpNativePtrToSeObjectMap(se::State &s) { //NOLINT SE_BIND_FUNC(jsc_dumpNativePtrToSeObjectMap) static bool jsc_dumpRoot(se::State &s) { //NOLINT - assert(false); + CC_ASSERT(false); return true; } SE_BIND_FUNC(jsc_dumpRoot) @@ -432,8 +432,8 @@ static bool JSB_saveByteCode(se::State &s) { //NOLINT SE_BIND_FUNC(JSB_saveByteCode) static bool getOrCreatePlainObject_r(const char *name, se::Object *parent, se::Object **outObj) { //NOLINT - assert(parent != nullptr); - assert(outObj != nullptr); + CC_ASSERT(parent != nullptr); + CC_ASSERT(outObj != nullptr); se::Value tmp; if (parent->getProperty(name, &tmp) && tmp.isObject()) { @@ -640,8 +640,8 @@ static bool js_loadImage(se::State &s) { //NOLINT SE_PRECONDITION2(ok, false, "js_loadImage : Error processing arguments"); se::Value callbackVal = args[1]; - assert(callbackVal.isObject()); - assert(callbackVal.toObject()->isFunction()); + CC_ASSERT(callbackVal.isObject()); + CC_ASSERT(callbackVal.toObject()->isFunction()); return jsb_global_load_image(path, callbackVal); } diff --git a/native/cocos/bindings/manual/jsb_global_init.cpp b/native/cocos/bindings/manual/jsb_global_init.cpp index 1a1a1451ef..01f223fa4d 100644 --- a/native/cocos/bindings/manual/jsb_global_init.cpp +++ b/native/cocos/bindings/manual/jsb_global_init.cpp @@ -95,7 +95,7 @@ void jsb_init_file_operation_delegate() { //NOLINT static se::ScriptEngine::FileOperationDelegate delegate; if (!delegate.isValid()) { delegate.onGetDataFromFile = [](const ccstd::string &path, const std::function &readCallback) -> void { - assert(!path.empty()); + CC_ASSERT(!path.empty()); Data fileData; @@ -138,7 +138,7 @@ void jsb_init_file_operation_delegate() { //NOLINT }; delegate.onGetStringFromFile = [](const ccstd::string &path) -> ccstd::string { - assert(!path.empty()); + CC_ASSERT(!path.empty()); ccstd::string byteCodePath = removeFileExt(path) + BYTE_CODE_FILE_EXT; if (FileUtils::getInstance()->isFileExist(byteCodePath)) { @@ -181,7 +181,7 @@ void jsb_init_file_operation_delegate() { //NOLINT }; delegate.onGetFullPath = [](const ccstd::string &path) -> ccstd::string { - assert(!path.empty()); + CC_ASSERT(!path.empty()); ccstd::string byteCodePath = removeFileExt(path) + BYTE_CODE_FILE_EXT; if (FileUtils::getInstance()->isFileExist(byteCodePath)) { return FileUtils::getInstance()->fullPathForFilename(byteCodePath); @@ -190,11 +190,11 @@ void jsb_init_file_operation_delegate() { //NOLINT }; delegate.onCheckFileExist = [](const ccstd::string &path) -> bool { - assert(!path.empty()); + CC_ASSERT(!path.empty()); return FileUtils::getInstance()->isFileExist(path); }; - assert(delegate.isValid()); + CC_ASSERT(delegate.isValid()); se::ScriptEngine::getInstance()->setFileOperationDelegate(delegate); } diff --git a/native/cocos/bindings/manual/jsb_scene_manual.cpp b/native/cocos/bindings/manual/jsb_scene_manual.cpp index 407c049643..b3106a1fec 100644 --- a/native/cocos/bindings/manual/jsb_scene_manual.cpp +++ b/native/cocos/bindings/manual/jsb_scene_manual.cpp @@ -380,7 +380,7 @@ static bool js_scene_Node_registerOnSiblingOrderChanged(se::State &s) // NOLINT( SE_BIND_FUNC(js_scene_Node_registerOnSiblingOrderChanged) // NOLINT(readability-identifier-naming) static bool scene_Vec3_to_seval(const cc::Vec3 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (!nodeVec3CacheObj) { nodeVec3CacheObj = se::Object::createPlainObject(); nodeVec3CacheObj->root(); @@ -395,7 +395,7 @@ static bool scene_Vec3_to_seval(const cc::Vec3 &v, se::Value *ret) { // NOLINT(r } static bool scene_Quaternion_to_seval(const cc::Quaternion &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (!nodeQuatCacheObj) { nodeQuatCacheObj = se::Object::createPlainObject(); nodeQuatCacheObj->root(); @@ -411,7 +411,7 @@ static bool scene_Quaternion_to_seval(const cc::Quaternion &v, se::Value *ret) { } static bool scene_Mat4_to_seval(const cc::Mat4 &v, se::Value *ret) { // NOLINT(readability-identifier-naming) - assert(ret != nullptr); + CC_ASSERT(ret != nullptr); if (!nodeMat4CacheObj) { nodeMat4CacheObj = se::Object::createPlainObject(); nodeMat4CacheObj->root(); diff --git a/native/cocos/bindings/manual/jsb_socketio.cpp b/native/cocos/bindings/manual/jsb_socketio.cpp index b09e487fc0..c699daa159 100644 --- a/native/cocos/bindings/manual/jsb_socketio.cpp +++ b/native/cocos/bindings/manual/jsb_socketio.cpp @@ -106,7 +106,7 @@ public: if (it != _eventRegistry.end()) { const se::ValueArray &cbStruct = it->second; - assert(cbStruct.size() == 2); + CC_ASSERT(cbStruct.size() == 2); const se::Value &callback = cbStruct[0]; const se::Value &target = cbStruct[1]; if (callback.isObject() && callback.toObject()->isFunction() && target.isObject()) { @@ -122,8 +122,8 @@ public: } void addEvent(const ccstd::string &eventName, const se::Value &callback, const se::Value &target) { - assert(callback.isObject() && callback.toObject()->isFunction()); - assert(target.isObject()); + CC_ASSERT(callback.isObject() && callback.toObject()->isFunction()); + CC_ASSERT(target.isObject()); _eventRegistry[eventName].clear(); _eventRegistry[eventName].push_back(callback); _eventRegistry[eventName].push_back(target); diff --git a/native/cocos/bindings/manual/jsb_spine_manual.cpp b/native/cocos/bindings/manual/jsb_spine_manual.cpp index 9721bd64b1..ab46e72e76 100644 --- a/native/cocos/bindings/manual/jsb_spine_manual.cpp +++ b/native/cocos/bindings/manual/jsb_spine_manual.cpp @@ -44,7 +44,7 @@ using namespace cc; static spine::Cocos2dTextureLoader textureLoader; static cc::RefMap *_preloadedAtlasTextures = nullptr; static middleware::Texture2D * _getPreloadedAtlasTexture(const char *path) { - assert(_preloadedAtlasTextures); + CC_ASSERT(_preloadedAtlasTextures); auto it = _preloadedAtlasTextures->find(path); return it != _preloadedAtlasTextures->end() ? it->second : nullptr; } diff --git a/native/cocos/bindings/manual/jsb_websocket.cpp b/native/cocos/bindings/manual/jsb_websocket.cpp index d30d1fcf3c..f7224623c2 100644 --- a/native/cocos/bindings/manual/jsb_websocket.cpp +++ b/native/cocos/bindings/manual/jsb_websocket.cpp @@ -229,7 +229,7 @@ void JsbWebSocketDelegate::onError(cc::network::WebSocket *ws, const cc::network } void JsbWebSocketDelegate::setJSDelegate(const se::Value &jsDelegate) { - assert(jsDelegate.isObject()); + CC_ASSERT(jsDelegate.isObject()); _JSDelegate = jsDelegate; } @@ -374,12 +374,12 @@ static bool webSocketSend(const se::State &s) { ok = dataObj->getTypedArrayData(&ptr, &length); SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); } else { - assert(false); + CC_ASSERT(false); } cobj->send(ptr, static_cast(length)); } else { - assert(false); + CC_ASSERT(false); } return true; @@ -406,18 +406,18 @@ static bool webSocketClose(se::State &s) { sevalue_to_native(args[0], &reason); cobj->closeAsync(1005, reason); } else { - assert(false); + CC_ASSERT(false); } } else if (argc == 2) { - assert(args[0].isNumber()); - assert(args[1].isString()); + CC_ASSERT(args[0].isNumber()); + CC_ASSERT(args[1].isString()); int reasonCode{0}; ccstd::string reasonString; sevalue_to_native(args[0], &reasonCode); sevalue_to_native(args[1], &reasonString); cobj->closeAsync(reasonCode, reasonString); } else { - assert(false); + CC_ASSERT(false); } // Attach current WebSocket instance to global object to prevent WebSocket instance // being garbage collected after "ws.close(); ws = null;" diff --git a/native/cocos/bindings/manual/jsb_websocket_server.cpp b/native/cocos/bindings/manual/jsb_websocket_server.cpp index 95f793a732..7504a8b398 100644 --- a/native/cocos/bindings/manual/jsb_websocket_server.cpp +++ b/native/cocos/bindings/manual/jsb_websocket_server.cpp @@ -194,7 +194,7 @@ static bool WebSocketServer_onconnection(se::State &s) { if (ptr) { se::Object *sobj = (se::Object *)ptr->getData(); sobj->unroot(); - assert(obj == sobj); + CC_ASSERT(obj == sobj); } }); se::ValueArray args; @@ -416,12 +416,12 @@ static bool WebSocketServer_Connection_send(se::State &s) { ok = dataObj->getTypedArrayData(&ptr, &length); SE_PRECONDITION2(ok, false, "getTypedArrayData failed!"); } else { - assert(false); + CC_ASSERT(false); } (*cobj)->sendBinaryAsync(ptr, (unsigned int)length, callback); } else { - assert(false); + CC_ASSERT(false); } return true; diff --git a/native/cocos/core/TypedArray.h b/native/cocos/core/TypedArray.h index 75c7dd1774..3fe7972009 100644 --- a/native/cocos/core/TypedArray.h +++ b/native/cocos/core/TypedArray.h @@ -240,18 +240,18 @@ public: se::Value tmpVal; _jsTypedArray->getProperty("buffer", &tmpVal); - assert(tmpVal.isObject()); - assert(tmpVal.toObject()->isArrayBuffer()); + CC_ASSERT(tmpVal.isObject()); + CC_ASSERT(tmpVal.toObject()->isArrayBuffer()); _buffer = ccnew ArrayBuffer(); _buffer->setJSArrayBuffer(tmpVal.toObject()); _jsTypedArray->getProperty("byteOffset", &tmpVal); - assert(tmpVal.isNumber()); + CC_ASSERT(tmpVal.isNumber()); _byteOffset = tmpVal.toUint32(); _jsTypedArray->getProperty("byteLength", &tmpVal); - assert(tmpVal.isNumber()); + CC_ASSERT(tmpVal.isNumber()); _byteLength = tmpVal.toUint32(); _byteEndPos = _buffer->byteLength(); diff --git a/native/cocos/core/assets/Material.cpp b/native/cocos/core/assets/Material.cpp index 500d8ebc7c..38347febab 100644 --- a/native/cocos/core/assets/Material.cpp +++ b/native/cocos/core/assets/Material.cpp @@ -103,12 +103,12 @@ void Material::doDestroy() { } void Material::recompileShaders(const MacroRecord & /*overrides*/, index_t /*passIdx*/) { - assert(false); + CC_ASSERT(false); CC_LOG_WARNING("Shaders in material asset '%s' cannot be modified at runtime, please instantiate the material first.", _name.c_str()); } void Material::overridePipelineStates(const PassOverrides & /*overrides*/, index_t /*passIdx*/) { - assert(false); + CC_ASSERT(false); CC_LOG_WARNING("Pipeline states in material asset '%s' cannot be modified at runtime, please instantiate the material first.", _name.c_str()); } diff --git a/native/cocos/core/geometry/AABB.cpp b/native/cocos/core/geometry/AABB.cpp index 76143266d6..0a72c860b1 100644 --- a/native/cocos/core/geometry/AABB.cpp +++ b/native/cocos/core/geometry/AABB.cpp @@ -24,8 +24,7 @@ ****************************************************************************/ #include "AABB.h" - -#include +#include "base/Macros.h" #include "cocos/core/geometry/Enums.h" #include "cocos/core/geometry/Sphere.h" diff --git a/native/cocos/core/geometry/Capsule.cpp b/native/cocos/core/geometry/Capsule.cpp index 78100ea9ea..3bb344206b 100644 --- a/native/cocos/core/geometry/Capsule.cpp +++ b/native/cocos/core/geometry/Capsule.cpp @@ -40,7 +40,7 @@ void Capsule::updateLocalCenter() { ellipseCenter1 = {0, 0, -halfHeight}; break; default: - assert(false); + CC_ASSERT(false); } } } // namespace geometry diff --git a/native/cocos/core/geometry/Enums.h b/native/cocos/core/geometry/Enums.h index 2bdfa4db4b..fa173635f3 100644 --- a/native/cocos/core/geometry/Enums.h +++ b/native/cocos/core/geometry/Enums.h @@ -1,6 +1,6 @@ #pragma once -#include +#include "base/Macros.h" #include "base/RefCounted.h" namespace cc { @@ -30,7 +30,7 @@ public: * 获取形状的类型。 */ inline ShapeEnum getType() const { - assert(_type != ShapeEnum::SHAPE_BAD); // shape is not initialized + CC_ASSERT(_type != ShapeEnum::SHAPE_BAD); // shape is not initialized return _type; } inline void setType(ShapeEnum type) { _type = type; } diff --git a/native/cocos/core/geometry/Intersect.h b/native/cocos/core/geometry/Intersect.h index 1f253ddaba..77741f8cec 100644 --- a/native/cocos/core/geometry/Intersect.h +++ b/native/cocos/core/geometry/Intersect.h @@ -400,7 +400,7 @@ template auto intersects(const T1 & /*a*/, const T2 & /*b*/) { static_assert(std::is_base_of::value, "type is not base of ShapeBase"); static_assert(std::is_base_of::value, "type is not base of ShapeBase"); - assert(false); // mismatch + CC_ASSERT(false); // mismatch } #define DECLARE_EXCHANGABLE_INTERSECT(TYPE1, TYPE2, FN) \ diff --git a/native/cocos/core/scene-graph/Scene.cpp b/native/cocos/core/scene-graph/Scene.cpp index 5830d63446..801012d242 100644 --- a/native/cocos/core/scene-graph/Scene.cpp +++ b/native/cocos/core/scene-graph/Scene.cpp @@ -48,7 +48,7 @@ void Scene::setSceneGlobals(SceneGlobals *globals) { _globals = globals; } void Scene::load() { if (!_inited) { //cjh if (TEST) { - // assert(!_activeInHierarchy, 'Should deactivate ActionManager by default'); + // CC_ASSERT(!_activeInHierarchy, 'Should deactivate ActionManager by default'); // } // expandNestedPrefabInstanceNode(this); // TODO(xwx): expandNestedPrefabInstanceNode not implement yet // applyTargetOverrides(this); // TODO(xwx): applyTargetOverrides not implement yet diff --git a/native/cocos/network/SocketIO.cpp b/native/cocos/network/SocketIO.cpp index 833e23e1da..af1eae87d5 100644 --- a/native/cocos/network/SocketIO.cpp +++ b/native/cocos/network/SocketIO.cpp @@ -351,7 +351,7 @@ SIOClientImpl::SIOClientImpl(Uri uri, ccstd::string caFilePath) : _uri(std::move } SIOClientImpl::~SIOClientImpl() { - assert(!_connected); + CC_ASSERT(!_connected); CC_SAFE_RELEASE(_ws); } @@ -906,7 +906,7 @@ SIOClient::SIOClient(ccstd::string path, SIOClientImpl *impl, SocketIO::SIODeleg } SIOClient::~SIOClient() { - assert(!_connected); + CC_ASSERT(!_connected); } void SIOClient::onOpen() { diff --git a/native/cocos/network/WebSocket-okhttp.cpp b/native/cocos/network/WebSocket-okhttp.cpp index 95114361ec..2ba1c2ab79 100644 --- a/native/cocos/network/WebSocket-okhttp.cpp +++ b/native/cocos/network/WebSocket-okhttp.cpp @@ -1,5 +1,4 @@ #include -#include #include "WebSocket.h" #include "application/ApplicationManager.h" #include "base/Scheduler.h" diff --git a/native/cocos/network/WebSocketServer.cpp b/native/cocos/network/WebSocketServer.cpp index 8a19b3a3fd..bc00695353 100644 --- a/native/cocos/network/WebSocketServer.cpp +++ b/native/cocos/network/WebSocketServer.cpp @@ -24,7 +24,6 @@ ****************************************************************************/ #include -#include #include #include "application/ApplicationManager.h" diff --git a/native/cocos/platform/Image.cpp b/native/cocos/platform/Image.cpp index a5b3392642..bba572e6a0 100644 --- a/native/cocos/platform/Image.cpp +++ b/native/cocos/platform/Image.cpp @@ -26,7 +26,6 @@ ****************************************************************************/ #include "Image.h" -#include #include #include #include "base/Config.h" // CC_USE_JPEG, CC_USE_WEBP diff --git a/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm b/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm index a6275133bb..db9f108fee 100644 --- a/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm +++ b/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm @@ -433,7 +433,7 @@ if (rect.size.width < 1 || rect.size.height < 1) return; //REFINE: - // assert(rect.origin.x == 0 && rect.origin.y == 0); + // CC_ASSERT(rect.origin.x == 0 && rect.origin.y == 0); memset((void *)_imageData.getBytes(), 0x00, _imageData.getSize()); } diff --git a/native/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.cpp b/native/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.cpp index ca6abff31b..47a4feffe5 100644 --- a/native/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.cpp +++ b/native/cocos/platform/interfaces/modules/canvas/CanvasRenderingContext2D.cpp @@ -346,7 +346,7 @@ void CanvasRenderingContext2D::setTextAlign(const ccstd::string &textAlign) { } else if (textAlign == "right") { _delegate->setTextAlign(TextAlign::RIGHT); } else { - assert(false); + CC_ASSERT(false); } } @@ -362,7 +362,7 @@ void CanvasRenderingContext2D::setTextBaseline(const ccstd::string &textBaseline } else if (textBaseline == "alphabetic") { _delegate->setTextBaseline(TextBaseline::ALPHABETIC); } else { - assert(false); + CC_ASSERT(false); } } diff --git a/native/cocos/platform/ios/modules/Screen.mm b/native/cocos/platform/ios/modules/Screen.mm index 42a33aea25..afdd015554 100644 --- a/native/cocos/platform/ios/modules/Screen.mm +++ b/native/cocos/platform/ios/modules/Screen.mm @@ -79,7 +79,7 @@ Screen::Orientation Screen::getDeviceOrientation() const { orientation = Orientation::PORTRAIT; break; default: - assert(false); + CC_ASSERT(false); break; } diff --git a/native/cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp b/native/cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp index 5a00cf0b5a..190cc75ec3 100644 --- a/native/cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp +++ b/native/cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp @@ -252,7 +252,7 @@ CanvasRenderingContext2DDelegate::Size CanvasRenderingContext2DDelegate::sizeWit // if (text.empty()) // return ccstd::array{0.0f, 0.0f}; // XFontStruct *fs = XLoadQueryFont(dpy, "cursor"); - // assert(fs); + // CC_ASSERT(fs); // int font_ascent = 0; // int font_descent = 0; // XCharStruct overall; diff --git a/native/cocos/platform/mac/cocos2d-prefix.pch b/native/cocos/platform/mac/cocos2d-prefix.pch deleted file mode 100644 index f46744c64e..0000000000 --- a/native/cocos/platform/mac/cocos2d-prefix.pch +++ /dev/null @@ -1,33 +0,0 @@ -// -// Prefix header for all source files of the 'cocos2dx' target in the 'cocos2dx' project -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __OBJC__ - #import -#endif - -#ifdef __cplusplus - #include "base/std/container/strig.h" - #include - #include - #include - #include - #include "base/std/container/unordered_map.h" - #include - #include - #include - #include -#endif diff --git a/native/cocos/platform/win32/inet_pton_mingw.cpp b/native/cocos/platform/win32/inet_pton_mingw.cpp deleted file mode 100644 index bc9dd46887..0000000000 --- a/native/cocos/platform/win32/inet_pton_mingw.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* This is from the BIND 4.9.4 release, modified to compile by itself */ - -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/* Portions Copyright (c) Microsoft Open Technologies, Inc. */ - -/*modifications by Microsoft Open Technologies, Inc. to implement missing inet_pton() from Windows 8 SDK */ - -#if defined(__MINGW32__) - - #include - #include - #include - #include - - #define ERRNO ((int)GetLastError()) - #define SET_ERRNO(x) (SetLastError((DWORD)(x))) - - #include "platform/win32/inet_pton_mingw.h" - - #define ENABLE_IPV6 - - #define IN6ADDRSZ 16 - #define INADDRSZ 4 - #define INT16SZ 2 - -/* - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static int inet_pton4(const char *src, unsigned char *dst); - #ifdef ENABLE_IPV6 -static int inet_pton6(const char *src, unsigned char *dst); - #endif - -/* int - * inet_pton(af, src, dst) - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). - * return: - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) - * notice: - * On Windows we store the error in the thread errno, not - * in the winsock error code. This is to avoid losing the - * actual last winsock error. So use macro ERRNO to fetch the - * errno this function sets when returning (-1), not SOCKERRNO. - * author: - * Paul Vixie, 1996. - */ - -int inet_pton(int af, const char *src, void *dst) { - switch (af) { - case AF_INET: - return (inet_pton4(src, (unsigned char *)dst)); - #ifdef ENABLE_IPV6 - case AF_INET6: - return (inet_pton6(src, (unsigned char *)dst)); - #endif - default: - SET_ERRNO(EAFNOSUPPORT); - return (-1); - } - /* NOTREACHED */ -} - -/* int - * inet_pton4(src, dst) - * like inet_aton() but without all the hexadecimal and shorthand. - * return: - * 1 if `src' is a valid dotted quad, else 0. - * notice: - * does not touch `dst' unless it's returning 1. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton4(const char *src, unsigned char *dst) { - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - tp = tmp; - *tp = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - unsigned int val = *tp * 10 + (unsigned int)(pch - digits); - - if (saw_digit && *tp == 0) - return (0); - if (val > 255) - return (0); - *tp = (unsigned char)val; - if (!saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - memcpy(dst, tmp, INADDRSZ); - return (1); -} - - #ifdef ENABLE_IPV6 -/* int - * inet_pton6(src, dst) - * convert presentation level address to network order binary form. - * return: - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * notice: - * (1) does not touch `dst' unless it's returning 1. - * (2) :: in a full address is silently ignored. - * credit: - * inspired by Mark Andrews. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton6(const char *src, unsigned char *dst) { - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - size_t val; - - memset((tp = tmp), 0, IN6ADDRSZ); - endp = tp + IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (++saw_xdigit > 4) - return (0); - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; - } - if (tp + INT16SZ > endp) - return (0); - *tp++ = (unsigned char)(val >> 8) & 0xff; - *tp++ = (unsigned char)val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { - tp += INADDRSZ; - saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (saw_xdigit) { - if (tp + INT16SZ > endp) - return (0); - *tp++ = (unsigned char)(val >> 8) & 0xff; - *tp++ = (unsigned char)val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const ssize_t n = tp - colonp; - ssize_t i; - - if (tp == endp) - return (0); - for (i = 1; i <= n; i++) { - *(endp - i) = *(colonp + n - i); - *(colonp + n - i) = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - memcpy(dst, tmp, IN6ADDRSZ); - return (1); -} - #endif /* ENABLE_IPV6 */ - -#endif /* HAVE_INET_PTON */ diff --git a/native/cocos/platform/win32/inet_pton_mingw.h b/native/cocos/platform/win32/inet_pton_mingw.h deleted file mode 100644 index 550a14d6aa..0000000000 --- a/native/cocos/platform/win32/inet_pton_mingw.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef HEADER_CURL_INET_PTON_MINGW_H -#define HEADER_CURL_INET_PTON_MINGW_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - * Portions Copyright (c) Microsoft Open Technologies, Inc. - * - ***************************************************************************/ - -#if defined(__MINGW32__) -int inet_pton(int af, const char *src, void *dst); -#endif - -#endif /* HEADER_CURL_INET_PTON_MINGW_H */ diff --git a/native/cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.cpp b/native/cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.cpp index 56ca14e9e2..24582ab617 100644 --- a/native/cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.cpp +++ b/native/cocos/platform/win32/modules/CanvasRenderingContext2DDelegate.cpp @@ -28,8 +28,8 @@ namespace { void fillRectWithColor(uint8_t *buf, uint32_t totalWidth, uint32_t totalHeight, uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { - assert(x + width <= totalWidth); - assert(y + height <= totalHeight); + CC_ASSERT(x + width <= totalWidth); + CC_ASSERT(y + height <= totalHeight); uint32_t y0 = y; uint32_t y1 = y + height; diff --git a/native/cocos/renderer/core/PassInstance.cpp b/native/cocos/renderer/core/PassInstance.cpp index 9871ff588f..222f351756 100644 --- a/native/cocos/renderer/core/PassInstance.cpp +++ b/native/cocos/renderer/core/PassInstance.cpp @@ -37,7 +37,7 @@ PassInstance::PassInstance(scene::Pass *parent, MaterialInstance *owner) : Super for (const auto &b : _shaderInfo->blocks) { scene::IBlockRef & block = _blocks[b.binding]; const scene::IBlockRef &parentBlock = _parent->getBlocks()[b.binding]; - assert(block.count == parentBlock.count); + CC_ASSERT(block.count == parentBlock.count); memcpy(block.data, parentBlock.data, parentBlock.count * 4); } diff --git a/native/cocos/renderer/core/PassUtils.cpp b/native/cocos/renderer/core/PassUtils.cpp index 6d2501143c..2efb31fc2b 100644 --- a/native/cocos/renderer/core/PassUtils.cpp +++ b/native/cocos/renderer/core/PassUtils.cpp @@ -168,7 +168,7 @@ const ccstd::unordered_map type2writer = { a[idx + 1] = vec4.y; a[idx + 2] = vec4.z; } else { - assert(false); + CC_ASSERT(false); } }}, {gfx::Type::FLOAT4, [](float *a, const MaterialProperty &v, index_t idx) { @@ -192,7 +192,7 @@ const ccstd::unordered_map type2writer = { a[idx + 2] = quat.z; a[idx + 3] = quat.w; } else { - assert(false); + CC_ASSERT(false); } }}, {gfx::Type::MAT3, [](float *a, const MaterialProperty &v, index_t idx) { diff --git a/native/cocos/renderer/core/ProgramLib.cpp b/native/cocos/renderer/core/ProgramLib.cpp index 2ae06e406f..ff26a83c97 100644 --- a/native/cocos/renderer/core/ProgramLib.cpp +++ b/native/cocos/renderer/core/ProgramLib.cpp @@ -554,7 +554,7 @@ IProgramInfo *ProgramLib::getTemplate(const ccstd::string &name) { ITemplateInfo *ProgramLib::getTemplateInfo(const ccstd::string &name) { auto it = _templates.find(name); - assert(it != _templates.end()); + CC_ASSERT(it != _templates.end()); auto hash = it->second.hash; auto itInfo = _templateInfos.find(hash); return itInfo != _templateInfos.end() ? &itInfo->second : nullptr; @@ -567,7 +567,7 @@ ITemplateInfo *ProgramLib::getTemplateInfo(const ccstd::string &name) { */ gfx::DescriptorSetLayout *ProgramLib::getDescriptorSetLayout(gfx::Device *device, const ccstd::string &name, bool isLocal) { auto itTmpl = _templates.find(name); - assert(itTmpl != _templates.end()); + CC_ASSERT(itTmpl != _templates.end()); const auto &tmpl = itTmpl->second; auto itTplInfo = _templateInfos.find(tmpl.hash); if (itTplInfo == _templateInfos.end()) { @@ -588,7 +588,7 @@ gfx::DescriptorSetLayout *ProgramLib::getDescriptorSetLayout(gfx::Device *device ccstd::string ProgramLib::getKey(const ccstd::string &name, const MacroRecord &defines) { auto itTpl = _templates.find(name); - assert(itTpl != _templates.end()); + CC_ASSERT(itTpl != _templates.end()); auto &tmpl = itTpl->second; auto &tmplDefs = tmpl.defines; if (tmpl.uber) { @@ -668,11 +668,11 @@ gfx::Shader *ProgramLib::getGFXShader(gfx::Device *device, const ccstd::string & } auto itTpl = _templates.find(name); - assert(itTpl != _templates.end()); + CC_ASSERT(itTpl != _templates.end()); const auto &tmpl = itTpl->second; const auto itTplInfo = _templateInfos.find(tmpl.hash); - assert(itTplInfo != _templateInfos.end()); + CC_ASSERT(itTplInfo != _templateInfos.end()); auto &tmplInfo = itTplInfo->second; if (!tmplInfo.pipelineLayout) { diff --git a/native/cocos/renderer/gfx-metal/MTLGPUObjects.h b/native/cocos/renderer/gfx-metal/MTLGPUObjects.h index 038046af65..f20d4fdf6a 100644 --- a/native/cocos/renderer/gfx-metal/MTLGPUObjects.h +++ b/native/cocos/renderer/gfx-metal/MTLGPUObjects.h @@ -201,10 +201,8 @@ public: if (!buffer) { uint mbNeeds = mu::roundUp(gpuBuffer->size, MegaBytesToBytes); mbNeeds = cc::utils::nextPOT(mbNeeds); -#ifdef CC_DEBUG - float realNeeds = gpuBuffer->size / static_cast(MegaBytesToBytes); - assert(mbNeeds > realNeeds); -#endif + CC_ASSERT(mbNeeds > gpuBuffer->size / static_cast(MegaBytesToBytes)); + _pool.resize(bufferCount + 1); buffer = &_pool.back(); if (_tripleEnabled) { diff --git a/native/cocos/renderer/gfx-metal/MTLShader.mm b/native/cocos/renderer/gfx-metal/MTLShader.mm index 7f06ed8a54..355b97c2e6 100644 --- a/native/cocos/renderer/gfx-metal/MTLShader.mm +++ b/native/cocos/renderer/gfx-metal/MTLShader.mm @@ -163,7 +163,7 @@ bool CCMTLShader::createMTLFunction(const ShaderStage &stage) { //delayed instance and pretend tobe specialized function. _gpuShader->specializeColor = false; _gpuShader->shaderSrc = [shader retain]; - assert(_gpuShader->shaderSrc != nil); + CC_ASSERT(_gpuShader->shaderSrc != nil); return true; } } else { diff --git a/native/cocos/renderer/pipeline/custom/FrameGraphDispatcher.cpp b/native/cocos/renderer/pipeline/custom/FrameGraphDispatcher.cpp index e5715eee66..c9cccc69f4 100644 --- a/native/cocos/renderer/pipeline/custom/FrameGraphDispatcher.cpp +++ b/native/cocos/renderer/pipeline/custom/FrameGraphDispatcher.cpp @@ -187,8 +187,8 @@ struct BarrierVisitor : public boost::bfs_visitor<> { auto toIter = std::find_if(toStatus.begin(), toStatus.end(), findAccessByID); // can't happen - assert(fromIter != fromStatus.end()); - assert(toIter != toStatus.end()); + CC_ASSERT(fromIter != fromStatus.end()); + CC_ASSERT(toIter != toStatus.end()); if (!isStatusDependent(*fromIter, *toIter)) { continue; @@ -244,7 +244,7 @@ struct BarrierVisitor : public boost::bfs_visitor<> { [resourceID](const Barrier &barrier) { return resourceID == barrier.resourceID; }); - assert(siblingIter != barrierMap[siblingPass].rearBarriers.end()); + CC_ASSERT(siblingIter != barrierMap[siblingPass].rearBarriers.end()); barrierMap[siblingPass].rearBarriers.erase(siblingIter); } } @@ -314,7 +314,7 @@ struct BarrierVisitor : public boost::bfs_visitor<> { [resourceID](const Barrier &barrier) { return resourceID == barrier.resourceID; }); - assert(siblingIter != barrierMap[siblingPass].frontBarriers.end()); + CC_ASSERT(siblingIter != barrierMap[siblingPass].frontBarriers.end()); barrierMap[siblingPass].frontBarriers.erase(siblingIter); } } diff --git a/native/cocos/renderer/pipeline/custom/JsbConversion.h b/native/cocos/renderer/pipeline/custom/JsbConversion.h index 8bff8818ff..e5e0b5e984 100644 --- a/native/cocos/renderer/pipeline/custom/JsbConversion.h +++ b/native/cocos/renderer/pipeline/custom/JsbConversion.h @@ -57,7 +57,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::vector *to, s return true; } - assert(from.toObject()); + CC_ASSERT(from.toObject()); se::Object *array = from.toObject(); if (array->isArray()) { @@ -75,7 +75,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::vector *to, s } if (array->isTypedArray()) { - assert(std::is_arithmetic::value); + CC_ASSERT(std::is_arithmetic::value); uint8_t *data = nullptr; size_t dataLen = 0; array->getTypedArrayData(&data, &dataLen); diff --git a/native/cocos/storage/local-storage/LocalStorage-android.cpp b/native/cocos/storage/local-storage/LocalStorage-android.cpp index 8d1209f5c3..ba6dbbbfbe 100644 --- a/native/cocos/storage/local-storage/LocalStorage-android.cpp +++ b/native/cocos/storage/local-storage/LocalStorage-android.cpp @@ -27,25 +27,16 @@ THE SOFTWARE. ****************************************************************************/ -/* - Local Storage support for the JS Bindings for iOS. - Works on cocos2d-iphone and cocos2d-x. - */ - -#include "base/Macros.h" #include "storage/local-storage/LocalStorage.h" +#include +#include +#include "base/Macros.h" +#include "jni.h" +#include "platform/java/jni/JniHelper.h" -#if (CC_PLATFORM == CC_PLATFORM_ANDROID) - - #include - #include - #include - #include "jni.h" - #include "platform/java/jni/JniHelper.h" - - #ifndef JCLS_LOCALSTORAGE - #define JCLS_LOCALSTORAGE "com/cocos/lib/CocosLocalStorage" - #endif +#ifndef JCLS_LOCALSTORAGE + #define JCLS_LOCALSTORAGE "com/cocos/lib/CocosLocalStorage" +#endif using namespace cc; //NOLINT static int gInitialized = 0; @@ -81,13 +72,13 @@ void localStorageFree() { /** sets an item in the LS */ void localStorageSetItem(const ccstd::string &key, const ccstd::string &value) { - assert(gInitialized); + CC_ASSERT(gInitialized); JniHelper::callStaticVoidMethod(JCLS_LOCALSTORAGE, "setItem", key, value); } /** gets an item from the LS */ bool localStorageGetItem(const ccstd::string &key, ccstd::string *outItem) { - assert(gInitialized); + CC_ASSERT(gInitialized); JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t, JCLS_LOCALSTORAGE, "getItem", "(Ljava/lang/String;)Ljava/lang/String;")) { @@ -110,26 +101,24 @@ bool localStorageGetItem(const ccstd::string &key, ccstd::string *outItem) { /** removes an item from the LS */ void localStorageRemoveItem(const ccstd::string &key) { - assert(gInitialized); + CC_ASSERT(gInitialized); JniHelper::callStaticVoidMethod(JCLS_LOCALSTORAGE, "removeItem", key); } /** removes all items from the LS */ void localStorageClear() { - assert(gInitialized); + CC_ASSERT(gInitialized); JniHelper::callStaticVoidMethod(JCLS_LOCALSTORAGE, "clear"); } /** gets an key from the JS. */ void localStorageGetKey(const int nIndex, ccstd::string *outKey) { - assert(gInitialized); + CC_ASSERT(gInitialized); outKey->assign(JniHelper::callStaticStringMethod(JCLS_LOCALSTORAGE, "getKey", nIndex)); } /** gets all items count in the JS. */ void localStorageGetLength(int &outLength) { - assert(gInitialized); + CC_ASSERT(gInitialized); outLength = JniHelper::callStaticIntMethod(JCLS_LOCALSTORAGE, "getLength"); } - -#endif // #if (CC_PLATFORM == CC_PLATFORM_ANDROID) diff --git a/native/cocos/storage/local-storage/LocalStorage.cpp b/native/cocos/storage/local-storage/LocalStorage.cpp index 48a972c1f4..5de7bd9b8c 100644 --- a/native/cocos/storage/local-storage/LocalStorage.cpp +++ b/native/cocos/storage/local-storage/LocalStorage.cpp @@ -55,20 +55,17 @@ */ #include "storage/local-storage/LocalStorage.h" +#include +#include + +#if (CC_PLATFORM == CC_PLATFORM_WINDOWS) + #include +#else + #include +#endif + #include "base/Macros.h" -#if (CC_PLATFORM != CC_PLATFORM_ANDROID) - - #include - #include - #include - - #if (CC_PLATFORM == CC_PLATFORM_WINDOWS) - #include - #else - #include - #endif - static int _initialized = 0; static sqlite3 * _db; static sqlite3_stmt *_stmt_select; @@ -146,7 +143,7 @@ void localStorageFree() { /** sets an item in the LS */ void localStorageSetItem(const ccstd::string &key, const ccstd::string &value) { - assert(_initialized); + CC_ASSERT(_initialized); int ok = sqlite3_bind_text(_stmt_update, 1, key.c_str(), -1, SQLITE_TRANSIENT); ok |= sqlite3_bind_text(_stmt_update, 2, value.c_str(), -1, SQLITE_TRANSIENT); @@ -160,7 +157,7 @@ void localStorageSetItem(const ccstd::string &key, const ccstd::string &value) { /** gets an item from the LS */ bool localStorageGetItem(const ccstd::string &key, ccstd::string *outItem) { - assert(_initialized); + CC_ASSERT(_initialized); int ok = sqlite3_reset(_stmt_select); ok |= sqlite3_bind_text(_stmt_select, 1, key.c_str(), -1, SQLITE_TRANSIENT); @@ -180,7 +177,7 @@ bool localStorageGetItem(const ccstd::string &key, ccstd::string *outItem) { /** removes an item from the LS */ void localStorageRemoveItem(const ccstd::string &key) { - assert(_initialized); + CC_ASSERT(_initialized); int ok = sqlite3_bind_text(_stmt_remove, 1, key.c_str(), -1, SQLITE_TRANSIENT); ok |= sqlite3_step(_stmt_remove); @@ -193,7 +190,7 @@ void localStorageRemoveItem(const ccstd::string &key) { /** removes all items from the LS */ void localStorageClear() { - assert(_initialized); + CC_ASSERT(_initialized); int ok = sqlite3_step(_stmt_clear); ok |= sqlite3_reset(_stmt_clear); @@ -204,7 +201,7 @@ void localStorageClear() { /** gets an key from the JS. */ void localStorageGetKey(const int nIndex, ccstd::string *outKey) { - assert(_initialized); + CC_ASSERT(_initialized); if (nIndex < 0) { printf("Error in input localStorage index Less than zero\n"); return; @@ -236,7 +233,7 @@ void localStorageGetKey(const int nIndex, ccstd::string *outKey) { /** gets all items count in the JS. */ void localStorageGetLength(int &outLength) { - assert(_initialized); + CC_ASSERT(_initialized); int ok = sqlite3_reset(_stmt_count); ok |= sqlite3_step(_stmt_count); @@ -248,5 +245,3 @@ void localStorageGetLength(int &outLength) { outLength = sqlite3_column_int(_stmt_count, 0); } } - -#endif // #if (CC_PLATFORM != CC_PLATFORM_ANDROID)