Skip to content

Commit 7857df8

Browse files
committed
Release 1.0.30
* Added possibility to perform casted fetch from expr::value_t. * Updated module versions in dependencies.
2 parents b009615 + a433e0b commit 7857df8

File tree

8 files changed

+198
-10
lines changed

8 files changed

+198
-10
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
* RECENT CHANGES
33
*******************************************************************************
44

5+
=== 1.0.30 ===
6+
* Added possibility to perform casted fetch from expr::value_t.
7+
* Updated module versions in dependencies.
8+
59
=== 1.0.29 ===
610
* Implemented simple compressor for Wavefront OBJ files.
711
* Fixed bug in determining file size for Unix-like systems.

include/lsp-plug.in/expr/types.h

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <sadko4u@gmail.com>
44
*
55
* This file is part of lsp-runtime-lib
66
* Created on: 16 сент. 2019 г.
@@ -141,11 +141,86 @@ namespace lsp
141141
*/
142142
void destroy_value(value_t *value);
143143

144+
/**
145+
* Ensure that value is integer and read it
146+
* @param dst pointer to store value
147+
* @param v value to read
148+
* @return status STATUS_BAD_TYPE error code on type mismatch
149+
*/
144150
status_t fetch_int(ssize_t *dst, const value_t *v);
151+
152+
/**
153+
* Ensure that value is floating-point and read it
154+
* @param dst pointer to store value
155+
* @param v value to read
156+
* @return status STATUS_BAD_TYPE error code on type mismatch
157+
*/
145158
status_t fetch_float(float *dst, const value_t *v);
159+
160+
/**
161+
* Ensure that value is floating-point and read it
162+
* @param dst pointer to store value
163+
* @param v value to read
164+
* @return status STATUS_BAD_TYPE error code on type mismatch
165+
*/
166+
status_t fetch_float(double *dst, const value_t *v);
167+
168+
/**
169+
* Ensure that value is boolean and read it
170+
* @param dst pointer to store value
171+
* @param v value to read
172+
* @return status STATUS_BAD_TYPE error code on type mismatch
173+
*/
146174
status_t fetch_bool(bool *dst, const value_t *v);
175+
176+
/**
177+
* Ensure that value is string and read it
178+
* @param dst pointer to store value
179+
* @param v value to read
180+
* @return status STATUS_BAD_TYPE error code on type mismatch
181+
*/
147182
status_t fetch_string(LSPString *dst, const value_t *v);
148183

184+
/**
185+
* Try to cast value to int and fetch it
186+
* @param dst pointer to store value
187+
* @param v value to read
188+
* @return status of operation
189+
*/
190+
status_t fetch_as_int(ssize_t *dst, const value_t *v);
191+
192+
/**
193+
* Try to cast value to floating-pont value and fetch it
194+
* @param dst pointer to store value
195+
* @param v value to read
196+
* @return status of operation
197+
*/
198+
status_t fetch_as_float(float *dst, const value_t *v);
199+
200+
/**
201+
* Try to cast value to floating-pont value and fetch it
202+
* @param dst pointer to store value
203+
* @param v value to read
204+
* @return status of operation
205+
*/
206+
status_t fetch_as_float(double *dst, const value_t *v);
207+
208+
/**
209+
* Try to cast value to boolean value and fetch it
210+
* @param dst pointer to store value
211+
* @param v value to read
212+
* @return status of operation
213+
*/
214+
status_t fetch_as_bool(bool *dst, const value_t *v);
215+
216+
/**
217+
* Try to cast value to string and fetch it
218+
* @param dst pointer to store value
219+
* @param v value to read
220+
* @return status of operation
221+
*/
222+
status_t fetch_as_string(LSPString *dst, const value_t *v);
223+
149224
status_t cast_value(value_t *v, value_type_t type);
150225
status_t cast_value(value_t *dst, const value_t *v, value_type_t type);
151226

include/lsp-plug.in/runtime/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#define LSP_RUNTIME_LIB_MAJOR 1
2626
#define LSP_RUNTIME_LIB_MINOR 0
27-
#define LSP_RUNTIME_LIB_MICRO 29
27+
#define LSP_RUNTIME_LIB_MICRO 30
2828

2929
#if defined(LSP_RUNTIME_LIB_PUBLISHER)
3030
#define LSP_RUNTIME_LIB_PUBLIC LSP_EXPORT_MODIFIER

modules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LSP_COMMON_LIB_TYPE := src
2525
LSP_COMMON_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_COMMON_LIB_NAME).git
2626
LSP_COMMON_LIB_URL_RW := git@github.com:lsp-plugins/$(LSP_COMMON_LIB_NAME).git
2727

28-
LSP_LLTL_LIB_VERSION := 1.0.26
28+
LSP_LLTL_LIB_VERSION := 1.0.27
2929
LSP_LLTL_LIB_NAME := lsp-lltl-lib
3030
LSP_LLTL_LIB_TYPE := src
3131
LSP_LLTL_LIB_URL_RO := https://github.com/lsp-plugins/$(LSP_LLTL_LIB_NAME).git

