Skip to content

Commit

Permalink
change callbacks to stdcall, add debug version to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSizuku committed Dec 7, 2024
1 parent 59e6dfc commit dc96973
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 27 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build_llvmmingw:
strategy:
matrix:
arch: [{prefix: i686, suffix: x86}, {prefix: x86_64, suffix: x64}]
arch: [{prefix: i686, suffix: x86}, {prefix: x86_64, suffix: x64}, {prefix: x86_64, suffix: x64d}]

runs-on: ubuntu-24.04
steps:
Expand All @@ -34,7 +34,11 @@ jobs:
export CC=${{ matrix.arch.prefix }}-w64-mingw32-clang
export WINDRES=${{ matrix.arch.prefix }}-w64-mingw32-windres
export BUILD_DIR=build
export BUILD_TYPE=MinSizeRel
if [[ "${{ matrix.arch.suffix }}" =~ "d" ]]; then
export BUILD_TYPE=Debug
else
export BUILD_TYPE=MinSizeRel
fi
bash script/build_mingw.sh
- name: prepare release
Expand Down
8 changes: 4 additions & 4 deletions asset/icon/icon.rc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
IDI_ICON1 ICON "icon1.ico"

1 VERSIONINFO
FILEVERSION 0,3,4,0
PRODUCTVERSION 0,3,4,0
FILEVERSION 0,3,5,0
PRODUCTVERSION 0,3,5,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904E4"
BEGIN
VALUE "CompanyName", "YuriSizuku"
VALUE "FileDescription", "A cross platform tool to view and analyze tiles or textures"
VALUE "FileVersion", "v0.3.4"
VALUE "FileVersion", "v0.3.5"
VALUE "InternalName", "TileViewer"
VALUE "OriginalFilename", "TileViewer.exe"
VALUE "ProductName", "TileViewer"
VALUE "ProductVersion", "v0.3.4"
VALUE "ProductVersion", "v0.3.5"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 1 addition & 1 deletion src/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <wx/dynlib.h>
#include "plugin.h"

#define APP_VERSION "v0.3.4"
#define APP_VERSION "v0.3.5"

extern struct tilecfg_t g_tilecfg;

