Skip to content

Commit 92a5a22

Browse files
committed
me_variable_ex -> -me_variable, an remove (unncessary now) me_compile_ex()
1 parent 24c8ce8 commit 92a5a22

14 files changed

Lines changed: 84 additions & 158 deletions

doc/data-types.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Both methods require explicit variable dtypes when the computation type differs
292292

293293
`ME_STRING` represents fixed-size UCS4 (`uint32_t`) strings. Each element is a
294294
NUL-terminated array of codepoints with no embedded NULs. You must provide the
295-
per-element byte size via `me_variable_ex` (`itemsize` must be a multiple of 4
295+
per-element byte size via `me_variable` (`itemsize` must be a multiple of 4
296296
and include the terminator). The maximum string length in codepoints is
297297
`itemsize / 4 - 1`.
298298

@@ -309,13 +309,13 @@ uint32_t names[][8] = {
309309
{'b','e','t','a',0,0,0,0},
310310
};
311311

312-
me_variable_ex vars[] = {
312+
me_variable vars[] = {
313313
{"name", ME_STRING, names, ME_VARIABLE, NULL, sizeof(names[0])}
314314
};
315315

316316
int error;
317317
me_expr *expr = NULL;
318-
if (me_compile_ex("startswith(name, \"alp\")", vars, 1, ME_BOOL, &error, &expr) != ME_COMPILE_SUCCESS) { /* handle error */ }
318+
if (me_compile("startswith(name, \"alp\")", vars, 1, ME_BOOL, &error, &expr) != ME_COMPILE_SUCCESS) { /* handle error */ }
319319
```
320320
321321
String literals are UTF-8 and support escapes like `\n`, `\t`, `\\`, `\"`, `\'`,

doc/dsl-usage.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def kernel(x):
2929
```
3030

3131
Signature arguments must match the variables you pass to `me_compile()` by name
32-
(order does not matter). (Callback functions registered via `me_variable_ex` are
32+
(order does not matter). (Callback functions registered via `me_variable` are
3333
not listed in the signature.)
3434

3535
Note: The order of the variables array still defines the pointer order passed to
@@ -323,7 +323,7 @@ Logical operator precedence matches Python: `not` binds tighter than `and`, whic
323323
- Predicates: `startswith(a, b)`, `endswith(a, b)`, `contains(a, b)` (string-to-string)
324324
325325
String variables must be provided with dtype `ME_STRING` and a fixed `itemsize`
326-
via `me_variable_ex` (itemsize is bytes per element and must be a multiple of 4).
326+
via `me_variable` (itemsize is bytes per element and must be a multiple of 4).
327327
String expressions always yield boolean output.
328328
329329
Example (element-wise string match with a scalar condition):
@@ -407,7 +407,7 @@ print(sum(a))
407407
### User-defined Functions
408408
409409
You can register custom C functions or closures and call them from DSL by
410-
including them in the `me_variable_ex` list passed to `me_compile_ex()`.
410+
including them in the `me_variable` list passed to `me_compile()`.
411411
412412
Rules:
413413
- Function/closure entries must use `ME_FUNCTION*` or `ME_CLOSURE*` in `type`.
@@ -422,14 +422,14 @@ static double clamp01(double x) {
422422
return x < 0.0 ? 0.0 : (x > 1.0 ? 1.0 : x);
423423
}
424424

425-
me_variable_ex vars[] = {
425+
me_variable vars[] = {
426426
{"x", ME_FLOAT64, x, ME_VARIABLE, NULL, 0},
427427
{"clamp01", ME_FLOAT64, clamp01, ME_FUNCTION1 | ME_FLAG_PURE, NULL, 0},
428428
};
429429

430430
me_expr *expr = NULL;
431431
int err = 0;
432-
me_compile_ex("def kernel(x):\n return clamp01(x)\n", vars, 2, ME_FLOAT64, &err, &expr);
432+
me_compile("def kernel(x):\n return clamp01(x)\n", vars, 2, ME_FLOAT64, &err, &expr);
433433
```
434434
435435
Example (closure with context):
@@ -439,7 +439,7 @@ static double scale(void *ctx, double x) {
439439
}
440440

441441
double factor = 2.0;
442-
me_variable_ex vars[] = {
442+
me_variable vars[] = {
443443
{"x", ME_FLOAT64, x, ME_VARIABLE, NULL, 0},
444444
{"scale", ME_FLOAT64, scale, ME_CLOSURE1 | ME_FLAG_PURE, &factor, 0},
445445
};

doc/strings.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ string operations.
1212

1313
## API: Variables and Compilation
1414

15-
Use `me_variable_ex` to supply `itemsize` for string variables:
15+
Use `me_variable` to supply `itemsize` for string variables:
1616

1717
```c
1818
uint32_t names[][8] = {
1919
{'a','l','p','h','a',0,0,0},
2020
{'b','e','t','a',0,0,0,0},
2121
};
2222

23-
me_variable_ex vars[] = {
23+
me_variable vars[] = {
2424
{"name", ME_STRING, names, ME_VARIABLE, NULL, sizeof(names[0])}
2525
};
2626

2727
me_expr *expr = NULL;
2828
int err = 0;
29-
if (me_compile_ex("contains(name, \"et\")", vars, 1, ME_BOOL, &err, &expr) != ME_COMPILE_SUCCESS) {
29+
if (me_compile("contains(name, \"et\")", vars, 1, ME_BOOL, &err, &expr) != ME_COMPILE_SUCCESS) {
3030
/* handle error */
3131
}
3232
```

examples/14_string_ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ static int run_expr(const char *expr_str, const void **vars, int nvars,
7272
me_expr *expr = NULL;
7373
int err = 0;
7474

75-
me_variable_ex variables[] = {
75+
me_variable variables[] = {
7676
{"name", ME_STRING, vars[0], ME_VARIABLE, NULL, sizeof(uint32_t) * 8}
7777
};
7878

79-
int rc = me_compile_ex(expr_str, variables, nvars, ME_BOOL, &err, &expr);
79+
int rc = me_compile(expr_str, variables, nvars, ME_BOOL, &err, &expr);
8080
if (rc != ME_COMPILE_SUCCESS) {
8181
printf("compile failed (%d) at %d for: %s\n", rc, err, expr_str);
8282
return rc;

examples/17_dsl_user_function.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ int main(void) {
3737
int n = (int)(sizeof(x) / sizeof(x[0]));
3838
double out[5];
3939

40-
me_variable_ex vars[] = {
40+
me_variable vars[] = {
4141
{"x", ME_FLOAT64, NULL, 0, NULL, 0},
4242
{"clamp01", ME_FLOAT64, clamp01, ME_FUNCTION1 | ME_FLAG_PURE, NULL, 0},
4343
};
4444

4545
int err = 0;
4646
me_expr *expr = NULL;
47-
if (me_compile_ex(dsl_source, vars, 2, ME_FLOAT64, &err, &expr) != ME_COMPILE_SUCCESS) {
47+
if (me_compile(dsl_source, vars, 2, ME_FLOAT64, &err, &expr) != ME_COMPILE_SUCCESS) {
4848
printf("Compile error at %d\n", err);
4949
return 1;
5050
}

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def mandelbrot(cr, ci):
422422

423423
- **What it demonstrates**: Registering a custom C function for DSL evaluation
424424
- **Expressions**: Calling a user-defined function from a DSL program
425-
- **Concepts**: `me_variable_ex` function entries, explicit return dtype
425+
- **Concepts**: `me_variable` function entries, explicit return dtype
426426
- **Best for**: Extending DSL with domain-specific helpers
427427

428428
**Run it:**

src/functions.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ static double npr(double n, double r) { return ncr(n, r) * fac(r); }
629629
#pragma function (floor)
630630
#endif
631631

632-
static const me_variable_ex functions[] = {
632+
static const me_variable functions[] = {
633633
/* must be in alphabetical order */
634634
/* Format: {name, dtype, address, type, context} */
635635
{"abs", 0, fabs, ME_FUNCTION1 | ME_FLAG_PURE, 0},
@@ -715,9 +715,9 @@ static const me_variable_ex functions[] = {
715715
{0, 0, 0, 0, 0}
716716
};
717717

718-
static const me_variable_ex* find_builtin(const char* name, int len) {
718+
static const me_variable* find_builtin(const char* name, int len) {
719719
int imin = 0;
720-
int imax = sizeof(functions) / sizeof(me_variable_ex) - 2;
720+
int imax = sizeof(functions) / sizeof(me_variable) - 2;
721721

722722
/*Binary search.*/
723723
while (imax >= imin) {
@@ -745,9 +745,9 @@ bool me_is_builtin_function_name(const char* name, size_t len) {
745745
return find_builtin(name, (int)len) != NULL;
746746
}
747747

748-
static const me_variable_ex* find_lookup(const state* s, const char* name, int len) {
748+
static const me_variable* find_lookup(const state* s, const char* name, int len) {
749749
int iters;
750-
const me_variable_ex* var;
750+
const me_variable* var;
751751
if (!s->lookup) return 0;
752752

753753
for (var = s->lookup, iters = s->lookup_len; iters; ++var, --iters) {
@@ -2998,7 +2998,7 @@ static void read_identifier_token(state* s) {
29982998
return;
29992999
}
30003000

3001-
const me_variable_ex* var = find_lookup(s, start, s->next - start);
3001+
const me_variable* var = find_lookup(s, start, s->next - start);
30023002
if (!var) {
30033003
var = find_builtin(start, s->next - start);
30043004
}

src/functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef struct state {
3636
const uint32_t* str_data;
3737
size_t str_len;
3838

39-
const me_variable_ex* lookup;
39+
const me_variable* lookup;
4040
int lookup_len;
4141
} state;
4242

0 commit comments

Comments
 (0)