project.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ ARTIFACT_ID = LSP_RUNTIME_LIB
2323
ARTIFACT_NAME = lsp-runtime-lib
2424
ARTIFACT_DESC = Runtime library used by LSP Project for plugin development
2525
ARTIFACT_HEADERS = lsp-plug.in
26-
ARTIFACT_VERSION = 1.0.29
26+
ARTIFACT_VERSION = 1.0.30
2727
ARTIFACT_EXPORT_SYMBOLS = 1

src/main/expr/Resolver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ namespace lsp
8686
if (func != NULL)
8787
return func(value, num_args, args);
8888

89-
set_value_undef(value);
90-
return STATUS_OK;
89+
return STATUS_NOT_FOUND;
9190
}
9291

9392
status_t Resolver::call(value_t *value, const LSPString *name, size_t num_args, const value_t *args)

src/main/expr/evaluator.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,12 @@ namespace lsp
11961196
}
11971197

11981198
// Now we can perform call
1199-
return env->call(value, expr->call.name, expr->call.count, args);
1199+
res = env->call(value, expr->call.name, expr->call.count, args);
1200+
if (res != STATUS_NOT_FOUND)
1201+
return res;
1202+
1203+
set_value_undef(value);
1204+
return STATUS_OK;
12001205
}
12011206

12021207
status_t eval_value(value_t *value, const expr_t *expr, eval_env_t *env)

src/main/expr/types.cpp

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2023 Vladimir Sadovnikov <sadko4u@gmail.com>
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <sadko4u@gmail.com>
44
*
55
* This file is part of lsp-runtime-lib
66
* Created on: 19 сент. 2019 г.
@@ -210,6 +210,14 @@ namespace lsp
210210
return STATUS_OK;
211211
}
212212

213+
status_t fetch_float(double *dst, const value_t *v)
214+
{
215+
if (v->type != VT_FLOAT)
216+
return STATUS_BAD_TYPE;
217+
*dst = v->v_float;
218+
return STATUS_OK;
219+
}
220+
213221
status_t fetch_bool(bool *dst, const value_t *v)
214222
{
215223
if (v->type != VT_BOOL)
@@ -225,6 +233,103 @@ namespace lsp
225233
return (dst->set(v->v_str)) ? STATUS_OK : STATUS_NO_MEM;
226234
}
227235

236+
status_t fetch_as_int(ssize_t *dst, const value_t *v)
237+
{
238+
if (v->type == VT_INT)
239+
{
240+
*dst = v->v_int;
241+
return STATUS_OK;
242+
}
243+
244+
// Perform cast
245+
value_t tmp;
246+
init_value(&tmp);
247+
lsp_finally { destroy_value(&tmp); };
248+
249+
status_t res = cast_int(&tmp, v);
250+
if (res == STATUS_OK)
251+
*dst = tmp.v_int;
252+
253+
return res;
254+
}
255+
256+
status_t fetch_as_float(float *dst, const value_t *v)
257+
{
258+
if (v->type == VT_FLOAT)
259+
{
260+
*dst = v->v_float;
261+
return STATUS_OK;
262+
}
263+
264+
// Perform cast
265+
value_t tmp;
266+
init_value(&tmp);
267+
lsp_finally { destroy_value(&tmp); };
268+
269+
status_t res = cast_int(&tmp, v);
270+
if (res == STATUS_OK)
271+
*dst = tmp.v_float;
272+
273+
return res;
274+
}
275+
276+
status_t fetch_as_float(double *dst, const value_t *v)
277+
{
278+
if (v->type == VT_FLOAT)
279+
{
280+
*dst = v->v_float;
281+
return STATUS_OK;
282+
}
283+
284+
// Perform cast
285+
value_t tmp;
286+
init_value(&tmp);
287+
lsp_finally { destroy_value(&tmp); };
288+
289+
status_t res = cast_int(&tmp, v);
290+
if (res == STATUS_OK)
291+
*dst = tmp.v_float;
292+
293+
return res;
294+
}
295+
296+
status_t fetch_as_bool(bool *dst, const value_t *v)
297+
{
298+
if (v->type == VT_BOOL)
299+
{
300+
*dst = v->v_bool;
301+
return STATUS_OK;
302+
}
303+
304+
// Perform cast
305+
value_t tmp;
306+
init_value(&tmp);
307+
lsp_finally { destroy_value(&tmp); };
308+
309+
status_t res = cast_int(&tmp, v);
310+
if (res == STATUS_OK)
311+
*dst = tmp.v_bool;
312+
313+
return res;
314+
}
315+
316+
status_t fetch_as_string(LSPString *dst, const value_t *v)
317+
{
318+
if (v->type == VT_STRING)
319+
return (dst->set(v->v_str)) ? STATUS_OK : STATUS_NO_MEM;
320+
321+
// Perform cast
322+
value_t tmp;
323+
init_value(&tmp);
324+
lsp_finally { destroy_value(&tmp); };
325+
326+
status_t res = cast_int(&tmp, v);
327+
if (res == STATUS_OK)
328+
dst->swap(v->v_str);
329+
330+
return res;
331+
}
332+
228333
status_t cast_value(value_t *v, value_type_t type)
229334
{
230335
switch (type)

0 commit comments

Comments
 (0)