Expand Down
26 changes: 18 additions & 8 deletions src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,20 @@
extern "C" {
#endif

#undef IN
#undef OUT
#undef OPTIONAL
#undef REQUIRED
#define IN
#define OUT
#define OPTIONAL
#define REQUIRED
#undef STDCALL
#if defined(_MSC_VER) || defined(__TINYC__)
#define STDCALL __stdcall
#else
#define STDCALL __attribute__((stdcall))
#endif

struct pixel_t
{
Expand Down Expand Up @@ -136,20 +146,20 @@ inline const char *decode_status_str(PLUGIN_STATUS x)
* open decoder
* @return decoder context
*/
typedef PLUGIN_STATUS (*CB_decode_open)(const char *name, void **context);
typedef PLUGIN_STATUS (*STDCALL CB_decode_open)(const char *name, void **context);

/**
* close decoder
*/
typedef PLUGIN_STATUS (*CB_decode_close)(void *context);
typedef PLUGIN_STATUS (*STDCALL CB_decode_close)(void *context);

/**
* decode 1 pixel
* @param data, corrent decoding data
* @param pixel out a uint32_t value
* @param remain_index keep the origin index
*/
typedef PLUGIN_STATUS (*CB_decode_pixel)(void *context,
typedef PLUGIN_STATUS (*STDCALL CB_decode_pixel)(void *context,
const uint8_t* data, size_t datasize,
const struct tilepos_t *pos, const struct tilefmt_t *fmt,
struct pixel_t *pixel, bool remain_index);
Expand All @@ -161,7 +171,7 @@ typedef PLUGIN_STATUS (*CB_decode_pixel)(void *context,
* @param npixel how many pixels for all tiles
* @param remain_index keep the origin index
*/
typedef PLUGIN_STATUS (*CB_decode_pixels)(void *context,
typedef PLUGIN_STATUS (*STDCALL CB_decode_pixels)(void *context,
const uint8_t* data, size_t datasize,
const struct tilefmt_t *fmt, struct pixel_t *pixels[],
size_t *npixel, bool remain_index);
Expand All @@ -170,18 +180,18 @@ typedef PLUGIN_STATUS (*CB_decode_pixels)(void *context,
* decode pre, post processing
* @param rawdata rawdata of the file
*/
typedef PLUGIN_STATUS (*CB_decode_parse)(void *context,
typedef PLUGIN_STATUS (*STDCALL CB_decode_parse)(void *context,
const uint8_t* rawdata, size_t rawsize, struct tilecfg_t *cfg);

/**
* send to the main ui
*/
typedef PLUGIN_STATUS (*CB_decode_send)(void *context, const char **buf, size_t *bufsize);
typedef PLUGIN_STATUS (*STDCALL CB_decode_send)(void *context, const char **buf, size_t *bufsize);

/**
* recive from the main ui
*/
typedef PLUGIN_STATUS (*CB_decode_recv)(void *context, const char *buf, size_t bufsize);
typedef PLUGIN_STATUS (*STDCALL CB_decode_recv)(void *context, const char *buf, size_t bufsize);

/**
* interface for C plugin
Expand All @@ -205,7 +215,7 @@ struct tile_decoder_t
/**
* if not export decoder struct, use get_decoder function instead
*/
typedef struct tile_decoder_t* (*API_get_decoder)();
typedef struct tile_decoder_t* (*STDCALL API_get_decoder)();

#ifdef __cplusplus
}
Expand Down
10 changes: 5 additions & 5 deletions src/plugin_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ static struct
}s_plugincfg = {.endian_big=false, .channel_argb=false,
.channel_abgr=false, .flipx=false, .flipy=false};

PLUGIN_STATUS decode_open_default(const char *name, void **context)
PLUGIN_STATUS STDCALL decode_open_default(const char *name, void **context)
{
s_msg[0] = '\0';
sprintf(s_msg, "[plugin_builtin::open]");
if(s_msg[strlen(s_msg) - 1] =='\n') s_msg[strlen(s_msg) - 1] = '\0';
return STATUS_OK;
}

PLUGIN_STATUS decode_close_default(void *context)
PLUGIN_STATUS STDCALL decode_close_default(void *context)
{
s_msg[0] = '\0';
sprintf(s_msg, "[plugin_builtin::close]");
if(s_msg[strlen(s_msg) - 1] =='\n') s_msg[strlen(s_msg) - 1] = '\0';
return STATUS_OK;
}

PLUGIN_STATUS decode_sendui_default(void *context, const char **buf, size_t *bufsize)
PLUGIN_STATUS STDCALL decode_sendui_default(void *context, const char **buf, size_t *bufsize)
{
s_msg[0] = '\0';

Expand All @@ -57,7 +57,7 @@ PLUGIN_STATUS decode_sendui_default(void *context, const char **buf, size_t *buf
return STATUS_OK;
}

PLUGIN_STATUS decode_recvui_default(void *context, const char *buf, size_t bufsize)
PLUGIN_STATUS STDCALL decode_recvui_default(void *context, const char *buf, size_t bufsize)
{
s_msg[0] = '\0';
sprintf(s_msg, "[plugin_builtin::recvui] recv %zu bytes", bufsize);
Expand Down Expand Up @@ -121,7 +121,7 @@ bool decode_offset_default(void *context,
return true;
}

PLUGIN_STATUS decode_pixel_default(void *context,
PLUGIN_STATUS STDCALL decode_pixel_default(void *context,
const uint8_t* data, size_t datasize,
const struct tilepos_t *pos, const struct tilefmt_t *fmt,
struct pixel_t *pixel, bool remain_index)
Expand Down
14 changes: 7 additions & 7 deletions src/plugin_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static void register_capis(lua_State *L)
lua_register(L, "get_rawdata", capi_get_rawdata);
}

PLUGIN_STATUS decode_open_lua(const char *luastr, void **context)
PLUGIN_STATUS STDCALL decode_open_lua(const char *luastr, void **context)
{
s_msg[0] = '\0';
lua_State* L = luaL_newstate();
Expand All @@ -290,7 +290,7 @@ PLUGIN_STATUS decode_open_lua(const char *luastr, void **context)
return STATUS_OK;
}

PLUGIN_STATUS decode_close_lua(void *context)
PLUGIN_STATUS STDCALL decode_close_lua(void *context)
{
s_msg[0] = '\0';
sprintf(s_msg, "[plugin_lua::close]");
Expand All @@ -303,7 +303,7 @@ PLUGIN_STATUS decode_close_lua(void *context)
return STATUS_OK;
}

PLUGIN_STATUS decode_sendui_lua(void *context, const char **buf, size_t *bufsize)
PLUGIN_STATUS STDCALL decode_sendui_lua(void *context, const char **buf, size_t *bufsize)
{
s_msg[0] = '\0';

Expand All @@ -325,7 +325,7 @@ PLUGIN_STATUS decode_sendui_lua(void *context, const char **buf, size_t *bufsize
return STATUS_OK;
}

PLUGIN_STATUS decode_recvui_lua(void *context, const char *buf, size_t bufsize)
PLUGIN_STATUS STDCALL decode_recvui_lua(void *context, const char *buf, size_t bufsize)
{
s_msg[0] = '\0';
sprintf(s_msg, "[plugin_lua::recvui] recv %zu bytes\n", bufsize);
Expand Down Expand Up @@ -381,7 +381,7 @@ PLUGIN_STATUS decode_recvui_lua(void *context, const char *buf, size_t bufsize)
}

// function decode_pixel(i, x, y)
PLUGIN_STATUS decode_pixel_lua(void *context,
PLUGIN_STATUS STDCALL decode_pixel_lua(void *context,
const uint8_t* data, size_t datasize,
const struct tilepos_t *pos, const struct tilefmt_t *fmt,
struct pixel_t *pixel, bool remain_index)
Expand All @@ -406,7 +406,7 @@ PLUGIN_STATUS decode_pixel_lua(void *context,
return STATUS_OK;
}

PLUGIN_STATUS decode_pre_lua(void *context,
PLUGIN_STATUS STDCALL decode_pre_lua(void *context,
const uint8_t* rawdata, size_t rawsize, struct tilecfg_t *cfg)
{
s_msg[0] = '\0';
Expand All @@ -432,7 +432,7 @@ PLUGIN_STATUS decode_pre_lua(void *context,
return res ? STATUS_OK : STATUS_FAIL;
}

PLUGIN_STATUS decode_post_lua(void *context,
PLUGIN_STATUS STDCALL decode_post_lua(void *context,
const uint8_t* rawdata, size_t rawsize, struct tilecfg_t *cfg)
{
s_msg[0] = '\0';
Expand Down

0 comments on commit dc96973

Please sign in to comment.