Skip to content

Commit

Permalink
More wrappers (#926)
Browse files Browse the repository at this point in the history
* Add XML_SetDoctypeDeclHandler wrapper for expat library

* More wrappers for fontconfig and freetype:

* FT_Get_MM_WeightVector
* FT_Set_MM_WeightVector
* FT_Get_CMap_Format
* FcInitLoadConfigAndFonts
* FcConfigDestroy

* More wrappers for libpng16:

* png_get_mem_ptr
* png_set_invert_mono
* png_set_invert_alpha
  • Loading branch information
ValdikSS authored Jan 22, 2024
1 parent 027605e commit e259ffc
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/wrapped/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2543,6 +2543,7 @@ wrappedexpat:
- vFpp:
- XML_SetCharacterDataHandler
- vFppp:
- XML_SetDoctypeDeclHandler
- XML_SetElementHandler
wrappedfaudio:
- vFpp:
Expand Down
1 change: 1 addition & 0 deletions src/wrapped/generated/wrappedexpattypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef void (*vFppp_t)(void*, void*, void*);

#define SUPER() ADDED_FUNCTIONS() \
GO(XML_SetCharacterDataHandler, vFpp_t) \
GO(XML_SetDoctypeDeclHandler, vFppp_t) \
GO(XML_SetElementHandler, vFppp_t)

#endif // __wrappedexpatTYPES_H_
50 changes: 50 additions & 0 deletions src/wrapped/wrappedexpat.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,50 @@ static void* find_CharData_Fct(void* fct)
printf_log(LOG_NONE, "Warning, no more slot for expat CharData callback\n");
return NULL;
}
// StartDoctypeDeclHandler
#define GO(A) \
static uintptr_t my_StartDoctypeDeclHandler_fct_##A = 0; \
static void* my_StartDoctypeDeclHandler_##A(void* data, void* name, void* sysid, void* pubid, int has_internal_subset) \
{ \
return (void*)RunFunctionFmt(my_StartDoctypeDeclHandler_fct_##A, "ppppi", data, name, sysid, pubid, has_internal_subset);\
}
SUPER()
#undef GO
static void* find_StartDoctypeDeclHandler_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_StartDoctypeDeclHandler_fct_##A == (uintptr_t)fct) return my_StartDoctypeDeclHandler_##A;
SUPER()
#undef GO
#define GO(A) if(my_StartDoctypeDeclHandler_fct_##A == 0) {my_StartDoctypeDeclHandler_fct_##A = (uintptr_t)fct; return my_StartDoctypeDeclHandler_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for expat StartDoctypeDeclHandler callback\n");
return NULL;
}
// EndDoctypeDeclHandler
#define GO(A) \
static uintptr_t my_EndDoctypeDeclHandler_fct_##A = 0; \
static void* my_EndDoctypeDeclHandler_##A(void* data) \
{ \
return (void*)RunFunctionFmt(my_EndDoctypeDeclHandler_fct_##A, "p", data);\
}
SUPER()
#undef GO
static void* find_EndDoctypeDeclHandler_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_EndDoctypeDeclHandler_fct_##A == (uintptr_t)fct) return my_EndDoctypeDeclHandler_##A;
SUPER()
#undef GO
#define GO(A) if(my_EndDoctypeDeclHandler_fct_##A == 0) {my_EndDoctypeDeclHandler_fct_##A = (uintptr_t)fct; return my_EndDoctypeDeclHandler_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for expat EndDoctypeDeclHandler callback\n");
return NULL;
}
#undef SUPER

EXPORT void my_XML_SetElementHandler(x86emu_t* emu, void* p, void* start, void* end)
Expand All @@ -106,6 +150,12 @@ EXPORT void my_XML_SetElementHandler(x86emu_t* emu, void* p, void* start, void*
my->XML_SetElementHandler(p, find_Start_Fct(start), find_End_Fct(end));
}

EXPORT void my_XML_SetDoctypeDeclHandler(x86emu_t* emu, void* p, void* start, void* end)
{
(void)emu;
my->XML_SetDoctypeDeclHandler(p, find_StartDoctypeDeclHandler_Fct(start), find_EndDoctypeDeclHandler_Fct(end));
}

EXPORT void my_XML_SetCharacterDataHandler(x86emu_t* emu, void* p, void* h)
{
(void)emu;
Expand Down
2 changes: 1 addition & 1 deletion src/wrapped/wrappedexpat_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GOM(XML_SetCharacterDataHandler, vFEpp)
//GO(XML_SetCommentHandler,
//GO(XML_SetDefaultHandler,
//GO(XML_SetDefaultHandlerExpand,
//GO(XML_SetDoctypeDeclHandler,
GOM(XML_SetDoctypeDeclHandler, vFEppp)
//GO(XML_SetElementDeclHandler,
GOM(XML_SetElementHandler, vFEppp)
//GO(XML_SetEncoding,
Expand Down
4 changes: 2 additions & 2 deletions src/wrapped/wrappedfontconfig_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ GO(FcConfigAppFontAddFile, iFpp)
//GO(FcConfigAppFontClear,
//GO(FcConfigBuildFonts,
//GO(FcConfigCreate,
//GO(FcConfigDestroy,
GO(FcConfigDestroy, vFp)
//GO(FcConfigEnableHome,
//GO(FcConfigFilename,
GO(FcConfigGetBlanks, pFp)
Expand Down Expand Up @@ -98,7 +98,7 @@ GO(FcGetVersion, iFv)
GO(FcInit, iFv)
GO(FcInitBringUptoDate, iFv)
//GO(FcInitLoadConfig,
//GO(FcInitLoadConfigAndFonts,
GO(FcInitLoadConfigAndFonts, pFv)
GO(FcInitReinitialize, iFv)
//GO(FcLangGetCharSet,
GO(FcLangSetAdd, iFpp)
Expand Down
5 changes: 4 additions & 1 deletion src/wrapped/wrappedfreetype_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GO(FT_Get_Charmap_Index, iFp)
//GO(FT_Get_CID_From_Glyph_Index,
//GO(FT_Get_CID_Is_Internally_CID_Keyed,
//GO(FT_Get_CID_Registry_Ordering_Supplement,
//GO(FT_Get_CMap_Format,
GO(FT_Get_CMap_Format, LFp)
//GO(FT_Get_CMap_Language_ID,
GO(FT_Get_First_Char, LFpp)
//GO(FT_Get_Font_Format,
Expand Down Expand Up @@ -200,3 +200,6 @@ GO(FTC_SBitCache_New, iFpp)

//GO(TT_New_Context,
//GO(TT_RunIns,

GO(FT_Set_MM_WeightVector, iFpUp)
GO(FT_Get_MM_WeightVector, iFppp)
3 changes: 3 additions & 0 deletions src/wrapped/wrappedpng16_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ GO(png_image_begin_read_from_memory, iFppL)
GO(png_image_finish_read, iFpppip)
GO(png_image_free, vFp)
GO(png_set_flush, vFpi)
GO(png_set_invert_alpha, vFp)
GO(png_set_invert_mono, vFp)
GO(png_get_mem_ptr, pFp)

0 comments on commit e259ffc

Please sign in to comment.