| 311 uic_reg_var(ctx, name, UI_VAR_DOUBLE, d); |
311 uic_reg_var(ctx, name, UI_VAR_DOUBLE, d); |
| 312 } |
312 } |
| 313 return d; |
313 return d; |
| 314 } |
314 } |
| 315 |
315 |
| |
316 static void string_destroy(UiString *s) { |
| |
317 if(s->value.free && s->value.ptr) { |
| |
318 s->value.free(s->value.ptr); |
| |
319 } |
| |
320 } |
| |
321 |
| 316 UiString* ui_string_new(UiContext *ctx, const char *name) { |
322 UiString* ui_string_new(UiContext *ctx, const char *name) { |
| 317 UiString *s = ui_malloc(ctx, sizeof(UiString)); |
323 UiString *s = ui_malloc(ctx, sizeof(UiString)); |
| 318 memset(s, 0, sizeof(UiString)); |
324 memset(s, 0, sizeof(UiString)); |
| |
325 ui_set_destructor(s, (ui_destructor_func)string_destroy); |
| 319 if(name) { |
326 if(name) { |
| 320 uic_reg_var(ctx, name, UI_VAR_STRING, s); |
327 uic_reg_var(ctx, name, UI_VAR_STRING, s); |
| 321 } |
328 } |
| 322 return s; |
329 return s; |
| |
330 } |
| |
331 |
| |
332 static void text_destroy(UiText *t) { |
| |
333 if(t->destroy) { |
| |
334 t->destroy(t); |
| |
335 } |
| 323 } |
336 } |
| 324 |
337 |
| 325 UiText* ui_text_new(UiContext *ctx, const char *name) { |
338 UiText* ui_text_new(UiContext *ctx, const char *name) { |
| 326 UiText *t = ui_malloc(ctx, sizeof(UiText)); |
339 UiText *t = ui_malloc(ctx, sizeof(UiText)); |
| 327 memset(t, 0, sizeof(UiText)); |
340 memset(t, 0, sizeof(UiText)); |
| |
341 ui_set_destructor(t, (ui_destructor_func)text_destroy); |
| 328 if(name) { |
342 if(name) { |
| 329 uic_reg_var(ctx, name, UI_VAR_TEXT, t); |
343 uic_reg_var(ctx, name, UI_VAR_TEXT, t); |
| 330 } |
344 } |
| 331 return t; |
345 return t; |
| 332 } |
346 } |
| 338 uic_reg_var(ctx, name, UI_VAR_RANGE, r); |
352 uic_reg_var(ctx, name, UI_VAR_RANGE, r); |
| 339 } |
353 } |
| 340 return r; |
354 return r; |
| 341 } |
355 } |
| 342 |
356 |
| 343 UIEXPORT UiGeneric* ui_generic_new(UiContext *ctx, const char *name) { |
357 static void generic_destroy(UiGeneric *g) { |
| |
358 if(g->destroy) { |
| |
359 g->destroy(g); |
| |
360 } |
| |
361 } |
| |
362 |
| |
363 UiGeneric* ui_generic_new(UiContext *ctx, const char *name) { |
| 344 UiGeneric *g = ui_malloc(ctx, sizeof(UiGeneric)); |
364 UiGeneric *g = ui_malloc(ctx, sizeof(UiGeneric)); |
| 345 memset(g, 0, sizeof(UiGeneric)); |
365 memset(g, 0, sizeof(UiGeneric)); |
| |
366 ui_set_destructor(g, (ui_destructor_func)generic_destroy); |
| 346 if(name) { |
367 if(name) { |
| 347 uic_reg_var(ctx, name, UI_VAR_GENERIC, g); |
368 uic_reg_var(ctx, name, UI_VAR_GENERIC, g); |
| 348 } |
369 } |
| 349 return g; |
370 return g; |
| 350 } |
371 } |