fix: fix build issue in Unvirt and LibCmo
- fix build issue in Unvirt and LibCmo - due to we use UTF8 string. the accessible value generator in EnumsMigration need to be changed at the same time. - remove string helper in Unvirt because we no longer need it.
This commit is contained in:
@ -109,6 +109,7 @@ namespace LibCmo::CK2 {
|
||||
* The encoding of ordinary is specified by encoding sequence.
|
||||
* If we fail to do convertion, the result will leave to blank and output a message to CKContext.
|
||||
* However, if you use this function with blank encoding sequence, it will raise exception.
|
||||
* So becore using this function, please make sure that you have checked by calling IsValidEncoding().
|
||||
*/
|
||||
void GetUTF8String(const std::string& native_name, XContainer::XString& u8_name);
|
||||
/**
|
||||
@ -120,6 +121,7 @@ namespace LibCmo::CK2 {
|
||||
* The encoding of ordinary is specified by encoding sequence.
|
||||
* If we fail to do convertion, the result will leave to blank and output a message to CKContext.
|
||||
* However, if you use this function with blank encoding sequence, it will raise exception.
|
||||
* So becore using this function, please make sure that you have checked by calling IsValidEncoding().
|
||||
*/
|
||||
void GetOrdinaryString(const XContainer::XString& u8_name, std::string& native_name);
|
||||
/**
|
||||
|
@ -18,6 +18,8 @@ namespace LibCmo::CK2 {
|
||||
CKERROR CKFileReader::ShallowLoad(CKSTRING u8_filename) {
|
||||
// check document status
|
||||
if (this->m_Done) return CKERROR::CKERR_CANCELLED;
|
||||
// check CKContext encoding sequence
|
||||
if (!this->m_Ctx->IsValidEncoding()) return CKERROR::CKERR_CANCELLED;
|
||||
|
||||
// check file and open memory
|
||||
if (u8_filename == nullptr) return CKERROR::CKERR_INVALIDPARAMETER;
|
||||
@ -35,6 +37,8 @@ namespace LibCmo::CK2 {
|
||||
if (err != CKERROR::CKERR_OK) return err;
|
||||
|
||||
// other data will be free automatically
|
||||
// set done flag and return
|
||||
this->m_Done = true;
|
||||
return CKERROR::CKERR_OK;
|
||||
}
|
||||
|
||||
@ -335,6 +339,8 @@ namespace LibCmo::CK2 {
|
||||
CKERROR CKFileReader::DeepLoad(CKSTRING u8_filename) {
|
||||
// check document status
|
||||
if (this->m_Done) return CKERROR::CKERR_CANCELLED;
|
||||
// check CKContext encoding sequence
|
||||
if (!this->m_Ctx->IsValidEncoding()) return CKERROR::CKERR_CANCELLED;
|
||||
|
||||
// ========== prepare work ==========
|
||||
CKERROR err = CKERROR::CKERR_OK;
|
||||
@ -342,6 +348,8 @@ namespace LibCmo::CK2 {
|
||||
// get shallow document first
|
||||
err = this->ShallowLoad(u8_filename);
|
||||
if (err != CKERROR::CKERR_OK) return err;
|
||||
// reset done flag because we need further processing
|
||||
this->m_Done = false;
|
||||
|
||||
// ========== create object first ==========
|
||||
for (auto& obj : this->m_FileObjects) {
|
||||
@ -387,6 +395,10 @@ namespace LibCmo::CK2 {
|
||||
}
|
||||
|
||||
// ========== finalize work ==========
|
||||
|
||||
|
||||
// set done flag and return
|
||||
this->m_Done = true;
|
||||
return CKERROR::CKERR_OK;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@ namespace LibCmo::CK2 {
|
||||
CKERROR CKFileWriter::Save(CKSTRING u8_filename) {
|
||||
// check document status
|
||||
if (this->m_Done) return CKERROR::CKERR_CANCELLED;
|
||||
// check CKContext encoding sequence
|
||||
if (!this->m_Ctx->IsValidEncoding()) return CKERROR::CKERR_CANCELLED;
|
||||
|
||||
// encoding conv helper
|
||||
std::string name_conv;
|
||||
@ -347,6 +349,8 @@ namespace LibCmo::CK2 {
|
||||
// close file
|
||||
std::fclose(fs);
|
||||
|
||||
// set done flag and return
|
||||
this->m_Done = true;
|
||||
return CKERROR::CKERR_OK;
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,11 @@ namespace LibCmo {
|
||||
#define PRI_CKSTRING "s"
|
||||
#define PRI_CKCHAR "c"
|
||||
|
||||
#define CKBYTE_C(v) UINT8_C(v)
|
||||
#define CKWORD_C(v) UINT16_C(v)
|
||||
#define CKDWORD_C(v) UINT32_C(v)
|
||||
#define CKQWORD_C(v) UINT64_C(v)
|
||||
|
||||
#define PRIuCKBYTE PRIu8
|
||||
#define PRIuCKWORD PRIu16
|
||||
#define PRIuCKDWORD PRIu32
|
||||
@ -104,6 +109,8 @@ namespace LibCmo {
|
||||
#define PRIXCKDWORD PRIX32
|
||||
#define PRIXCKQWORD PRIX64
|
||||
|
||||
#define CKINT_C(v) INT32_C(v)
|
||||
|
||||
#define PRIiCKINT PRIi32
|
||||
|
||||
#define PRIfCKFLOAT "f"
|
||||
|
@ -15,6 +15,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
* All pointers should translate to DWORD(32 bit) for platform independent.
|
||||
* Otherwise this struct may be corrupted in x64 platform because pointer is QWORD in x64.
|
||||
*/
|
||||
#pragma pack(4)
|
||||
struct FakeBitmapProperties {
|
||||
CKINT m_Size;
|
||||
struct {
|
||||
@ -23,7 +24,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
}m_ReaderGuid;
|
||||
struct {
|
||||
// fake CKFileExtension
|
||||
CKCHAR m_Data[4];
|
||||
char m_Data[4];
|
||||
}m_Ext;
|
||||
struct {
|
||||
// fake VxImageDescEx
|
||||
@ -60,6 +61,7 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
}m_Format;
|
||||
/*void**/CKPTR m_Data;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
CKTexture::CKTexture(CKContext* ctx, CK_ID ckid, CKSTRING name) :
|
||||
CKBeObject(ctx, ckid, name),
|
||||
@ -184,10 +186,12 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
// setup ext and guid
|
||||
props.m_ReaderGuid.d1 = realprops.m_ReaderGuid.d1;
|
||||
props.m_ReaderGuid.d2 = realprops.m_ReaderGuid.d2;
|
||||
std::string ext;
|
||||
m_Context->GetOrdinaryString(realprops.m_Ext.GetExt(), ext);
|
||||
std::memcpy(
|
||||
props.m_Ext.m_Data,
|
||||
realprops.m_Ext.GetExt(),
|
||||
std::min(CKSizeof(props.m_Ext.m_Data), realprops.m_Ext.GetSize())
|
||||
props.m_Ext.m_Data,
|
||||
ext.c_str(),
|
||||
std::min(CKSizeof(props.m_Ext.m_Data) - CKDWORD_C(1), static_cast<CKDWORD>(ext.size()))
|
||||
);
|
||||
|
||||
// write fake one
|
||||
@ -308,9 +312,14 @@ namespace LibCmo::CK2::ObjImpls {
|
||||
if (buf != nullptr) {
|
||||
FakeBitmapProperties* props = static_cast<FakeBitmapProperties*>(buf.get());
|
||||
|
||||
// get utf8 extension
|
||||
XContainer::XString ext;
|
||||
m_Context->GetUTF8String(props->m_Ext.m_Data, ext);
|
||||
|
||||
// get my bitmap prop
|
||||
CKBitmapProperties myprops(
|
||||
CKGUID(props->m_ReaderGuid.d1, props->m_ReaderGuid.d2),
|
||||
props->m_Ext.m_Data
|
||||
ext.c_str()
|
||||
);
|
||||
m_ImageHost.SetSaveFormat(myprops);
|
||||
}
|
||||
|
Reference in New Issue
Block a user