[JSC] Implemented adapter. Removed Native2Value and Value2Native from js_base.h

This commit is contained in:
Asethone
2023-06-01 16:27:16 +04:00
parent 375b5a5f4f
commit f40b6f849d
7 changed files with 69 additions and 34 deletions

View File

@ -23,11 +23,20 @@ FUNCTION_WRAPPER_JS_3(hash, hash)
FUNCTION_WRAPPER_JS_4(hash2, hash2)
@end
void* CHashEmbed::GetDataForEmbedObject(void* data)
class CHashEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
CHashEmbed* pNativeObj = reinterpret_cast<CHashEmbed*>(data);
CJSCHashEmbed* pEmbedObj = [[CJSCHashEmbed alloc] init:pNativeObj];
return (void*)CFBridgingRetain(pEmbedObj);
public:
id getExportedObject(CJSEmbedObject* pNative)
{
return [[CJSCHashEmbed alloc] init:(CHashEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CHashEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CHashEmbedAdapter();
return m_pAdapter;
}
std::string CHashEmbed::getName() { return "CHashEmbed"; }

View File

@ -43,11 +43,20 @@ FUNCTION_WRAPPER_JS_2(encodeImage, encodeImage)
FUNCTION_WRAPPER_JS_1(getImageType, getImageType)
@end
void* CZipEmbed::GetDataForEmbedObject(void* data)
class CZipEmbedAdapter : public CJSEmbedObjectAdapterJSC
{
CZipEmbed* pNativeObj = reinterpret_cast<CZipEmbed*>(data);
CJSCZipEmbed* pEmbedObj = [[CJSCZipEmbed alloc] init:pNativeObj];
return (void*)CFBridgingRetain(pEmbedObj);
public:
id getExportedObject(CJSEmbedObject* pNative)
{
return [[CJSCZipEmbed alloc] init:(CZipEmbed*)pNative];
}
};
CJSEmbedObjectAdapterBase* CZipEmbed::getAdapter()
{
if (m_pAdapter == nullptr)
m_pAdapter = new CZipEmbedAdapter();
return m_pAdapter;
}
std::string CZipEmbed::getName() { return "CZipEmbed"; }