Сохранить совместимость ABI графиков

This commit is contained in:
2026-09-05 02:44:08 +03:00
parent be066a57eb
commit f5f15f6a04
6 changed files with 7 additions and 6 deletions

View File

@@ -3,7 +3,8 @@
Численная логика находится в `include/set_plot.h` и `src/set_plot.c`. Численная логика находится в `include/set_plot.h` и `src/set_plot.c`.
Это модуль C99 без Qt, Android, транспорта, динамической памяти и глобального Это модуль C99 без Qt, Android, транспорта, динамической памяти и глобального
состояния. Он собирается в существующую библиотеку SETProtocol; отдельная DLL состояния. Он собирается в существующую библиотеку SETProtocol; отдельная DLL
для графиков не требуется. Версия ABI графиков — `set_plot_abi_version() == 2`. для графиков не требуется. Версия ABI графиков — `set_plot_abi_version() == 1`;
новые операции добавляются без изменения существующих значений и сигнатур.
| Общее в templates | Адаптер приложения | | Общее в templates | Адаптер приложения |
|---|---| |---|---|

View File

@@ -21,7 +21,7 @@ enum set_plot_operation {
SET_PLOT_LIMITS = 8 /* xMin,xMax,yMin,yMax -> validated unchanged limits */ SET_PLOT_LIMITS = 8 /* xMin,xMax,yMin,yMax -> validated unchanged limits */
}; };
/** Version of this plot ABI, independently of the transport ABI (currently 2). */ /** Version of this additive plot ABI, independently of the transport ABI. */
PCAN_ABI_API uint32_t set_plot_abi_version(void); PCAN_ABI_API uint32_t set_plot_abi_version(void);
/** Evaluates one operation. Returns output count, or 0 for invalid arguments. /** Evaluates one operation. Returns output count, or 0 for invalid arguments.
* TRANSFORM rejects malformed viewports; invalid gesture values return the * TRANSFORM rejects malformed viewports; invalid gesture values return the

View File

@@ -8,7 +8,7 @@ static int finite_values(const double *v, size_t n) {
return 1; return 1;
} }
uint32_t set_plot_abi_version(void) { return 2U; } uint32_t set_plot_abi_version(void) { return 1U; }
size_t set_plot_eval(uint32_t op, const double *v, size_t n, double *out, size_t cap) { size_t set_plot_eval(uint32_t op, const double *v, size_t n, double *out, size_t cap) {
static const size_t sizes[] = {10, 3, 4, 4, 6, 2, 3, 2, 4}; static const size_t sizes[] = {10, 3, 4, 4, 6, 2, 3, 2, 4};

View File

@@ -1,5 +1,5 @@
{ {
"version": 2, "version": 1,
"cases": [ "cases": [
{"name":"zoom_x_anchor","op":0,"input":[0,0,1,1,2,1,0,0,0.25,0.5],"output":[0.125,0,0.5,1]}, {"name":"zoom_x_anchor","op":0,"input":[0,0,1,1,2,1,0,0,0.25,0.5],"output":[0.125,0,0.5,1]},
{"name":"zoom_y_anchor","op":0,"input":[0,0,1,1,1,4,0,0,0.5,0.75],"output":[0,0.5625,1,0.25]}, {"name":"zoom_y_anchor","op":0,"input":[0,0,1,1,1,4,0,0,0.5,0.75],"output":[0,0.5625,1,0.25]},

View File

@@ -9,7 +9,7 @@ int main(void) {
const double y[] = {15, 10, 30, 1}; const double y[] = {15, 10, 30, 1};
const double drag[] = {0, 100, 500, -10, 10, 1}; const double drag[] = {0, 100, 500, -10, 10, 1};
double back[4], bad[] = {NAN, 10, 8}; double back[4], bad[] = {NAN, 10, 8};
assert(set_plot_abi_version() == 2); assert(set_plot_abi_version() == 1);
assert(set_plot_eval(SET_PLOT_TRANSFORM, zoom, 10, output, 4) == 4); assert(set_plot_eval(SET_PLOT_TRANSFORM, zoom, 10, output, 4) == 4);
assert(output[0] == .125 && output[1] == 0 && output[2] == .5 && output[3] == 1); assert(output[0] == .125 && output[1] == 0 && output[2] == .5 && output[3] == 1);
assert(output[4] == 12345); assert(output[4] == 12345);

View File

@@ -37,7 +37,7 @@ class PlotMath:
self.library = library self.library = library
library.set_plot_abi_version.restype = ctypes.c_uint32 library.set_plot_abi_version.restype = ctypes.c_uint32
library.set_plot_abi_version.argtypes = [] library.set_plot_abi_version.argtypes = []
if library.set_plot_abi_version() != 2: if library.set_plot_abi_version() != 1:
raise RuntimeError("Unsupported plot ABI") raise RuntimeError("Unsupported plot ABI")
library.set_plot_eval.argtypes = [ctypes.c_uint32, ctypes.POINTER(ctypes.c_double), library.set_plot_eval.argtypes = [ctypes.c_uint32, ctypes.POINTER(ctypes.c_double),
ctypes.c_size_t, ctypes.POINTER(ctypes.c_double), ctypes.c_size_t] ctypes.c_size_t, ctypes.POINTER(ctypes.c_double), ctypes.c_size_t]