mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
@@ -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
|
||||
)
|
||||
|
||||
@@ -29,8 +29,6 @@ THE SOFTWARE.
|
||||
#include "audio/android/tinysndfile.h"
|
||||
#include "platform/FileUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
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<unsigned char *>(malloc(bufSize));
|
||||
sf_count_t readFrames = sf_readf_short(handle, reinterpret_cast<int16_t *>(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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <cstdint> // To include uint8_t, uint16_t and so on.
|
||||
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
#define CC_ASSERT(cond) assert(cond)
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
|
||||
#include <memory>
|
||||
#include <zlib.h>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include "base/Data.h"
|
||||
#include "base/Locked.h"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "DummyJobGraph.h"
|
||||
#include <cassert>
|
||||
#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++) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ template <typename T>
|
||||
std::enable_if_t<!std::is_base_of<Message, 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<Message *>(_writer.currentMemoryChunk + _writer.offset);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <thread>
|
||||
#include "Event.h"
|
||||
#include "base/Macros.h"
|
||||
#include "base/std/container/list.h"
|
||||
#include "concurrentqueue/concurrentqueue.h"
|
||||
|
||||
@@ -71,14 +71,14 @@ private:
|
||||
|
||||
template <typename Function, typename... Args>
|
||||
auto ThreadPool::dispatchTask(Function &&func, Args &&...args) -> std::future<decltype(func(std::forward<Args>(args)...))> {
|
||||
assert(_running);
|
||||
CC_ASSERT(_running);
|
||||
|
||||
using ReturnType = decltype(func(std::forward<Args>(args)...));
|
||||
auto task = std::make_shared<std::packaged_task<ReturnType()>>(std::bind(std::forward<Function>(func), std::forward<Args>(args)...));
|
||||
bool const succeed = _tasks.enqueue([task]() {
|
||||
(*task)();
|
||||
});
|
||||
assert(succeed);
|
||||
CC_ASSERT(succeed);
|
||||
_event.signal();
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <cmath>
|
||||
@@ -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<T> TypedPrivateObject<T>::share() {
|
||||
if (isSharedPtr()) {
|
||||
return reinterpret_cast<SharedPrivateObject<T> *>(this)->getData();
|
||||
}
|
||||
assert(false);
|
||||
CC_ASSERT(false);
|
||||
return std::shared_ptr<T>(nullptr);
|
||||
}
|
||||
template <typename T>
|
||||
inline cc::IntrusivePtr<T> &TypedPrivateObject<T>::ccShared() {
|
||||
assert(isCCShared());
|
||||
CC_ASSERT(isCCShared());
|
||||
return reinterpret_cast<CCSharedPtrPrivateObject<T> *>(this)->_ptr;
|
||||
}
|
||||
|
||||
@@ -180,7 +179,7 @@ inline void inHeap(void *ptr) {
|
||||
auto anchor = reinterpret_cast<intptr_t>(&a);
|
||||
auto p = reinterpret_cast<intptr_t>(ptr);
|
||||
// must be in heaps
|
||||
assert(abs(anchor - p) > r);
|
||||
CC_ASSERT(abs(anchor - p) > r);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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<uint64_t>(_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();
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "ValueArrayPool.h"
|
||||
#include <cassert>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
#include "v8.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h> // Resolves that memset, memcpy aren't found while APP_PLATFORM >= 22 on Android
|
||||
#include <algorithm> // for std::find
|
||||
#include <chrono>
|
||||
|
||||
@@ -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<v8::Object> Class::_createJSObjectWithClass(Class *cls) { //NOLINT
|
||||
v8::MaybeLocal<v8::Object> ret = cls->_ctorTemplate.Get(__isolate)->InstanceTemplate()->NewInstance(__isolate->GetCurrentContext());
|
||||
assert(!ret.IsEmpty());
|
||||
CC_ASSERT(!ret.IsEmpty());
|
||||
return ret.ToLocalChecked();
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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<v8::Object> typedArray;
|
||||
assert(obj->isArrayBuffer());
|
||||
CC_ASSERT(obj->isArrayBuffer());
|
||||
v8::Local<v8::ArrayBuffer> jsobj = obj->_getJSObject().As<v8::ArrayBuffer>();
|
||||
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<v8::Object> 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<v8::Object> 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<v8::Object> obj = const_cast<Object *>(this)->_obj.handle(__isolate);
|
||||
v8::Local<v8::TypedArray> arr = v8::Local<v8::TypedArray>::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<v8::Object> obj = const_cast<Object *>(this)->_obj.handle(__isolate);
|
||||
v8::Local<v8::ArrayBuffer> arrBuf = v8::Local<v8::ArrayBuffer>::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<Object *>(this);
|
||||
|
||||
v8::MaybeLocal<v8::String> 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<Object *>(this);
|
||||
v8::MaybeLocal<v8::Value> 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<v8::Value> jsval;
|
||||
internal::seToJsValue(__isolate, data, &jsval);
|
||||
@@ -753,7 +753,7 @@ bool Object::setArrayElement(uint32_t index, const Value &data) {
|
||||
}
|
||||
|
||||
bool Object::getAllKeys(ccstd::vector<ccstd::string> *allKeys) const {
|
||||
assert(allKeys != nullptr);
|
||||
CC_ASSERT(allKeys != nullptr);
|
||||
auto * thiz = const_cast<Object *>(this);
|
||||
v8::Local<v8::Context> context = __isolate->GetCurrentContext();
|
||||
v8::MaybeLocal<v8::Array> 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;
|
||||
|
||||
@@ -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<v8::Object> 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<v8::Object> 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<int>(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<int>(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<Object> &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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<v8::Message> message, v8::Local<v
|
||||
v8::Local<v8::String> 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<void()> &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<int>(_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<uint32_t>(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);
|
||||
|
||||
@@ -44,7 +44,7 @@ void jsToSeArgs(const v8::FunctionCallbackInfo<v8::Value> &v8args, ValueArray &o
|
||||
}
|
||||
|
||||
void seToJsArgs(v8::Isolate *isolate, const ValueArray &args, v8::Local<v8::Value> *outArr) {
|
||||
assert(outArr != nullptr);
|
||||
CC_ASSERT(outArr != nullptr);
|
||||
uint32_t i = 0;
|
||||
for (const auto &data : args) {
|
||||
v8::Local<v8::Value> &jsval = outArr[i];
|
||||
@@ -54,7 +54,7 @@ void seToJsArgs(v8::Isolate *isolate, const ValueArray &args, v8::Local<v8::Valu
|
||||
}
|
||||
|
||||
void seToJsValue(v8::Isolate *isolate, const Value &v, v8::Local<v8::Value> *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<v8::Value> *out
|
||||
*outJsVal = v8::BigInt::New(isolate, v.toInt64());
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
CC_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void jsToSeValue(v8::Isolate *isolate, v8::Local<v8::Value> 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<double>(data.toInt64())));
|
||||
} else if (data.getType() == Value::Type::String) {
|
||||
v8::MaybeLocal<v8::String> 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<v8::Value> value) {
|
||||
void setPrivate(v8::Isolate *isolate, ObjectWrap &wrap, PrivateObjectBase *data, Object *thizObj, PrivateData **outInternalData) {
|
||||
v8::Local<v8::Object> 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<v8::Value> value, uint32_t inde
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
assert(index >= 0 && index < 2);
|
||||
CC_ASSERT(index >= 0 && index < 2);
|
||||
if (index > 1) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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<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;
|
||||
@@ -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<ScriptNativeBridge *>(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<ScriptNativeBridge *>(s.nativeThisObject());
|
||||
assert(cobj == ScriptNativeBridge::bridgeCxxInstance);
|
||||
CC_ASSERT(cobj == ScriptNativeBridge::bridgeCxxInstance);
|
||||
delete cobj;
|
||||
ScriptNativeBridge::bridgeCxxInstance = nullptr;
|
||||
return true;
|
||||
|
||||
@@ -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<ScriptNativeBridge *>(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<ScriptNativeBridge *>(s.nativeThisObject());
|
||||
assert(cobj == ScriptNativeBridge::bridgeCxxInstance);
|
||||
CC_ASSERT(cobj == ScriptNativeBridge::bridgeCxxInstance);
|
||||
delete cobj;
|
||||
ScriptNativeBridge::bridgeCxxInstance = nullptr;
|
||||
return true;
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
template <typename T>
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -25,21 +25,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#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 <typename T>
|
||||
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<T>(v.toObject()->getPrivateData());
|
||||
@@ -224,10 +223,10 @@ seval_to_type(const se::Value &v, bool &ok) { // NOLINT(readability-identifier-n
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_pointer<T>::value && std::is_class<typename std::remove_pointer<T>::type>::value, bool>::type
|
||||
seval_to_std_vector(const se::Value &v, ccstd::vector<T> *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<T> *ret) { // NOLINT(reada
|
||||
template <typename T>
|
||||
typename std::enable_if<!std::is_pointer<T>::value, bool>::type
|
||||
seval_to_std_vector(const se::Value &v, ccstd::vector<T> *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<T> *ret) { // NOLINT(reada
|
||||
|
||||
template <typename T>
|
||||
bool seval_to_Map_string_key(const se::Value &v, cc::RefMap<ccstd::string, T> *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<ccstd::string> allKeys;
|
||||
@@ -346,7 +345,7 @@ native_ptr_to_seval(T &v_ref, se::Value *ret, bool *isReturnCachedValue = nullpt
|
||||
using DecayT = typename std::decay<typename std::remove_const<decltype(v_ref)>::type>::type;
|
||||
auto *v = const_cast<DecayT *>(&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 <typename T>
|
||||
bool native_ptr_to_rooted_seval( // NOLINT(readability-identifier-naming)
|
||||
typename std::enable_if<!std::is_base_of<cc::RefCounted, T>::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<void *>(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 <typename T>
|
||||
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<typename std::remove_const<T>::type>::type;
|
||||
auto *v = const_cast<DecayT *>(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 <typename T>
|
||||
bool native_ptr_to_seval(T *vp, se::Value *ret, bool *isReturnCachedValue = nullptr) { // NOLINT(readability-identifier-naming)
|
||||
using DecayT = typename std::decay<typename std::remove_const<T>::type>::type;
|
||||
auto *v = const_cast<DecayT *>(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 <typename T>
|
||||
bool std_vector_to_seval(const ccstd::vector<T> &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<T> &v, se::Value *ret) { // NOLINT(
|
||||
|
||||
template <typename T>
|
||||
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<T *>(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<T>::value) {
|
||||
*to = *static_cast<T *>(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<T> *to, se::Objec
|
||||
|
||||
template <typename T, size_t CNT>
|
||||
bool sevalue_to_native(const se::Value &from, ccstd::array<T, CNT> *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<T, CNT> *to, se::Obje
|
||||
|
||||
template <size_t CNT>
|
||||
bool sevalue_to_native(const se::Value &from, ccstd::array<uint8_t, CNT> *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<uint8_t, CNT> *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<uint32_t>(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<T *>(tmp);
|
||||
@@ -821,7 +820,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::vector<T> *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<T> *to, se::Object *
|
||||
}
|
||||
|
||||
if (array->isTypedArray()) {
|
||||
assert(std::is_arithmetic<T>::value);
|
||||
CC_ASSERT(std::is_arithmetic<T>::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<R(Args...)> *
|
||||
template <typename... Args>
|
||||
inline bool sevalue_to_native(const se::Value & /*from*/, cc::variant<Args...> * /*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<T, is_reference>
|
||||
if CC_CONSTEXPR (std::is_constructible<T>::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<T> *out, se::Objec
|
||||
return true;
|
||||
}
|
||||
auto *privateObject = from.toObject()->getPrivateObject();
|
||||
assert(privateObject->isSharedPtr());
|
||||
CC_ASSERT(privateObject->isSharedPtr());
|
||||
*out = static_cast<se::TypedPrivateObject<T>>(privateObject).share();
|
||||
return true;
|
||||
}
|
||||
@@ -1039,7 +1038,7 @@ bool sevalue_to_native(const se::Value &from, cc::IntrusivePtr<T> *to, se::Objec
|
||||
return ok;
|
||||
}
|
||||
|
||||
assert(privateObject->isCCShared());
|
||||
CC_ASSERT(privateObject->isCCShared());
|
||||
*to = static_cast<se::CCSharedPtrPrivateObject<T> *>(privateObject)->ccShared();
|
||||
return true;
|
||||
}
|
||||
@@ -1384,10 +1383,10 @@ bool nativevalue_to_se(const spine::Vector<T *> &v, se::Value &ret, se::Object *
|
||||
|
||||
template <typename T>
|
||||
bool sevalue_to_native(const se::Value &v, spine::Vector<T *> *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<T> &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<T> &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));
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace {
|
||||
|
||||
template <typename T>
|
||||
bool std_vector_T_to_seval(const ccstd::vector<T> &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::variant<cc::monostate, cc::Mat
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
bool sevalue_to_native(const se::Value &from, cc::ArrayBuffer *to, se::Object * /*ctx*/) {
|
||||
assert(from.isObject());
|
||||
CC_ASSERT(from.isObject());
|
||||
to->setJSArrayBuffer(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<unsigned char> *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<spine::String> *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<spine::String> *ret, se
|
||||
#if CC_USE_MIDDLEWARE
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
bool seval_to_Map_string_key(const se::Value &v, cc::RefMap<ccstd::string, cc::middleware::Texture2D *> *ret) {
|
||||
assert(ret != nullptr);
|
||||
assert(v.isObject());
|
||||
CC_ASSERT(ret != nullptr);
|
||||
CC_ASSERT(v.isObject());
|
||||
se::Object *obj = v.toObject();
|
||||
|
||||
ccstd::vector<ccstd::string> allKeys;
|
||||
@@ -1252,7 +1252,7 @@ bool seval_to_Map_string_key(const se::Value &v, cc::RefMap<ccstd::string, cc::m
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
bool ccvalue_to_seval(const cc::Value &v, se::Value *ret) { // NOLINT
|
||||
assert(ret != nullptr);
|
||||
CC_ASSERT(ret != nullptr);
|
||||
bool ok = true;
|
||||
switch (v.getType()) {
|
||||
case cc::Value::Type::NONE:
|
||||
@@ -1294,7 +1294,7 @@ bool ccvalue_to_seval(const cc::Value &v, se::Value *ret) { // NOLINT
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
bool ccvaluemap_to_seval(const cc::ValueMap &v, se::Value *ret) { // NOLINT
|
||||
assert(ret != nullptr);
|
||||
CC_ASSERT(ret != nullptr);
|
||||
|
||||
se::HandleObject obj(se::Object::createPlainObject());
|
||||
bool ok = true;
|
||||
@@ -1324,7 +1324,7 @@ bool ccvaluemap_to_seval(const cc::ValueMap &v, se::Value *ret) { // NOLINT
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
bool ccvaluemapintkey_to_seval(const cc::ValueMapIntKey &v, se::Value *ret) { // NOLINT
|
||||
assert(ret != nullptr);
|
||||
CC_ASSERT(ret != nullptr);
|
||||
|
||||
se::HandleObject obj(se::Object::createPlainObject());
|
||||
bool ok = true;
|
||||
@@ -1356,7 +1356,7 @@ bool ccvaluemapintkey_to_seval(const cc::ValueMapIntKey &v, se::Value *ret) { //
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
bool ccvaluevector_to_seval(const cc::ValueVector &v, se::Value *ret) { // NOLINT
|
||||
assert(ret != nullptr);
|
||||
CC_ASSERT(ret != nullptr);
|
||||
se::HandleObject obj(se::Object::createArrayObject(v.size()));
|
||||
bool ok = true;
|
||||
|
||||
@@ -1381,7 +1381,7 @@ bool ccvaluevector_to_seval(const cc::ValueVector &v, se::Value *ret) { // NOLIN
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
bool ManifestAsset_to_seval(const cc::extension::ManifestAsset &v, se::Value *ret) {
|
||||
assert(ret != nullptr);
|
||||
CC_ASSERT(ret != nullptr);
|
||||
se::HandleObject obj(se::Object::createPlainObject());
|
||||
obj->setProperty("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<cc::physics::ConvexDesc *>(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<cc::physics::TrimeshDesc *>(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<cc::physics::HeightFieldDesc *>(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<cc::physics::RaycastOptions *>(json->getPrivateData());
|
||||
if (data) {
|
||||
|
||||
@@ -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<se::Value> *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<se::Value> *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<void *>(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;
|
||||
}
|
||||
|
||||
@@ -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<uint8_t *>(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<uint8_t *>(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;
|
||||
}
|
||||
|
||||
@@ -125,8 +125,8 @@ ccstd::unordered_map<ccstd::string, se::Value> gModuleCache;
|
||||
static bool require(se::State &s) { //NOLINT
|
||||
const auto &args = s.args();
|
||||
int argc = static_cast<int>(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<int>(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);
|
||||
}
|
||||
|
||||
@@ -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<void(const uint8_t *, size_t)> &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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -44,7 +44,7 @@ using namespace cc;
|
||||
static spine::Cocos2dTextureLoader textureLoader;
|
||||
static cc::RefMap<ccstd::string, middleware::Texture2D *> *_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;
|
||||
}
|
||||
|
||||
@@ -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<unsigned int>(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;"
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "AABB.h"
|
||||
|
||||
#include <cassert>
|
||||
#include "base/Macros.h"
|
||||
#include "cocos/core/geometry/Enums.h"
|
||||
#include "cocos/core/geometry/Sphere.h"
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void Capsule::updateLocalCenter() {
|
||||
ellipseCenter1 = {0, 0, -halfHeight};
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
CC_ASSERT(false);
|
||||
}
|
||||
}
|
||||
} // namespace geometry
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#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; }
|
||||
|
||||
@@ -400,7 +400,7 @@ template <typename T1, typename T2>
|
||||
auto intersects(const T1 & /*a*/, const T2 & /*b*/) {
|
||||
static_assert(std::is_base_of<T1, ShapeBase>::value, "type is not base of ShapeBase");
|
||||
static_assert(std::is_base_of<T2, ShapeBase>::value, "type is not base of ShapeBase");
|
||||
assert(false); // mismatch
|
||||
CC_ASSERT(false); // mismatch
|
||||
}
|
||||
|
||||
#define DECLARE_EXCHANGABLE_INTERSECT(TYPE1, TYPE2, FN) \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include "WebSocket.h"
|
||||
#include "application/ApplicationManager.h"
|
||||
#include "base/Scheduler.h"
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include "application/ApplicationManager.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "Image.h"
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include "base/Config.h" // CC_USE_JPEG, CC_USE_WEBP
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ Screen::Orientation Screen::getDeviceOrientation() const {
|
||||
orientation = Orientation::PORTRAIT;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
CC_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ CanvasRenderingContext2DDelegate::Size CanvasRenderingContext2DDelegate::sizeWit
|
||||
// if (text.empty())
|
||||
// return ccstd::array<float, 2>{0.0f, 0.0f};
|
||||
// XFontStruct *fs = XLoadQueryFont(dpy, "cursor");
|
||||
// assert(fs);
|
||||
// CC_ASSERT(fs);
|
||||
// int font_ascent = 0;
|
||||
// int font_descent = 0;
|
||||
// XCharStruct overall;
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'cocos2dx' target in the 'cocos2dx' project
|
||||
//
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "base/std/container/strig.h"
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include "base/std/container/unordered_map.h"
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <stack>
|
||||
#endif
|
||||
@@ -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 <errno.h>
|
||||
#include <assert.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <Winsock2.h>
|
||||
|
||||
#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 */
|
||||
@@ -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, <daniel@haxx.se>, 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 */
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ const ccstd::unordered_map<gfx::Type, GFXTypeWriterCallback> 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<gfx::Type, GFXTypeWriterCallback> 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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<float>(MegaBytesToBytes);
|
||||
assert(mbNeeds > realNeeds);
|
||||
#endif
|
||||
CC_ASSERT(mbNeeds > gpuBuffer->size / static_cast<float>(MegaBytesToBytes));
|
||||
|
||||
_pool.resize(bufferCount + 1);
|
||||
buffer = &_pool.back();
|
||||
if (_tripleEnabled) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ bool sevalue_to_native(const se::Value &from, ccstd::vector<T, allocator> *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<T, allocator> *to, s
|
||||
}
|
||||
|
||||
if (array->isTypedArray()) {
|
||||
assert(std::is_arithmetic<T>::value);
|
||||
CC_ASSERT(std::is_arithmetic<T>::value);
|
||||
uint8_t *data = nullptr;
|
||||
size_t dataLen = 0;
|
||||
array->getTypedArrayData(&data, &dataLen);
|
||||
|
||||
@@ -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 <cstdio>
|
||||
#include <cstdlib>
|
||||
#include "base/Macros.h"
|
||||
#include "jni.h"
|
||||
#include "platform/java/jni/JniHelper.h"
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#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)
|
||||
|
||||
@@ -55,20 +55,17 @@
|
||||
*/
|
||||
|
||||
#include "storage/local-storage/LocalStorage.h"
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
|
||||
#include <sqlite3/sqlite3.h>
|
||||
#else
|
||||
#include <sqlite3.h>
|
||||
#endif
|
||||
|
||||
#include "base/Macros.h"
|
||||
|
||||
#if (CC_PLATFORM != CC_PLATFORM_ANDROID)
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
|
||||
#include <sqlite3/sqlite3.h>
|
||||
#else
|
||||
#include <sqlite3.h>
|
||||
#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)
|
||||
|
||||
Reference in New Issue
Block a user