提交 09a5d287 编写于 作者: “zhangboyuan”

ipc告警处理

Signed-off-by: N“zhangboyuan” <zhangboyuan1@huawei.com>
上级 8285463f
......@@ -47,9 +47,9 @@ public:
static IRemoteInvoker *GetProxyInvoker(IRemoteObject *object);
// Joint Current thread into IPC Work Group
void JoinWorkThread(int proto);
void JoinWorkThread(int prot);
// Quit current thread from IPC work group.
void StopWorkThread(int proto);
void StopWorkThread(int prot);
private:
static pthread_key_t TLSKey_;
......
......@@ -90,23 +90,23 @@ char *BufferObject::GetSendBufferAndLock(uint32_t size)
}
sendMutex_.lock();
if (needSize > sendBuffSize_) {
char *newBuffer_ = new (std::nothrow) char[needSize];
if (newBuffer_ == nullptr) {
char *newBuffer = new (std::nothrow) char[needSize];
if (newBuffer == nullptr) {
sendMutex_.unlock();
return nullptr;
}
if ((sendBuffer_ != nullptr) && (sendBuffSize_ != 0)) {
int memcpyResult = memcpy_s(newBuffer_, needSize, sendBuffer_, sendBuffSize_);
int memcpyResult = memcpy_s(newBuffer, needSize, sendBuffer_, sendBuffSize_);
if (memcpyResult != 0) {
delete[] newBuffer_;
delete[] newBuffer;
sendMutex_.unlock();
return nullptr;
}
}
delete[] sendBuffer_;
sendBuffer_ = newBuffer_;
sendBuffer_ = newBuffer;
sendBuffSize_ = needSize;
}
......@@ -122,23 +122,23 @@ char *BufferObject::GetReceiveBufferAndLock(uint32_t size)
}
recvMutex_.lock();
if (needSize > recvBuffSize_) {
char *newBuffer_ = new (std::nothrow) char[needSize];
if (newBuffer_ == nullptr) {
char *newBuffer = new (std::nothrow) char[needSize];
if (newBuffer == nullptr) {
recvMutex_.unlock();
return nullptr;
}
if ((receiveBuffer_ != nullptr) && (recvBuffSize_ != 0)) {
int memcpyResult = memcpy_s(newBuffer_, needSize, receiveBuffer_, recvBuffSize_);
int memcpyResult = memcpy_s(newBuffer, needSize, receiveBuffer_, recvBuffSize_);
if (memcpyResult != 0) {
delete[] newBuffer_;
delete[] newBuffer;
recvMutex_.unlock();
return nullptr;
}
}
delete[] receiveBuffer_;
receiveBuffer_ = newBuffer_;
receiveBuffer_ = newBuffer;
recvBuffSize_ = needSize;
}
......
......@@ -108,12 +108,12 @@ private:
int WaitForReply(uint64_t seqNumber, MessageParcel *reply, std::shared_ptr<T> sessionObject, int userWaitTime);
void ProcessTransaction(dbinder_transaction_data *tr, uint32_t listenFd);
void ProcessReply(dbinder_transaction_data *tr, uint32_t listenFd);
bool IRemoteObjectTranslate(char *dataBuffer, binder_size_t buffer_size, MessageParcel &data, uint32_t socketId,
bool IRemoteObjectTranslate(char *dataBuffer, binder_size_t bufferSize, MessageParcel &data, uint32_t socketId,
std::shared_ptr<T> sessionObject);
bool TranslateRawData(char *dataBuffer, MessageParcel &data, uint32_t socketId);
std::shared_ptr<T> GetSessionObject(uint32_t handle, uint32_t socketId);
uint64_t GetUniqueSeqNumber(int cmd);
void ConstructTransData(dbinder_transaction_data &TransData, size_t totalSize, uint64_t seqNum, int cmd, __u32 code,
void ConstructTransData(dbinder_transaction_data &transData, size_t totalSize, uint64_t seqNum, int cmd, __u32 code,
__u32 flags);
bool ProcessRawData(std::shared_ptr<T> sessionObject, MessageParcel &data, uint64_t seqNum);
std::shared_ptr<dbinder_transaction_data> ProcessNormalData(std::shared_ptr<T> sessionObject, MessageParcel &data,
......@@ -227,7 +227,7 @@ bool DBinderBaseInvoker<T>::TranslateRemoteHandleType(flat_binder_object *binder
/* check data parcel contains object, if yes, get its session as payload of socket packet */
template <class T>
bool DBinderBaseInvoker<T>::IRemoteObjectTranslate(char *dataBuffer, binder_size_t buffer_size, MessageParcel &data,
bool DBinderBaseInvoker<T>::IRemoteObjectTranslate(char *dataBuffer, binder_size_t bufferSize, MessageParcel &data,
uint32_t socketId, std::shared_ptr<T> sessionObject)
{
if (data.GetOffsetsSize() <= 0 || dataBuffer == nullptr) {
......@@ -236,7 +236,7 @@ bool DBinderBaseInvoker<T>::IRemoteObjectTranslate(char *dataBuffer, binder_size
uint32_t totalSize = 0;
binder_size_t *binderObjectsOffsets = reinterpret_cast<binder_size_t *>(data.GetObjectOffsets());
uint32_t offsetOfSession = buffer_size + data.GetOffsetsSize() * sizeof(binder_size_t);
uint32_t offsetOfSession = bufferSize + data.GetOffsetsSize() * sizeof(binder_size_t);
char *flatOffset = dataBuffer + offsetOfSession;
for (size_t i = 0; i < data.GetOffsetsSize(); i++) {
......@@ -353,20 +353,20 @@ template <class T> uint64_t DBinderBaseInvoker<T>::GetUniqueSeqNumber(int cmd)
}
template <class T>
void DBinderBaseInvoker<T>::ConstructTransData(dbinder_transaction_data &TransData, size_t totalSize, uint64_t seqNum,
void DBinderBaseInvoker<T>::ConstructTransData(dbinder_transaction_data &transData, size_t totalSize, uint64_t seqNum,
int cmd, __u32 code, __u32 flags)
{
TransData.sizeOfSelf = totalSize;
TransData.magic = DBINDER_MAGICWORD;
TransData.version = VERSION_NUM;
TransData.cmd = cmd;
TransData.code = code;
TransData.flags = flags;
TransData.cookie = 0;
TransData.seqNumber = seqNum;
TransData.buffer_size = 0;
TransData.offsets_size = 0;
TransData.offsets = 0;
transData.sizeOfSelf = totalSize;
transData.magic = DBINDER_MAGICWORD;
transData.version = VERSION_NUM;
transData.cmd = cmd;
transData.code = code;
transData.flags = flags;
transData.cookie = 0;
transData.seqNumber = seqNum;
transData.buffer_size = 0;
transData.offsets_size = 0;
transData.offsets = 0;
}
template <class T>
......
......@@ -350,7 +350,7 @@ void BinderInvoker::OnBinderDied()
void BinderInvoker::OnAcquireObject(uint32_t cmd)
{
bool ParcelResult = false;
bool parcelResult = false;
uintptr_t refsPointer = input_.ReadPointer();
uintptr_t objectPointer = input_.ReadPointer();
RefBase *refs = reinterpret_cast<IRemoteObject *>(refsPointer);
......@@ -362,13 +362,13 @@ void BinderInvoker::OnAcquireObject(uint32_t cmd)
size_t rewindPos = output_.GetWritePosition();
if (cmd == BR_ACQUIRE) {
refs->IncStrongRef(this);
ParcelResult = output_.WriteInt32(BC_ACQUIRE_DONE);
parcelResult = output_.WriteInt32(BC_ACQUIRE_DONE);
} else {
refs->IncWeakRef(this);
ParcelResult = output_.WriteInt32(BC_INCREFS_DONE);
parcelResult = output_.WriteInt32(BC_INCREFS_DONE);
}
if (!ParcelResult || !output_.WritePointer(refsPointer)) {
if (!parcelResult || !output_.WritePointer(refsPointer)) {
if (!output_.RewindWrite(rewindPos)) {
output_.FlushBuffer();
}
......
......@@ -44,7 +44,7 @@ public:
}
static napi_value AshmemExport(napi_env env, napi_value exports);
private:
static napi_value Ashmem_JS_Constructor(napi_env env, napi_callback_info cbinfo);
static napi_value Ashmem_JS_Constructor(napi_env env, napi_callback_info info);
static napi_value CloseAshmem(napi_env env, napi_callback_info info);
static napi_value CreateAshmem(napi_env env, napi_callback_info info);
static napi_value Create(napi_env env, napi_callback_info info);
......@@ -64,9 +64,9 @@ private:
static napi_value WriteToAshmem(napi_env env, napi_callback_info info);
static napi_value WriteAshmem(napi_env env, napi_callback_info info);
static napi_value GetAshmemFromExisting(napi_env env, napi_callback_info info);
static napi_value GetAshmemConstructor(napi_env env, napi_value* info);
static napi_value getNewAshmemConstructor(napi_env env, napi_value& info, int32_t fd, uint32_t size);
static napi_value CheckWriteAshmemParams(napi_env env, size_t argc, napi_value* info);
static napi_value GetAshmemConstructor(napi_env env, napi_value* argv);
static napi_value getNewAshmemConstructor(napi_env env, napi_value& constructor, int32_t fd, uint32_t size);
static napi_value CheckWriteAshmemParams(napi_env env, size_t argc, napi_value* argv);
static napi_value TransferByteToJsData(napi_env env, uint32_t size, const void *result);
sptr<Ashmem> ashmem_;
......
......@@ -32,68 +32,68 @@ public:
static napi_value Export(napi_env env, napi_value exports);
private:
// Napi methods and properties
static napi_value JS_create(napi_env env, napi_callback_info cbinfo);
static napi_value JS_reclaim(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeRemoteObject(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readRemoteObject(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeInterfaceToken(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readInterfaceToken(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getSize(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getCapacity(napi_env env, napi_callback_info cbinfo);
static napi_value JS_setSize(napi_env env, napi_callback_info cbinfo);
static napi_value JS_setCapacity(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getWritableBytes(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getReadableBytes(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getReadPosition(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getWritePosition(napi_env env, napi_callback_info cbinfo);
static napi_value JS_rewindWrite(napi_env env, napi_callback_info cbinfo);
static napi_value JS_rewindRead(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeNoException(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readException(napi_env env, napi_callback_info cbinfo);
static napi_value JS_create(napi_env env, napi_callback_info info);
static napi_value JS_reclaim(napi_env env, napi_callback_info info);
static napi_value JS_writeRemoteObject(napi_env env, napi_callback_info info);
static napi_value JS_readRemoteObject(napi_env env, napi_callback_info info);
static napi_value JS_writeInterfaceToken(napi_env env, napi_callback_info info);
static napi_value JS_readInterfaceToken(napi_env env, napi_callback_info info);
static napi_value JS_getSize(napi_env env, napi_callback_info info);
static napi_value JS_getCapacity(napi_env env, napi_callback_info info);
static napi_value JS_setSize(napi_env env, napi_callback_info info);
static napi_value JS_setCapacity(napi_env env, napi_callback_info info);
static napi_value JS_getWritableBytes(napi_env env, napi_callback_info info);
static napi_value JS_getReadableBytes(napi_env env, napi_callback_info info);
static napi_value JS_getReadPosition(napi_env env, napi_callback_info info);
static napi_value JS_getWritePosition(napi_env env, napi_callback_info info);
static napi_value JS_rewindWrite(napi_env env, napi_callback_info info);
static napi_value JS_rewindRead(napi_env env, napi_callback_info info);
static napi_value JS_writeNoException(napi_env env, napi_callback_info info);
static napi_value JS_readException(napi_env env, napi_callback_info info);
static napi_value JS_writeByte(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeShort(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeInt(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeLong(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeFloat(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeDouble(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeBoolean(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeChar(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeString(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeSequenceable(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeByteArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeShortArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeIntArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeLongArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeFloatArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeDoubleArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeBooleanArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeCharArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeStringArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeSequenceableArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeRemoteObjectArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeByte(napi_env env, napi_callback_info info);
static napi_value JS_writeShort(napi_env env, napi_callback_info info);
static napi_value JS_writeInt(napi_env env, napi_callback_info info);
static napi_value JS_writeLong(napi_env env, napi_callback_info info);
static napi_value JS_writeFloat(napi_env env, napi_callback_info info);
static napi_value JS_writeDouble(napi_env env, napi_callback_info info);
static napi_value JS_writeBoolean(napi_env env, napi_callback_info info);
static napi_value JS_writeChar(napi_env env, napi_callback_info info);
static napi_value JS_writeString(napi_env env, napi_callback_info info);
static napi_value JS_writeSequenceable(napi_env env, napi_callback_info info);
static napi_value JS_writeByteArray(napi_env env, napi_callback_info info);
static napi_value JS_writeShortArray(napi_env env, napi_callback_info info);
static napi_value JS_writeIntArray(napi_env env, napi_callback_info info);
static napi_value JS_writeLongArray(napi_env env, napi_callback_info info);
static napi_value JS_writeFloatArray(napi_env env, napi_callback_info info);
static napi_value JS_writeDoubleArray(napi_env env, napi_callback_info info);
static napi_value JS_writeBooleanArray(napi_env env, napi_callback_info info);
static napi_value JS_writeCharArray(napi_env env, napi_callback_info info);
static napi_value JS_writeStringArray(napi_env env, napi_callback_info info);
static napi_value JS_writeSequenceableArray(napi_env env, napi_callback_info info);
static napi_value JS_writeRemoteObjectArray(napi_env env, napi_callback_info info);
static napi_value JS_readByte(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readShort(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readInt(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readLong(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readFloat(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readDouble(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readBoolean(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readChar(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readString(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readSequenceable(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readByteArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readShortArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readIntArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readLongArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readFloatArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readDoubleArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readBooleanArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readCharArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readStringArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readSequenceableArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readRemoteObjectArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readByte(napi_env env, napi_callback_info info);
static napi_value JS_readShort(napi_env env, napi_callback_info info);
static napi_value JS_readInt(napi_env env, napi_callback_info info);
static napi_value JS_readLong(napi_env env, napi_callback_info info);
static napi_value JS_readFloat(napi_env env, napi_callback_info info);
static napi_value JS_readDouble(napi_env env, napi_callback_info info);
static napi_value JS_readBoolean(napi_env env, napi_callback_info info);
static napi_value JS_readChar(napi_env env, napi_callback_info info);
static napi_value JS_readString(napi_env env, napi_callback_info info);
static napi_value JS_readSequenceable(napi_env env, napi_callback_info info);
static napi_value JS_readByteArray(napi_env env, napi_callback_info info);
static napi_value JS_readShortArray(napi_env env, napi_callback_info info);
static napi_value JS_readIntArray(napi_env env, napi_callback_info info);
static napi_value JS_readLongArray(napi_env env, napi_callback_info info);
static napi_value JS_readFloatArray(napi_env env, napi_callback_info info);
static napi_value JS_readDoubleArray(napi_env env, napi_callback_info info);
static napi_value JS_readBooleanArray(napi_env env, napi_callback_info info);
static napi_value JS_readCharArray(napi_env env, napi_callback_info info);
static napi_value JS_readStringArray(napi_env env, napi_callback_info info);
static napi_value JS_readSequenceableArray(napi_env env, napi_callback_info info);
static napi_value JS_readRemoteObjectArray(napi_env env, napi_callback_info info);
static napi_value JS_CloseFileDescriptor(napi_env env, napi_callback_info info);
static napi_value JS_DupFileDescriptor(napi_env env, napi_callback_info info);
......@@ -106,7 +106,7 @@ private:
static napi_value JS_WriteRawData(napi_env env, napi_callback_info info);
static napi_value JS_ReadRawData(napi_env env, napi_callback_info info);
static napi_value JS_constructor(napi_env env, napi_callback_info cbinfo);
static napi_value JS_constructor(napi_env env, napi_callback_info info);
static void release(MessageParcel *parcel);
napi_env env_ = nullptr;
......
......@@ -33,68 +33,68 @@ public:
static napi_value Export(napi_env env, napi_value exports);
private:
// Napi methods and properties
static napi_value JS_create(napi_env env, napi_callback_info cbinfo);
static napi_value JS_reclaim(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeRemoteObject(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readRemoteObject(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeInterfaceToken(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readInterfaceToken(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getSize(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getCapacity(napi_env env, napi_callback_info cbinfo);
static napi_value JS_setSize(napi_env env, napi_callback_info cbinfo);
static napi_value JS_setCapacity(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getWritableBytes(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getReadableBytes(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getReadPosition(napi_env env, napi_callback_info cbinfo);
static napi_value JS_getWritePosition(napi_env env, napi_callback_info cbinfo);
static napi_value JS_rewindWrite(napi_env env, napi_callback_info cbinfo);
static napi_value JS_rewindRead(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeNoException(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readException(napi_env env, napi_callback_info cbinfo);
static napi_value JS_create(napi_env env, napi_callback_info info);
static napi_value JS_reclaim(napi_env env, napi_callback_info info);
static napi_value JS_writeRemoteObject(napi_env env, napi_callback_info info);
static napi_value JS_readRemoteObject(napi_env env, napi_callback_info info);
static napi_value JS_writeInterfaceToken(napi_env env, napi_callback_info info);
static napi_value JS_readInterfaceToken(napi_env env, napi_callback_info info);
static napi_value JS_getSize(napi_env env, napi_callback_info info);
static napi_value JS_getCapacity(napi_env env, napi_callback_info info);
static napi_value JS_setSize(napi_env env, napi_callback_info info);
static napi_value JS_setCapacity(napi_env env, napi_callback_info info);
static napi_value JS_getWritableBytes(napi_env env, napi_callback_info info);
static napi_value JS_getReadableBytes(napi_env env, napi_callback_info info);
static napi_value JS_getReadPosition(napi_env env, napi_callback_info info);
static napi_value JS_getWritePosition(napi_env env, napi_callback_info info);
static napi_value JS_rewindWrite(napi_env env, napi_callback_info info);
static napi_value JS_rewindRead(napi_env env, napi_callback_info info);
static napi_value JS_writeNoException(napi_env env, napi_callback_info info);
static napi_value JS_readException(napi_env env, napi_callback_info info);
static napi_value JS_writeByte(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeShort(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeInt(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeLong(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeFloat(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeDouble(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeBoolean(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeChar(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeString(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeParcelable(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeByteArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeShortArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeIntArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeLongArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeFloatArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeDoubleArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeBooleanArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeCharArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeStringArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeParcelableArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeRemoteObjectArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_writeByte(napi_env env, napi_callback_info info);
static napi_value JS_writeShort(napi_env env, napi_callback_info info);
static napi_value JS_writeInt(napi_env env, napi_callback_info info);
static napi_value JS_writeLong(napi_env env, napi_callback_info info);
static napi_value JS_writeFloat(napi_env env, napi_callback_info info);
static napi_value JS_writeDouble(napi_env env, napi_callback_info info);
static napi_value JS_writeBoolean(napi_env env, napi_callback_info info);
static napi_value JS_writeChar(napi_env env, napi_callback_info info);
static napi_value JS_writeString(napi_env env, napi_callback_info info);
static napi_value JS_writeParcelable(napi_env env, napi_callback_info info);
static napi_value JS_writeByteArray(napi_env env, napi_callback_info info);
static napi_value JS_writeShortArray(napi_env env, napi_callback_info info);
static napi_value JS_writeIntArray(napi_env env, napi_callback_info info);
static napi_value JS_writeLongArray(napi_env env, napi_callback_info info);
static napi_value JS_writeFloatArray(napi_env env, napi_callback_info info);
static napi_value JS_writeDoubleArray(napi_env env, napi_callback_info info);
static napi_value JS_writeBooleanArray(napi_env env, napi_callback_info info);
static napi_value JS_writeCharArray(napi_env env, napi_callback_info info);
static napi_value JS_writeStringArray(napi_env env, napi_callback_info info);
static napi_value JS_writeParcelableArray(napi_env env, napi_callback_info info);
static napi_value JS_writeRemoteObjectArray(napi_env env, napi_callback_info info);
static napi_value JS_readByte(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readShort(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readInt(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readLong(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readFloat(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readDouble(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readBoolean(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readChar(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readString(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readParcelable(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readByteArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readShortArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readIntArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readLongArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readFloatArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readDoubleArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readBooleanArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readCharArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readStringArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readParcelableArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readRemoteObjectArray(napi_env env, napi_callback_info cbinfo);
static napi_value JS_readByte(napi_env env, napi_callback_info info);
static napi_value JS_readShort(napi_env env, napi_callback_info info);
static napi_value JS_readInt(napi_env env, napi_callback_info info);
static napi_value JS_readLong(napi_env env, napi_callback_info info);
static napi_value JS_readFloat(napi_env env, napi_callback_info info);
static napi_value JS_readDouble(napi_env env, napi_callback_info info);
static napi_value JS_readBoolean(napi_env env, napi_callback_info info);
static napi_value JS_readChar(napi_env env, napi_callback_info info);
static napi_value JS_readString(napi_env env, napi_callback_info info);
static napi_value JS_readParcelable(napi_env env, napi_callback_info info);
static napi_value JS_readByteArray(napi_env env, napi_callback_info info);
static napi_value JS_readShortArray(napi_env env, napi_callback_info info);
static napi_value JS_readIntArray(napi_env env, napi_callback_info info);
static napi_value JS_readLongArray(napi_env env, napi_callback_info info);
static napi_value JS_readFloatArray(napi_env env, napi_callback_info info);
static napi_value JS_readDoubleArray(napi_env env, napi_callback_info info);
static napi_value JS_readBooleanArray(napi_env env, napi_callback_info info);
static napi_value JS_readCharArray(napi_env env, napi_callback_info info);
static napi_value JS_readStringArray(napi_env env, napi_callback_info info);
static napi_value JS_readParcelableArray(napi_env env, napi_callback_info info);
static napi_value JS_readRemoteObjectArray(napi_env env, napi_callback_info info);
static napi_value JS_CloseFileDescriptor(napi_env env, napi_callback_info info);
static napi_value JS_DupFileDescriptor(napi_env env, napi_callback_info info);
......@@ -107,7 +107,7 @@ private:
static napi_value JS_WriteRawData(napi_env env, napi_callback_info info);
static napi_value JS_ReadRawData(napi_env env, napi_callback_info info);
static napi_value JS_constructor(napi_env env, napi_callback_info cbinfo);
static napi_value JS_constructor(napi_env env, napi_callback_info info);
static void release(MessageParcel *parcel);
static napi_value JS_checkWriteByteArrayArgs(napi_env env, size_t argc, napi_value* argv, uint32_t &arrayLength);
......
......@@ -38,11 +38,11 @@ EXTERN_C_END
*/
class NAPIDeathRecipient : public IRemoteObject::DeathRecipient {
public:
explicit NAPIDeathRecipient(napi_env env, napi_value jsRecipient);
explicit NAPIDeathRecipient(napi_env env, napi_value jsDeathRecipient);
void OnRemoteDied(const wptr<IRemoteObject> &object) override;
bool Matches(napi_value jsRecipient);
bool Matches(napi_value object);
protected:
virtual ~NAPIDeathRecipient();
......
......@@ -49,7 +49,7 @@ public:
NapiError() {};
NapiError(int32_t errorCode) : errorCode_(errorCode) {};
napi_value GetError(napi_env& env) const;
napi_value ThrowError(napi_env& env, int32_t errorCode = -1);
napi_value ThrowError(napi_env& env, int32_t code = -1);
inline void Error(int32_t errorCode)
{
errorCode_ = (errorCode != -1) ? errorCode : errorCode_;
......
......@@ -98,7 +98,7 @@ napi_value NapiOhosRpcMessageOptionSetAsync(napi_env env, napi_callback_info inf
MessageOption *option = nullptr;
napi_unwrap(env, thisVar, (void **)&option);
NAPI_ASSERT(env, option != nullptr, "failed to get native message option");
option->SetFlags(static_cast<int32_t> (flags));
option->SetFlags(static_cast<int32_t>(flags));
napi_value result = nullptr;
napi_get_undefined(env, &result);
return result;
......
......@@ -919,7 +919,7 @@ napi_value NAPI_MessageParcel::JS_readByte(napi_env env, napi_callback_info info
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
int8_t value = napiParcel->nativeParcel_->ReadInt8();
napi_value napiValue = nullptr;
......@@ -934,7 +934,7 @@ napi_value NAPI_MessageParcel::JS_readShort(napi_env env, napi_callback_info inf
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
int16_t value = napiParcel->nativeParcel_->ReadInt16();
napi_value napiValue = nullptr;
......@@ -949,7 +949,7 @@ napi_value NAPI_MessageParcel::JS_readInt(napi_env env, napi_callback_info info)
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
int32_t value = napiParcel->nativeParcel_->ReadInt32();
napi_value napiValue = nullptr;
......@@ -964,7 +964,7 @@ napi_value NAPI_MessageParcel::JS_readLong(napi_env env, napi_callback_info info
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
int64_t value = napiParcel->nativeParcel_->ReadInt64();
napi_value napiValue = nullptr;
......@@ -979,7 +979,7 @@ napi_value NAPI_MessageParcel::JS_readFloat(napi_env env, napi_callback_info inf
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
double value = napiParcel->nativeParcel_->ReadDouble();
napi_value napiValue = nullptr;
......@@ -994,7 +994,7 @@ napi_value NAPI_MessageParcel::JS_readDouble(napi_env env, napi_callback_info in
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
double value = napiParcel->nativeParcel_->ReadDouble();
napi_value napiValue = nullptr;
......@@ -1009,7 +1009,7 @@ napi_value NAPI_MessageParcel::JS_readBoolean(napi_env env, napi_callback_info i
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
int8_t value = napiParcel->nativeParcel_->ReadInt8();
napi_value napiValue = nullptr;
......@@ -1024,7 +1024,7 @@ napi_value NAPI_MessageParcel::JS_readChar(napi_env env, napi_callback_info info
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
uint8_t value = napiParcel->nativeParcel_->ReadUint8();
napi_value result = nullptr;
......@@ -1039,7 +1039,7 @@ napi_value NAPI_MessageParcel::JS_readString(napi_env env, napi_callback_info in
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
std::u16string parcelString = napiParcel->nativeParcel_->ReadString16();
std::string outString = Str16ToStr8(parcelString.c_str());
......@@ -1056,7 +1056,7 @@ napi_value NAPI_MessageParcel::JS_getSize(napi_env env, napi_callback_info info)
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
size_t value = napiParcel->nativeParcel_->GetDataSize();
napi_value napiValue = nullptr;
......@@ -1072,7 +1072,7 @@ napi_value NAPI_MessageParcel::JS_getCapacity(napi_env env, napi_callback_info i
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
size_t value = napiParcel->nativeParcel_->GetDataCapacity();
napi_value napiValue = nullptr;
......@@ -1143,7 +1143,7 @@ napi_value NAPI_MessageParcel::JS_getWritableBytes(napi_env env, napi_callback_i
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
size_t value = napiParcel->nativeParcel_->GetWritableBytes();
napi_value napiValue = nullptr;
......@@ -1159,7 +1159,7 @@ napi_value NAPI_MessageParcel::JS_getReadableBytes(napi_env env, napi_callback_i
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
size_t value = napiParcel->nativeParcel_->GetReadableBytes();
napi_value napiValue = nullptr;
......@@ -1175,7 +1175,7 @@ napi_value NAPI_MessageParcel::JS_getReadPosition(napi_env env, napi_callback_in
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
size_t value = napiParcel->nativeParcel_->GetReadPosition();
napi_value napiValue = nullptr;
......@@ -1217,7 +1217,7 @@ napi_value NAPI_MessageParcel::JS_getWritePosition(napi_env env, napi_callback_i
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
size_t value = napiParcel->nativeParcel_->GetWritePosition();
napi_value napiValue = nullptr;
......@@ -1861,7 +1861,7 @@ napi_value NAPI_MessageParcel::JS_readSequenceable(napi_env env, napi_callback_i
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
int32_t len = napiParcel->nativeParcel_->ReadInt32();
if (len > 0) {
......@@ -1952,7 +1952,7 @@ napi_value NAPI_MessageParcel::JS_readRemoteObject(napi_env env, napi_callback_i
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
sptr<IRemoteObject> value = napiParcel->nativeParcel_->ReadRemoteObject();
napi_value napiValue = NAPI_ohos_rpc_CreateJsRemoteObject(env, value);
......@@ -2002,7 +2002,7 @@ napi_value NAPI_MessageParcel::JS_readInterfaceToken(napi_env env, napi_callback
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
std::u16string parcelString = napiParcel->nativeParcel_->ReadInterfaceToken();
std::string outString = Str16ToStr8(parcelString.c_str());
......@@ -2054,7 +2054,7 @@ napi_value NAPI_MessageParcel::JS_ContainFileDescriptors(napi_env env, napi_call
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
bool result = napiParcel->nativeParcel_->ContainFileDescriptors();
napi_value napiValue = nullptr;
NAPI_CALL(env, napi_get_boolean(env, result, &napiValue));
......@@ -2075,7 +2075,7 @@ napi_value NAPI_MessageParcel::JS_WriteFileDescriptor(napi_env env, napi_callbac
napi_get_value_int32(env, argv[0], &fd);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
bool result = napiParcel->nativeParcel_->WriteFileDescriptor(fd);
napi_value napiValue = nullptr;
NAPI_CALL(env, napi_get_boolean(env, result, &napiValue));
......@@ -2089,7 +2089,7 @@ napi_value NAPI_MessageParcel::JS_ReadFileDescriptor(napi_env env, napi_callback
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
int32_t result = napiParcel->nativeParcel_->ReadFileDescriptor();
napi_value napiValue;
napi_create_int32(env, result, &napiValue);
......@@ -2135,7 +2135,7 @@ napi_value NAPI_MessageParcel::JS_ReadAshmem(napi_env env, napi_callback_info in
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
sptr<Ashmem> nativeAshmem = napiParcel->nativeParcel_->ReadAshmem();
napi_value global = nullptr;
napi_status status = napi_get_global(env, &global);
......@@ -2188,7 +2188,7 @@ napi_value NAPI_MessageParcel::JS_WriteRawData(napi_env env, napi_callback_info
napi_get_value_int32(env, argv[1], &size);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
bool result = napiParcel->nativeParcel_->WriteRawData(array.data(), size * BYTE_SIZE_32);
napi_value napiValue = nullptr;
NAPI_CALL(env, napi_get_boolean(env, result, &napiValue));
......@@ -2209,9 +2209,9 @@ napi_value NAPI_MessageParcel::JS_ReadRawData(napi_env env, napi_callback_info i
napi_get_value_int32(env, argv[0], &arraySize);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
const void *rawData = napiParcel->nativeParcel_->ReadRawData(arraySize * BYTE_SIZE_32);
NAPI_ASSERT_BASE(env, rawData != nullptr, "rawData is null", 0);
NAPI_ASSERT_BASE(env, rawData != nullptr, "rawData is null", nullptr);
// [c++] rawData -> byteBuffer()[js]
napi_value result = nullptr;
if (arraySize <= 0) {
......@@ -2235,7 +2235,7 @@ napi_value NAPI_MessageParcel::JS_GetRawDataCapacity(napi_env env, napi_callback
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageParcel *napiParcel = nullptr;
napi_unwrap(env, thisVar, (void **)&napiParcel);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", 0);
NAPI_ASSERT_BASE(env, napiParcel != nullptr, "napiParcel is null", nullptr);
uint32_t result = napiParcel->nativeParcel_->GetRawDataCapacity();
napi_value napiValue;
napi_create_uint32(env, result, &napiValue);
......
......@@ -1346,7 +1346,7 @@ napi_value NAPI_MessageSequence::JS_getSize(napi_env env, napi_callback_info inf
NAPI_MessageSequence *napiSequence = nullptr;
napi_unwrap(env, thisVar, (void **)&napiSequence);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", 0);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", nullptr);
size_t value = napiSequence->nativeParcel_->GetDataSize();
napi_value napiValue = nullptr;
......@@ -1362,7 +1362,7 @@ napi_value NAPI_MessageSequence::JS_getCapacity(napi_env env, napi_callback_info
NAPI_MessageSequence *napiSequence = nullptr;
napi_unwrap(env, thisVar, (void **)&napiSequence);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", 0);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", nullptr);
size_t value = napiSequence->nativeParcel_->GetDataCapacity();
napi_value napiValue = nullptr;
......@@ -1457,7 +1457,7 @@ napi_value NAPI_MessageSequence::JS_getWritableBytes(napi_env env, napi_callback
NAPI_MessageSequence *napiSequence = nullptr;
napi_unwrap(env, thisVar, (void **)&napiSequence);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", 0);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", nullptr);
size_t value = napiSequence->nativeParcel_->GetWritableBytes();
napi_value napiValue = nullptr;
......@@ -1473,7 +1473,7 @@ napi_value NAPI_MessageSequence::JS_getReadableBytes(napi_env env, napi_callback
NAPI_MessageSequence *napiSequence = nullptr;
napi_unwrap(env, thisVar, (void **)&napiSequence);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", 0);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", nullptr);
size_t value = napiSequence->nativeParcel_->GetReadableBytes();
napi_value napiValue = nullptr;
......@@ -1489,7 +1489,7 @@ napi_value NAPI_MessageSequence::JS_getReadPosition(napi_env env, napi_callback_
NAPI_MessageSequence *napiSequence = nullptr;
napi_unwrap(env, thisVar, (void **)&napiSequence);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", 0);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", nullptr);
size_t value = napiSequence->nativeParcel_->GetReadPosition();
napi_value napiValue = nullptr;
......@@ -1543,7 +1543,7 @@ napi_value NAPI_MessageSequence::JS_getWritePosition(napi_env env, napi_callback
NAPI_MessageSequence *napiSequence = nullptr;
napi_unwrap(env, thisVar, (void **)&napiSequence);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", 0);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", nullptr);
size_t value = napiSequence->nativeParcel_->GetWritePosition();
napi_value napiValue = nullptr;
......@@ -2500,7 +2500,7 @@ napi_value NAPI_MessageSequence::JS_ContainFileDescriptors(napi_env env, napi_ca
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageSequence *napiSequence = nullptr;
napi_unwrap(env, thisVar, (void **)&napiSequence);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", 0);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", nullptr);
bool result = napiSequence->nativeParcel_->ContainFileDescriptors();
napi_value napiValue = nullptr;
NAPI_CALL(env, napi_get_boolean(env, result, &napiValue));
......@@ -2788,7 +2788,7 @@ napi_value NAPI_MessageSequence::JS_GetRawDataCapacity(napi_env env, napi_callba
napi_get_cb_info(env, info, &argc, nullptr, &thisVar, nullptr);
NAPI_MessageSequence *napiSequence = nullptr;
napi_unwrap(env, thisVar, (void **)&napiSequence);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", 0);
NAPI_ASSERT_BASE(env, napiSequence != nullptr, "napiSequence is null", nullptr);
uint32_t result = napiSequence->nativeParcel_->GetRawDataCapacity();
napi_value napiValue;
napi_create_uint32(env, result, &napiValue);
......
......@@ -445,7 +445,7 @@ napi_value NAPIRemoteObject::ThenCallback(napi_env env, napi_callback_info info)
napi_value NAPIRemoteObject::CatchCallback(napi_env env, napi_callback_info info)
{
ZLOGI(LOG_LABEL, "Async onReomteReuqest's return_val is rejected");
ZLOGI(LOG_LABEL, "Async onReomteReuqest's returnVal is rejected");
size_t argc = 1;
napi_value argv[1] = {nullptr};
void* data = nullptr;
......@@ -668,8 +668,8 @@ int NAPIRemoteObject::OnJsRemoteRequest(CallbackParam *jsParam)
// start to call onRemoteRequest
size_t argc2 = 4;
napi_value argv2[] = { jsCode, jsData, jsReply, jsOption };
napi_value return_val;
napi_status ret = napi_call_function(param->env, thisVar, onRemoteRequest, argc2, argv2, &return_val);
napi_value returnVal;
napi_status ret = napi_call_function(param->env, thisVar, onRemoteRequest, argc2, argv2, &returnVal);
// Reset old calling pid, uid, device id
NAPI_RemoteObject_resetOldCallingInfo(param->env, oldCallingInfo);
......@@ -683,11 +683,11 @@ int NAPIRemoteObject::OnJsRemoteRequest(CallbackParam *jsParam)
ZLOGD(LOG_LABEL, "call js onRemoteRequest done");
// Check whether return_val is Promise
bool returnIsPromise = false;//
napi_is_promise(param->env, return_val, &returnIsPromise);
napi_is_promise(param->env, returnVal, &returnIsPromise);
if (!returnIsPromise) {
ZLOGD(LOG_LABEL, "onRemoteRequest is synchronous");
bool result = false;
napi_get_value_bool(param->env, return_val, &result);
napi_get_value_bool(param->env, returnVal, &result);
if (!result) {
ZLOGE(LOG_LABEL, "OnRemoteRequest res:%{public}s", result ? "true" : "false");
param->result = ERR_UNKNOWN_TRANSACTION;
......@@ -700,22 +700,22 @@ int NAPIRemoteObject::OnJsRemoteRequest(CallbackParam *jsParam)
ZLOGD(LOG_LABEL, "onRemoteRequest is asynchronous");
// Create promiseThen
napi_value promiseThen = nullptr;
napi_get_named_property(param->env, return_val, "then", &promiseThen);
napi_get_named_property(param->env, returnVal, "then", &promiseThen);
if (promiseThen == nullptr) {
ZLOGE(LOG_LABEL, "get promiseThen failed");
param->result = -1;
break;
}
napi_value then_value;
ret = napi_create_function(param->env, "thenCallback", NAPI_AUTO_LENGTH, ThenCallback, param, &then_value);
napi_value thenValue;
ret = napi_create_function(param->env, "thenCallback", NAPI_AUTO_LENGTH, ThenCallback, param, &thenValue);
if (ret != napi_ok) {
ZLOGE(LOG_LABEL, "thenCallback got exception");
param->result = ERR_UNKNOWN_TRANSACTION;
break;
}
// Start to call promiseThen
napi_value then_return_value;
ret = napi_call_function(param->env, return_val, promiseThen, 1, &then_value, &then_return_value);
napi_value thenReturnValue;
ret = napi_call_function(param->env, returnVal, promiseThen, 1, &thenValue, &thenReturnValue);
if (ret != napi_ok) {
ZLOGE(LOG_LABEL, "PromiseThen got exception");
param->result = ERR_UNKNOWN_TRANSACTION;
......@@ -723,23 +723,23 @@ int NAPIRemoteObject::OnJsRemoteRequest(CallbackParam *jsParam)
}
// Create promiseCatch
napi_value promiseCatch = nullptr;
napi_get_named_property(param->env, return_val, "catch", &promiseCatch);
napi_get_named_property(param->env, returnVal, "catch", &promiseCatch);
if (promiseCatch == nullptr) {
ZLOGE(LOG_LABEL, "get promiseCatch failed");
param->result = -1;
break;
}
napi_value catch_value;
napi_value catchValue;
ret = napi_create_function(param->env, "catchCallback",
NAPI_AUTO_LENGTH, CatchCallback, param, &catch_value);
NAPI_AUTO_LENGTH, CatchCallback, param, &catchValue);
if (ret != napi_ok) {
ZLOGE(LOG_LABEL, "catchCallback got exception");
param->result = ERR_UNKNOWN_TRANSACTION;
break;
}
// Start to call promiseCatch
napi_value catch_return_value;
ret = napi_call_function(param->env, return_val, promiseCatch, 1, &catch_value, &catch_return_value);
napi_value catchReturnValue;
ret = napi_call_function(param->env, returnVal, promiseCatch, 1, &catchValue, &catchReturnValue);
if (ret != napi_ok) {
ZLOGE(LOG_LABEL, "PromiseCatch got exception");
param->result = ERR_UNKNOWN_TRANSACTION;
......@@ -1361,7 +1361,7 @@ napi_value NAPI_RemoteObject_getInterfaceDescriptor(napi_env env, napi_callback_
{
napi_value result = nullptr;
napi_value thisVar = nullptr;
napi_get_cb_info(env, info, 0, nullptr, &thisVar, nullptr);
napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr);
sptr<IRemoteObject> nativeObject = NAPI_ohos_rpc_getNativeRemoteObject(env, thisVar);
std::u16string descriptor = nativeObject->GetObjectDescriptor();
napi_create_string_utf8(env, Str16ToStr8(descriptor).c_str(), NAPI_AUTO_LENGTH, &result);
......@@ -1372,7 +1372,7 @@ napi_value NAPI_RemoteObject_getDescriptor(napi_env env, napi_callback_info info
{
napi_value result = nullptr;
napi_value thisVar = nullptr;
napi_get_cb_info(env, info, 0, nullptr, &thisVar, nullptr);
napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr);
sptr<IRemoteObject> nativeObject = NAPI_ohos_rpc_getNativeRemoteObject(env, thisVar);
if (nativeObject == nullptr) {
ZLOGE(LOG_LABEL, "native stub object is nullptr");
......
......@@ -96,9 +96,9 @@ void NAPIDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object)
napi_value onRemoteDied = nullptr;
napi_get_named_property(param->env, jsDeathRecipient, "onRemoteDied", &onRemoteDied);
NAPI_ASSERT_RETURN_VOID(param->env, onRemoteDied != nullptr, "failed to get property onRemoteDied");
napi_value return_val = nullptr;
napi_call_function(param->env, jsDeathRecipient, onRemoteDied, 0, nullptr, &return_val);
if (return_val == nullptr) {
napi_value returnVal = nullptr;
napi_call_function(param->env, jsDeathRecipient, onRemoteDied, 0, nullptr, &returnVal);
if (returnVal == nullptr) {
ZLOGE(LOG_LABEL, "failed to call function onRemoteDied");
}
delete param;
......@@ -775,7 +775,7 @@ napi_value NAPI_RemoteProxy_unregisterDeathRecipient(napi_env env, napi_callback
napi_value NAPI_RemoteProxy_getInterfaceDescriptor(napi_env env, napi_callback_info info)
{
napi_value thisVar = nullptr;
napi_get_cb_info(env, info, 0, 0, &thisVar, nullptr);
napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr);
NAPIRemoteProxyHolder *holder = nullptr;
napi_status status = napi_unwrap(env, thisVar, (void **)&holder);
NAPI_ASSERT(env, status == napi_ok, "failed to get proxy holder");
......@@ -798,7 +798,7 @@ napi_value NAPI_RemoteProxy_getInterfaceDescriptor(napi_env env, napi_callback_i
napi_value NAPI_RemoteProxy_getDescriptor(napi_env env, napi_callback_info info)
{
napi_value thisVar = nullptr;
napi_get_cb_info(env, info, 0, 0, &thisVar, nullptr);
napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr);
NAPIRemoteProxyHolder *holder = nullptr;
napi_status status = napi_unwrap(env, thisVar, (void **)&holder);
if (status != napi_ok) {
......@@ -828,7 +828,7 @@ napi_value NAPI_RemoteProxy_isObjectDead(napi_env env, napi_callback_info info)
{
ZLOGI(LOG_LABEL, "call isObjectDead");
napi_value thisVar = nullptr;
napi_get_cb_info(env, info, 0, 0, &thisVar, nullptr);
napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, nullptr);
NAPIRemoteProxyHolder *holder = nullptr;
napi_status status = napi_unwrap(env, thisVar, (void **)&holder);
NAPI_ASSERT(env, status == napi_ok, "failed to get proxy holder");
......
......@@ -26,7 +26,7 @@
namespace OHOS {
EXTERN_C_START
static napi_value rpcExport(napi_env env, napi_value exports)
static napi_value RpcExport(napi_env env, napi_value exports)
{
NAPI_MessageParcel::Export(env, exports);
NAPI_MessageSequence::Export(env, exports);
......@@ -43,5 +43,5 @@ EXTERN_C_END
/*
* Module register function
*/
NAPI_MODULE(rpc, rpcExport)
NAPI_MODULE(rpc, RpcExport)
} // namesapce OHOS
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册