2012-01-12 08:38:53 -08:00
|
|
|
/* Eina - EFL data type library
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
* Copyright (C) 2012 ProFUSION embedded systems
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EINA_INLINE_VALUE_X_
|
|
|
|
#define EINA_INLINE_VALUE_X_
|
|
|
|
|
2012-01-20 23:44:05 -08:00
|
|
|
#include <stdlib.h>
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
#include <string.h>
|
2012-01-11 02:37:13 -08:00
|
|
|
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
#include "eina_stringshare.h"
|
|
|
|
|
|
|
|
/* NOTE: most of value is implemented here for performance reasons */
|
|
|
|
|
|
|
|
//#define EINA_VALUE_NO_OPTIMIZE 1
|
|
|
|
#ifdef EINA_VALUE_NO_OPTIMIZE
|
|
|
|
#define EINA_VALUE_TYPE_DEFAULT(type) (0)
|
|
|
|
#else
|
2012-01-11 11:46:55 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var _EINA_VALUE_TYPE_BASICS_START
|
|
|
|
* pointer to the first basic type.
|
2012-01-12 08:38:53 -08:00
|
|
|
* @since 1.2
|
2012-01-11 11:46:55 -08:00
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_START;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var _EINA_VALUE_TYPE_BASICS_END
|
|
|
|
* pointer to the last (inclusive) basic type.
|
2012-01-12 08:38:53 -08:00
|
|
|
* @since 1.2
|
2012-01-11 11:46:55 -08:00
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_END;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
#define EINA_VALUE_TYPE_DEFAULT(type) \
|
2012-01-11 11:46:55 -08:00
|
|
|
((_EINA_VALUE_TYPE_BASICS_START <= type) && \
|
|
|
|
(type <= _EINA_VALUE_TYPE_BASICS_END))
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define EINA_VALUE_TYPE_CHECK_RETURN(value) \
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(value); \
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN(eina_value_type_check(value->type))
|
|
|
|
|
|
|
|
#define EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, retval) \
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type), retval)
|
|
|
|
|
|
|
|
#define EINA_VALUE_TYPE_DISPATCH(type, method, no_method_err, ...) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (type->method) \
|
|
|
|
type->method(type, ##__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2012-01-20 12:18:10 -08:00
|
|
|
#define EINA_VALUE_TYPE_DISPATCH_RETURN(value, method, no_method_err, def_ret, ...) \
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (type->method) \
|
|
|
|
return type->method(type, ##__VA_ARGS__); \
|
|
|
|
return def_ret; \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2012-01-12 08:38:53 -08:00
|
|
|
/**
|
|
|
|
* @brief Get memory for given value (inline or allocated buffer).
|
|
|
|
* @since 1.2
|
|
|
|
* @private
|
|
|
|
*/
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
static inline void *
|
|
|
|
eina_value_memory_get(const Eina_Value *value)
|
|
|
|
{
|
|
|
|
if (value->type->value_size <= 8)
|
|
|
|
return (void *)value->value.buf;
|
|
|
|
return value->value.ptr;
|
|
|
|
}
|
|
|
|
|
2012-01-12 10:50:43 -08:00
|
|
|
/**
|
|
|
|
* @brief Allocate memory for internal value types.
|
|
|
|
* @since 1.2
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
EAPI void *eina_value_inner_alloc(size_t size);
|
|
|
|
/**
|
|
|
|
* @brief Releases memory for internal value types.
|
|
|
|
* @since 1.2
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
EAPI void eina_value_inner_free(size_t size, void *mem);
|
|
|
|
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_setup(Eina_Value *value, const Eina_Value_Type *type)
|
|
|
|
{
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(type->value_size > 0, EINA_FALSE);
|
|
|
|
|
|
|
|
value->type = type;
|
|
|
|
|
2012-01-12 10:50:43 -08:00
|
|
|
if (type->value_size <= 8) mem = &value->value;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
else
|
|
|
|
{
|
2012-01-12 10:50:43 -08:00
|
|
|
mem = value->value.ptr = eina_value_inner_alloc(type->value_size);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(mem, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
2012-01-12 10:50:43 -08:00
|
|
|
memset(mem, 0, type->value_size);
|
|
|
|
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (EINA_VALUE_TYPE_DEFAULT(type))
|
|
|
|
{
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_DISPATCH_RETURN(type, setup,
|
2013-10-11 00:49:13 -07:00
|
|
|
0, EINA_FALSE, mem);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
eina_value_flush(Eina_Value *value)
|
|
|
|
{
|
|
|
|
const Eina_Value_Type *type;
|
|
|
|
void *mem;
|
|
|
|
|
2017-08-23 13:24:52 -07:00
|
|
|
if (!value || !value->type) return;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
EINA_VALUE_TYPE_CHECK_RETURN(value);
|
|
|
|
|
|
|
|
type = value->type;
|
|
|
|
mem = eina_value_memory_get(value);
|
|
|
|
|
|
|
|
if (EINA_VALUE_TYPE_DEFAULT(type))
|
|
|
|
{
|
|
|
|
if (type == EINA_VALUE_TYPE_STRINGSHARE)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
if (value->value.ptr) eina_stringshare_del((const char*) value->value.ptr);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_STRING)
|
|
|
|
{
|
|
|
|
if (value->value.ptr) free(value->value.ptr);
|
|
|
|
}
|
2012-01-12 10:50:43 -08:00
|
|
|
else if (type->value_size > 8)
|
|
|
|
eina_value_inner_free(type->value_size, mem);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-11 00:49:13 -07:00
|
|
|
EINA_VALUE_TYPE_DISPATCH(type, flush, 0, mem);
|
2012-01-12 10:50:43 -08:00
|
|
|
if (type->value_size > 8)
|
|
|
|
eina_value_inner_free(type->value_size, mem);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
value->type = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
eina_value_compare(const Eina_Value *a, const Eina_Value *b)
|
|
|
|
{
|
|
|
|
const Eina_Value_Type *type;
|
|
|
|
void *pa, *pb;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_CHECK_RETURN_VAL(a, -1);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(b, -1);
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(a->type == b->type, -1);
|
|
|
|
|
|
|
|
type = a->type;
|
|
|
|
pa = eina_value_memory_get(a);
|
|
|
|
pb = eina_value_memory_get(b);
|
|
|
|
|
|
|
|
#ifndef EINA_VALUE_NO_OPTIMIZE
|
|
|
|
if (type == EINA_VALUE_TYPE_UCHAR)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
unsigned char *ta = (unsigned char *) pa, *tb = (unsigned char *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_USHORT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
unsigned short *ta = (unsigned short *) pa, *tb = (unsigned short *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_UINT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
unsigned int *ta = (unsigned int *) pa, *tb = (unsigned int *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2012-01-31 08:55:10 -08:00
|
|
|
else if ((type == EINA_VALUE_TYPE_ULONG) || (type == EINA_VALUE_TYPE_TIMESTAMP))
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
unsigned long *ta = (unsigned long *) pa, *tb = (unsigned long *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_UINT64)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
uint64_t *ta = (uint64_t *) pa, *tb = (uint64_t *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_CHAR)
|
|
|
|
{
|
2012-05-17 02:56:28 -07:00
|
|
|
signed char *ta = (signed char *) pa, *tb = (signed char *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_SHORT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
short *ta = (short *) pa, *tb = (short *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_INT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
int *ta = (int *) pa, *tb = (int *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_LONG)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
long *ta = (long *) pa, *tb = (long *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_INT64)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
int64_t *ta = (int64_t *) pa, *tb = (int64_t *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_FLOAT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
float *ta = (float *) pa, *tb = (float *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_DOUBLE)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
double *ta = (double *) pa, *tb = (double *) pb;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (*ta < *tb)
|
|
|
|
return -1;
|
|
|
|
else if (*ta > *tb)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_STRINGSHARE ||
|
|
|
|
type == EINA_VALUE_TYPE_STRING)
|
|
|
|
{
|
|
|
|
const char *sa = *(const char **)pa;
|
|
|
|
const char *sb = *(const char **)pb;
|
|
|
|
if (sa == sb)
|
|
|
|
return 0;
|
|
|
|
if (sa == NULL)
|
|
|
|
return -1;
|
|
|
|
if (sb == NULL)
|
|
|
|
return 1;
|
|
|
|
return strcmp(sa, sb);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-10-11 00:49:13 -07:00
|
|
|
EINA_VALUE_TYPE_DISPATCH_RETURN(type, compare, 0,
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
EINA_FALSE, pa, pb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_set(Eina_Value *value, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, value);
|
|
|
|
ret = eina_value_vset(value, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_get(const Eina_Value *value, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, value);
|
|
|
|
ret = eina_value_vget(value, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_vset(Eina_Value *value, va_list args)
|
|
|
|
{
|
|
|
|
const Eina_Value_Type *type;
|
|
|
|
void *mem;
|
2013-11-10 00:43:57 -08:00
|
|
|
va_list args_copy;
|
|
|
|
Eina_Bool r = EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
|
|
|
|
EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
|
|
|
|
type = value->type;
|
|
|
|
mem = eina_value_memory_get(value);
|
|
|
|
#ifndef EINA_VALUE_NO_OPTIMIZE
|
|
|
|
if (type == EINA_VALUE_TYPE_UCHAR)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
unsigned char *tmem = (unsigned char *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, unsigned int); /* promoted by va_arg */
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_USHORT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
unsigned short *tmem = (unsigned short *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, unsigned int); /* promoted by va_arg */
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_UINT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
unsigned int *tmem = (unsigned int *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, unsigned int);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2012-01-31 08:55:10 -08:00
|
|
|
else if ((type == EINA_VALUE_TYPE_ULONG) || (type == EINA_VALUE_TYPE_TIMESTAMP))
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
unsigned long *tmem = (unsigned long *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, unsigned long);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_UINT64)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
uint64_t *tmem = (uint64_t *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, uint64_t);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_CHAR)
|
|
|
|
{
|
2012-05-17 02:56:28 -07:00
|
|
|
signed char *tmem = (signed char *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, int); /* promoted by va_arg */
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_SHORT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
short *tmem = (short *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, int); /* promoted by va_arg */
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_INT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
int *tmem = (int *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, int);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_LONG)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
long *tmem = (long *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, long);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_INT64)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
int64_t *tmem = (int64_t *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, int64_t);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_FLOAT)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
float *tmem = (float *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, double); /* promoted by va_arg */
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_DOUBLE)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
double *tmem = (double *) mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
*tmem = va_arg(args, double);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_STRINGSHARE)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
const char *str = (const char *) va_arg(args, const char *);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return eina_stringshare_replace((const char **)&value->value.ptr, str);
|
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_STRING)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
const char *str = (const char *) va_arg(args, const char *);
|
2012-02-10 14:03:48 -08:00
|
|
|
if (value->value.ptr == str) return EINA_TRUE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (!str)
|
2012-02-10 14:03:48 -08:00
|
|
|
{
|
|
|
|
free(value->value.ptr);
|
|
|
|
value->value.ptr = NULL;
|
|
|
|
}
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
else
|
|
|
|
{
|
2012-02-10 14:03:48 -08:00
|
|
|
char *tmp = strdup(str);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!tmp) return EINA_FALSE;
|
2012-02-10 14:03:48 -08:00
|
|
|
free(value->value.ptr);
|
|
|
|
value->value.ptr = tmp;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-11-10 00:43:57 -08:00
|
|
|
va_copy(args_copy, args);
|
|
|
|
if (type->vset) r = type->vset(type, mem, args_copy);
|
|
|
|
va_end(args_copy);
|
|
|
|
|
|
|
|
return r;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_vget(const Eina_Value *value, va_list args)
|
|
|
|
{
|
|
|
|
const Eina_Value_Type *type;
|
|
|
|
const void *mem;
|
|
|
|
void *ptr;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
|
|
|
|
type = value->type;
|
|
|
|
mem = eina_value_memory_get(value);
|
|
|
|
ptr = va_arg(args, void *);
|
|
|
|
if (EINA_VALUE_TYPE_DEFAULT(type))
|
|
|
|
{
|
|
|
|
memcpy(ptr, mem, type->value_size);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2013-10-11 00:49:13 -07:00
|
|
|
EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, 0,
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
EINA_FALSE, mem, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_pset(Eina_Value *value, const void *ptr)
|
|
|
|
{
|
|
|
|
const Eina_Value_Type *type;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
|
|
|
|
|
|
|
|
type = value->type;
|
|
|
|
mem = eina_value_memory_get(value);
|
|
|
|
|
|
|
|
if (EINA_VALUE_TYPE_DEFAULT(type))
|
|
|
|
{
|
|
|
|
if (type == EINA_VALUE_TYPE_STRINGSHARE)
|
|
|
|
{
|
2012-05-08 03:51:37 -07:00
|
|
|
const char *str = *((const char * const *) ptr);
|
2012-01-11 02:37:13 -08:00
|
|
|
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return eina_stringshare_replace((const char **)&value->value.ptr,
|
2012-01-11 02:37:13 -08:00
|
|
|
str);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
}
|
|
|
|
else if (type == EINA_VALUE_TYPE_STRING)
|
|
|
|
{
|
2012-05-08 03:51:37 -07:00
|
|
|
const char *str = *((const char * const *) ptr);
|
2012-02-10 14:03:48 -08:00
|
|
|
if (value->value.ptr == str) return EINA_TRUE;
|
2012-01-11 02:37:13 -08:00
|
|
|
if (!str)
|
2012-02-10 14:03:48 -08:00
|
|
|
{
|
|
|
|
free(value->value.ptr);
|
|
|
|
value->value.ptr = NULL;
|
|
|
|
}
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
else
|
|
|
|
{
|
2012-02-10 14:03:48 -08:00
|
|
|
char *tmp = strdup(str);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!tmp) return EINA_FALSE;
|
2012-02-10 14:03:48 -08:00
|
|
|
free(value->value.ptr);
|
|
|
|
value->value.ptr = tmp;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
memcpy(mem, ptr, type->value_size);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2013-10-11 00:49:13 -07:00
|
|
|
EINA_VALUE_TYPE_DISPATCH_RETURN(value, pset, 0,
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
EINA_FALSE, mem, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_pget(const Eina_Value *value, void *ptr)
|
|
|
|
{
|
|
|
|
const Eina_Value_Type *type;
|
|
|
|
const void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
|
|
|
|
|
|
|
|
type = value->type;
|
|
|
|
mem = eina_value_memory_get(value);
|
|
|
|
if (EINA_VALUE_TYPE_DEFAULT(type))
|
|
|
|
{
|
|
|
|
memcpy(ptr, mem, type->value_size);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2013-10-11 00:49:13 -07:00
|
|
|
EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, 0,
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
EINA_FALSE, mem, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const Eina_Value_Type *
|
|
|
|
eina_value_type_get(const Eina_Value *value)
|
|
|
|
{
|
2018-05-07 09:46:42 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, NULL);
|
|
|
|
// Trigger warning if the type is NULL, but the value is != EINA_VALUE_EMTPY.
|
2018-05-10 16:41:20 -07:00
|
|
|
if (!value->type &&
|
|
|
|
value->value._guarantee)
|
2018-05-07 09:46:42 -07:00
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type), NULL);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return value->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, retval) \
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_ARRAY, retval)
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int step)
|
|
|
|
{
|
2012-01-11 02:37:13 -08:00
|
|
|
Eina_Value_Array desc = { subtype, step, NULL };
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (!eina_value_setup(value, EINA_VALUE_TYPE_ARRAY))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_pset(value, &desc))
|
|
|
|
{
|
|
|
|
eina_value_flush(value);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int
|
|
|
|
eina_value_array_count(const Eina_Value *value)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return 0;
|
2013-03-19 07:07:28 -07:00
|
|
|
return desc.array ? eina_inarray_count(desc.array) : 0;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_remove(Eina_Value *value, unsigned int position)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
mem = eina_inarray_nth(desc.array, position);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
eina_value_type_flush(desc.subtype, mem);
|
|
|
|
return eina_inarray_remove_at(desc.array, position);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_vset(Eina_Value *value, unsigned int position, va_list args)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
mem = eina_inarray_nth(desc.array, position);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_vset(desc.subtype, mem, args);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_vget(const Eina_Value *value, unsigned int position, va_list args)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
|
|
|
const void *mem;
|
|
|
|
void *ptr;
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2018-03-01 15:43:30 -08:00
|
|
|
if (position >= eina_inarray_count(desc.array))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
mem = eina_inarray_nth(desc.array, position);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ptr = va_arg(args, void *);
|
|
|
|
ret = eina_value_type_pget(desc.subtype, mem, ptr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_vinsert(Eina_Value *value, unsigned int position, va_list args)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
2012-01-12 11:16:46 -08:00
|
|
|
void *mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-01-12 11:16:46 -08:00
|
|
|
mem = eina_inarray_alloc_at(desc.array, position, 1);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
|
|
|
|
if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set;
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error_set:
|
|
|
|
eina_value_type_flush(desc.subtype, mem);
|
|
|
|
error_setup:
|
|
|
|
eina_inarray_remove_at(desc.array, position);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_vappend(Eina_Value *value, va_list args)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
2012-01-12 11:16:46 -08:00
|
|
|
void *mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
int position;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-01-12 11:16:46 -08:00
|
|
|
position = eina_inarray_count(desc.array);
|
|
|
|
mem = eina_inarray_alloc_at(desc.array, position, 1);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
|
|
|
|
if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set;
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error_set:
|
|
|
|
eina_value_type_flush(desc.subtype, mem);
|
|
|
|
error_setup:
|
|
|
|
eina_inarray_remove_at(desc.array, position);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_set(Eina_Value *value, unsigned int position, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, position);
|
|
|
|
ret = eina_value_array_vset(value, position, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_get(const Eina_Value *value, unsigned int position, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, position);
|
|
|
|
ret = eina_value_array_vget(value, position, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_insert(Eina_Value *value, unsigned int position, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, position);
|
|
|
|
ret = eina_value_array_vinsert(value, position, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool eina_value_array_append(Eina_Value *value, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, value);
|
|
|
|
ret = eina_value_array_vappend(value, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_pset(Eina_Value *value, unsigned int position, const void *ptr)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
mem = eina_inarray_nth(desc.array, position);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_pset(desc.subtype, mem, ptr);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_pget(const Eina_Value *value, unsigned int position, void *ptr)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
|
|
|
const void *mem;
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
mem = eina_inarray_nth(desc.array, position);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ret = eina_value_type_pget(desc.subtype, mem, ptr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_pinsert(Eina_Value *value, unsigned int position, const void *ptr)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
2012-01-12 11:16:46 -08:00
|
|
|
void *mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-01-12 11:16:46 -08:00
|
|
|
mem = eina_inarray_alloc_at(desc.array, position, 1);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
|
|
|
|
if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set;
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error_set:
|
|
|
|
eina_value_type_flush(desc.subtype, mem);
|
|
|
|
error_setup:
|
|
|
|
eina_inarray_remove_at(desc.array, position);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_pappend(Eina_Value *value, const void *ptr)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
2012-01-12 11:16:46 -08:00
|
|
|
void *mem;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
int position;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0);
|
|
|
|
if (!eina_value_pget(value, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-01-12 11:16:46 -08:00
|
|
|
position = eina_inarray_count(desc.array);
|
|
|
|
mem = eina_inarray_alloc_at(desc.array, position, 1);
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup;
|
|
|
|
if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set;
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error_set:
|
|
|
|
eina_value_type_flush(desc.subtype, mem);
|
|
|
|
error_setup:
|
|
|
|
eina_inarray_remove_at(desc.array, position);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-03-01 09:15:54 -08:00
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_array_value_get(const Eina_Value *src, unsigned int position, Eina_Value *dst)
|
|
|
|
{
|
|
|
|
Eina_Value_Array desc;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(src, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE);
|
|
|
|
|
|
|
|
if (!eina_value_pget(src, &desc))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (position >= eina_inarray_count(desc.array))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_setup(dst, desc.subtype))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_pset(dst, eina_inarray_nth(desc.array, position)))
|
|
|
|
{
|
|
|
|
eina_value_flush(dst);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
#undef EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL
|
|
|
|
|
2012-01-11 13:52:32 -08:00
|
|
|
#define EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, retval) \
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_LIST, retval)
|
|
|
|
|
|
|
|
static inline void *
|
|
|
|
eina_value_list_node_memory_get(const Eina_Value_Type *type, const Eina_List *node)
|
|
|
|
{
|
2014-06-05 13:50:20 -07:00
|
|
|
if (node == NULL || type == NULL) return NULL;
|
2012-01-11 13:52:32 -08:00
|
|
|
if (type->value_size <= sizeof(void*))
|
|
|
|
return (void *)&(node->data);
|
|
|
|
return node->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *
|
|
|
|
eina_value_list_node_memory_setup(const Eina_Value_Type *type, Eina_List *node)
|
|
|
|
{
|
|
|
|
if (type->value_size <= sizeof(void*))
|
|
|
|
return (void *)&(node->data);
|
|
|
|
node->data = malloc(type->value_size);
|
|
|
|
return node->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
eina_value_list_node_memory_flush(const Eina_Value_Type *type, Eina_List *node)
|
|
|
|
{
|
|
|
|
if (type->value_size <= sizeof(void*))
|
|
|
|
return;
|
2013-07-16 02:11:50 -07:00
|
|
|
if (node->data != (void*)1L) free(node->data);
|
2012-01-11 13:52:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_setup(Eina_Value *value, const Eina_Value_Type *subtype)
|
|
|
|
{
|
|
|
|
Eina_Value_List desc = { subtype, NULL };
|
|
|
|
if (!eina_value_setup(value, EINA_VALUE_TYPE_LIST))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_pset(value, &desc))
|
|
|
|
{
|
|
|
|
eina_value_flush(value);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int
|
|
|
|
eina_value_list_count(const Eina_Value *value)
|
|
|
|
{
|
|
|
|
Eina_Value_List *desc;
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return 0;
|
|
|
|
return eina_list_count(desc->list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_remove(Eina_Value *value, unsigned int position)
|
|
|
|
{
|
|
|
|
Eina_Value_List *desc;
|
|
|
|
Eina_List *node;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
node = eina_list_nth_list(desc->list, position);
|
|
|
|
mem = eina_value_list_node_memory_get(desc->subtype, node);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
eina_value_type_flush(desc->subtype, mem);
|
|
|
|
eina_value_list_node_memory_flush(desc->subtype, node);
|
|
|
|
desc->list = eina_list_remove_list(desc->list, node);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_vset(Eina_Value *value, unsigned int position, va_list args)
|
|
|
|
{
|
|
|
|
Eina_Value_List *desc;
|
|
|
|
Eina_List *node;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
node = eina_list_nth_list(desc->list, position);
|
|
|
|
mem = eina_value_list_node_memory_get(desc->subtype, node);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_vset(desc->subtype, mem, args);
|
2012-01-11 13:52:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_vget(const Eina_Value *value, unsigned int position, va_list args)
|
|
|
|
{
|
2012-01-12 14:58:31 -08:00
|
|
|
const Eina_Value_List *desc;
|
2012-01-11 13:52:32 -08:00
|
|
|
const Eina_List *node;
|
|
|
|
const void *mem;
|
|
|
|
void *ptr;
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-12 14:58:31 -08:00
|
|
|
desc = (const Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
node = eina_list_nth_list(desc->list, position);
|
|
|
|
mem = eina_value_list_node_memory_get(desc->subtype, node);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ptr = va_arg(args, void *);
|
|
|
|
ret = eina_value_type_pget(desc->subtype, mem, ptr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_vinsert(Eina_Value *value, unsigned int position, va_list args)
|
|
|
|
{
|
|
|
|
Eina_Value_List *desc;
|
|
|
|
Eina_List *node;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!desc->list)
|
|
|
|
node = desc->list = eina_list_append(NULL, (void*)1L);
|
|
|
|
else if (position == 0)
|
|
|
|
node = desc->list = eina_list_prepend(desc->list, (void*)1L);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Eina_List *rel = eina_list_nth_list(desc->list, position - 1);
|
|
|
|
desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel);
|
|
|
|
node = rel->next;
|
|
|
|
}
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
|
|
|
|
|
|
|
|
mem = eina_value_list_node_memory_setup(desc->subtype, node);
|
|
|
|
if (!mem)
|
|
|
|
{
|
|
|
|
desc->list = eina_list_remove_list(desc->list, node);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
|
|
|
|
if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set;
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error_set:
|
|
|
|
eina_value_type_flush(desc->subtype, mem);
|
|
|
|
error_setup:
|
|
|
|
eina_value_list_node_memory_flush(desc->subtype, node);
|
|
|
|
desc->list = eina_list_remove_list(desc->list, node);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_vappend(Eina_Value *value, va_list args)
|
|
|
|
{
|
|
|
|
Eina_Value_List *desc;
|
|
|
|
Eina_List *node;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
desc->list = eina_list_append(desc->list, (void*)1L);
|
|
|
|
node = eina_list_last(desc->list);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
|
|
|
|
|
|
|
|
mem = eina_value_list_node_memory_setup(desc->subtype, node);
|
|
|
|
if (!mem)
|
|
|
|
{
|
|
|
|
desc->list = eina_list_remove_list(desc->list, node);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
|
|
|
|
if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set;
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error_set:
|
|
|
|
eina_value_type_flush(desc->subtype, mem);
|
|
|
|
error_setup:
|
|
|
|
eina_value_list_node_memory_flush(desc->subtype, node);
|
|
|
|
desc->list = eina_list_remove_list(desc->list, node);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_set(Eina_Value *value, unsigned int position, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, position);
|
|
|
|
ret = eina_value_list_vset(value, position, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_get(const Eina_Value *value, unsigned int position, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, position);
|
|
|
|
ret = eina_value_list_vget(value, position, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_insert(Eina_Value *value, unsigned int position, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, position);
|
|
|
|
ret = eina_value_list_vinsert(value, position, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool eina_value_list_append(Eina_Value *value, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, value);
|
|
|
|
ret = eina_value_list_vappend(value, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_pset(Eina_Value *value, unsigned int position, const void *ptr)
|
|
|
|
{
|
|
|
|
Eina_Value_List *desc;
|
|
|
|
Eina_List *node;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
node = eina_list_nth_list(desc->list, position);
|
|
|
|
mem = eina_value_list_node_memory_get(desc->subtype, node);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_pset(desc->subtype, mem, ptr);
|
2012-01-11 13:52:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_pget(const Eina_Value *value, unsigned int position, void *ptr)
|
|
|
|
{
|
2012-01-12 14:58:31 -08:00
|
|
|
const Eina_Value_List *desc;
|
2012-01-11 13:52:32 -08:00
|
|
|
const Eina_List *node;
|
|
|
|
const void *mem;
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-12 14:58:31 -08:00
|
|
|
desc = (const Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
node = eina_list_nth_list(desc->list, position);
|
|
|
|
mem = eina_value_list_node_memory_get(desc->subtype, node);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ret = eina_value_type_pget(desc->subtype, mem, ptr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_pinsert(Eina_Value *value, unsigned int position, const void *ptr)
|
|
|
|
{
|
|
|
|
Eina_Value_List *desc;
|
|
|
|
Eina_List *node;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!desc->list)
|
|
|
|
node = desc->list = eina_list_append(NULL, (void*)1L);
|
|
|
|
else if (position == 0)
|
|
|
|
node = desc->list = eina_list_prepend(desc->list, (void*)1L);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Eina_List *rel = eina_list_nth_list(desc->list, position - 1);
|
|
|
|
desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel);
|
|
|
|
node = rel->next;
|
|
|
|
}
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
|
|
|
|
|
|
|
|
mem = eina_value_list_node_memory_setup(desc->subtype, node);
|
|
|
|
if (!mem)
|
|
|
|
{
|
|
|
|
desc->list = eina_list_remove_list(desc->list, node);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
|
|
|
|
if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set;
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error_set:
|
|
|
|
eina_value_type_flush(desc->subtype, mem);
|
|
|
|
error_setup:
|
|
|
|
eina_value_list_node_memory_flush(desc->subtype, node);
|
|
|
|
desc->list = eina_list_remove_list(desc->list, node);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_list_pappend(Eina_Value *value, const void *ptr)
|
|
|
|
{
|
|
|
|
Eina_Value_List *desc;
|
|
|
|
Eina_List *node;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_List *)eina_value_memory_get(value);
|
2012-01-11 13:52:32 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
desc->list = eina_list_append(desc->list, (void*)1L);
|
|
|
|
node = eina_list_last(desc->list);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE);
|
|
|
|
|
|
|
|
mem = eina_value_list_node_memory_setup(desc->subtype, node);
|
|
|
|
if (!mem)
|
|
|
|
{
|
|
|
|
desc->list = eina_list_remove_list(desc->list, node);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup;
|
|
|
|
if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set;
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error_set:
|
|
|
|
eina_value_type_flush(desc->subtype, mem);
|
|
|
|
error_setup:
|
|
|
|
eina_value_list_node_memory_flush(desc->subtype, node);
|
|
|
|
desc->list = eina_list_remove_list(desc->list, node);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
#undef EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL
|
|
|
|
|
2012-01-11 15:54:35 -08:00
|
|
|
#define EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, retval) \
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_HASH, retval)
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_hash_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int buckets_power_size)
|
|
|
|
{
|
|
|
|
Eina_Value_Hash desc = { subtype, buckets_power_size, NULL };
|
|
|
|
if (!eina_value_setup(value, EINA_VALUE_TYPE_HASH))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_pset(value, &desc))
|
|
|
|
{
|
|
|
|
eina_value_flush(value);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int
|
|
|
|
eina_value_hash_population(const Eina_Value *value)
|
|
|
|
{
|
|
|
|
Eina_Value_Hash *desc;
|
|
|
|
EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_Hash *)eina_value_memory_get(value);
|
2012-01-11 15:54:35 -08:00
|
|
|
if (!desc)
|
|
|
|
return 0;
|
|
|
|
return eina_hash_population(desc->hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_hash_del(Eina_Value *value, const char *key)
|
|
|
|
{
|
|
|
|
Eina_Value_Hash *desc;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_Hash *)eina_value_memory_get(value);
|
2012-01-11 15:54:35 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
mem = eina_hash_find(desc->hash, key);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
eina_value_type_flush(desc->subtype, mem);
|
|
|
|
free(mem);
|
|
|
|
eina_hash_del_by_key(desc->hash, key);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_hash_vset(Eina_Value *value, const char *key, va_list args)
|
|
|
|
{
|
|
|
|
Eina_Value_Hash *desc;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_Hash *)eina_value_memory_get(value);
|
2012-01-11 15:54:35 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
mem = eina_hash_find(desc->hash, key);
|
2012-02-10 13:43:55 -08:00
|
|
|
if (!mem)
|
2012-01-11 15:54:35 -08:00
|
|
|
{
|
|
|
|
mem = malloc(desc->subtype->value_size);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!mem) return EINA_FALSE;
|
2012-01-11 15:54:35 -08:00
|
|
|
if (!eina_hash_add(desc->hash, key, mem))
|
|
|
|
{
|
|
|
|
free(mem);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2012-02-10 13:43:55 -08:00
|
|
|
if (!eina_value_type_setup(desc->subtype, mem))
|
|
|
|
{
|
|
|
|
eina_value_type_flush(desc->subtype, mem);
|
|
|
|
eina_hash_del_by_key(desc->hash, key);
|
|
|
|
free(mem);
|
2013-10-03 17:54:27 -07:00
|
|
|
return EINA_FALSE;
|
2012-02-10 13:43:55 -08:00
|
|
|
}
|
2012-01-11 15:54:35 -08:00
|
|
|
}
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_vset(desc->subtype, mem, args);
|
2012-01-11 15:54:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_hash_vget(const Eina_Value *value, const char *key, va_list args)
|
|
|
|
{
|
2012-01-12 14:58:31 -08:00
|
|
|
const Eina_Value_Hash *desc;
|
2012-01-11 15:54:35 -08:00
|
|
|
const void *mem;
|
|
|
|
void *ptr;
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
2012-01-12 14:58:31 -08:00
|
|
|
desc = (const Eina_Value_Hash *)eina_value_memory_get(value);
|
2012-01-11 15:54:35 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
mem = eina_hash_find(desc->hash, key);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ptr = va_arg(args, void *);
|
|
|
|
ret = eina_value_type_pget(desc->subtype, mem, ptr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_hash_set(Eina_Value *value, const char *key, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, key);
|
|
|
|
ret = eina_value_hash_vset(value, key, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_hash_get(const Eina_Value *value, const char *key, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, key);
|
|
|
|
ret = eina_value_hash_vget(value, key, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_hash_pset(Eina_Value *value, const char *key, const void *ptr)
|
|
|
|
{
|
|
|
|
Eina_Value_Hash *desc;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
2012-01-11 16:24:22 -08:00
|
|
|
desc = (Eina_Value_Hash *)eina_value_memory_get(value);
|
2012-01-11 15:54:35 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
mem = eina_hash_find(desc->hash, key);
|
2012-02-10 13:43:55 -08:00
|
|
|
if (!mem)
|
2012-01-11 15:54:35 -08:00
|
|
|
{
|
|
|
|
mem = malloc(desc->subtype->value_size);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!mem) return EINA_FALSE;
|
2012-01-11 15:54:35 -08:00
|
|
|
if (!eina_hash_add(desc->hash, key, mem))
|
|
|
|
{
|
|
|
|
free(mem);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2012-02-10 13:43:55 -08:00
|
|
|
if (!eina_value_type_setup(desc->subtype, mem))
|
|
|
|
{
|
|
|
|
eina_value_type_flush(desc->subtype, mem);
|
|
|
|
eina_hash_del_by_key(desc->hash, key);
|
|
|
|
free(mem);
|
2013-10-03 17:54:27 -07:00
|
|
|
return EINA_FALSE;
|
2012-02-10 13:43:55 -08:00
|
|
|
}
|
2012-01-11 15:54:35 -08:00
|
|
|
}
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_pset(desc->subtype, mem, ptr);
|
2012-01-11 15:54:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_hash_pget(const Eina_Value *value, const char *key, void *ptr)
|
|
|
|
{
|
2012-01-12 14:58:31 -08:00
|
|
|
const Eina_Value_Hash *desc;
|
2012-01-11 15:54:35 -08:00
|
|
|
const void *mem;
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
|
2012-01-12 14:58:31 -08:00
|
|
|
desc = (const Eina_Value_Hash *)eina_value_memory_get(value);
|
2012-01-11 15:54:35 -08:00
|
|
|
if (!desc)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
mem = eina_hash_find(desc->hash, key);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ret = eina_value_type_pget(desc->subtype, mem, ptr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#undef EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL
|
|
|
|
|
2012-01-12 14:58:31 -08:00
|
|
|
#define EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, retval) \
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_STRUCT, retval)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Find member of struct
|
|
|
|
* @since 1.2
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
EAPI const Eina_Value_Struct_Member *eina_value_struct_member_find(const Eina_Value_Struct *st, const char *name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_setup(Eina_Value *value, const Eina_Value_Struct_Desc *sdesc)
|
|
|
|
{
|
|
|
|
Eina_Value_Struct desc = {sdesc, NULL};
|
|
|
|
if (!eina_value_setup(value, EINA_VALUE_TYPE_STRUCT))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_pset(value, &desc))
|
|
|
|
{
|
|
|
|
eina_value_flush(value);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2017-08-24 07:13:56 -07:00
|
|
|
static inline const Eina_Value_Struct_Desc *
|
|
|
|
eina_value_struct_desc_get(const Eina_Value *value)
|
|
|
|
{
|
|
|
|
const Eina_Value_Struct *st;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, NULL);
|
|
|
|
st = (const Eina_Value_Struct *)eina_value_memory_get(value);
|
|
|
|
if ((!st) || (!st->desc))
|
|
|
|
return NULL;
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(st->desc->version == EINA_VALUE_STRUCT_DESC_VERSION, NULL);
|
|
|
|
return st->desc;
|
|
|
|
}
|
|
|
|
|
2012-01-12 14:58:31 -08:00
|
|
|
static inline void *
|
|
|
|
eina_value_struct_member_memory_get(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member)
|
|
|
|
{
|
|
|
|
unsigned char *base = (unsigned char *)st->memory;
|
|
|
|
if (!base) return NULL;
|
|
|
|
return base + member->offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_vset(Eina_Value *value, const char *name, va_list args)
|
|
|
|
{
|
|
|
|
const Eina_Value_Struct_Member *member;
|
|
|
|
Eina_Value_Struct *st;
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
|
|
|
|
st = (Eina_Value_Struct *)eina_value_memory_get(value);
|
|
|
|
if (!st)
|
|
|
|
return EINA_FALSE;
|
|
|
|
member = eina_value_struct_member_find(st, name);
|
|
|
|
if (!member)
|
|
|
|
return EINA_FALSE;
|
|
|
|
mem = eina_value_struct_member_memory_get(st, member);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_vset(member->type, mem, args);
|
2012-01-12 14:58:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_vget(const Eina_Value *value, const char *name, va_list args)
|
|
|
|
{
|
|
|
|
const Eina_Value_Struct_Member *member;
|
|
|
|
const Eina_Value_Struct *st;
|
|
|
|
const void *mem;
|
|
|
|
void *ptr;
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
|
|
|
|
st = (const Eina_Value_Struct *)eina_value_memory_get(value);
|
|
|
|
if (!st)
|
|
|
|
return EINA_FALSE;
|
|
|
|
member = eina_value_struct_member_find(st, name);
|
|
|
|
if (!member)
|
|
|
|
return EINA_FALSE;
|
|
|
|
mem = eina_value_struct_member_memory_get(st, member);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ptr = va_arg(args, void *);
|
|
|
|
ret = eina_value_type_pget(member->type, mem, ptr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_set(Eina_Value *value, const char *name, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, name);
|
|
|
|
ret = eina_value_struct_vset(value, name, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_get(const Eina_Value *value, const char *name, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
Eina_Bool ret;
|
|
|
|
va_start(args, name);
|
|
|
|
ret = eina_value_struct_vget(value, name, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_pset(Eina_Value *value, const char *name, const void *ptr)
|
|
|
|
{
|
|
|
|
const Eina_Value_Struct_Member *member;
|
|
|
|
Eina_Value_Struct *st;
|
|
|
|
void *mem;
|
|
|
|
|
2012-01-24 14:56:17 -08:00
|
|
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
|
2012-01-12 14:58:31 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
|
2012-01-24 14:56:17 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
|
2012-01-12 14:58:31 -08:00
|
|
|
st = (Eina_Value_Struct *)eina_value_memory_get(value);
|
|
|
|
if (!st)
|
|
|
|
return EINA_FALSE;
|
|
|
|
member = eina_value_struct_member_find(st, name);
|
|
|
|
if (!member)
|
|
|
|
return EINA_FALSE;
|
|
|
|
mem = eina_value_struct_member_memory_get(st, member);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_pset(member->type, mem, ptr);
|
2012-01-12 14:58:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_pget(const Eina_Value *value, const char *name, void *ptr)
|
|
|
|
{
|
|
|
|
const Eina_Value_Struct_Member *member;
|
|
|
|
const Eina_Value_Struct *st;
|
|
|
|
const void *mem;
|
|
|
|
Eina_Bool ret;
|
|
|
|
|
2012-01-24 14:56:17 -08:00
|
|
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
|
2012-01-12 14:58:31 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
|
2012-01-24 14:56:17 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
|
2012-01-12 14:58:31 -08:00
|
|
|
st = (const Eina_Value_Struct *)eina_value_memory_get(value);
|
|
|
|
if (!st)
|
|
|
|
return EINA_FALSE;
|
|
|
|
member = eina_value_struct_member_find(st, name);
|
|
|
|
if (!member)
|
|
|
|
return EINA_FALSE;
|
|
|
|
mem = eina_value_struct_member_memory_get(st, member);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ret = eina_value_type_pget(member->type, mem, ptr);
|
|
|
|
return ret;
|
|
|
|
}
|
2012-01-24 14:56:17 -08:00
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_value_get(const Eina_Value *src, const char *name, Eina_Value *dst)
|
|
|
|
{
|
|
|
|
const Eina_Value_Struct_Member *member;
|
|
|
|
const Eina_Value_Struct *st;
|
|
|
|
const void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(src, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE);
|
|
|
|
st = (const Eina_Value_Struct *)eina_value_memory_get(src);
|
|
|
|
if (!st)
|
|
|
|
return EINA_FALSE;
|
|
|
|
member = eina_value_struct_member_find(st, name);
|
|
|
|
if (!member)
|
|
|
|
return EINA_FALSE;
|
|
|
|
mem = eina_value_struct_member_memory_get(st, member);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_setup(dst, member->type))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_pset(dst, mem))
|
|
|
|
{
|
|
|
|
eina_value_flush(dst);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_value_set(Eina_Value *dst, const char *name, const Eina_Value *src)
|
|
|
|
{
|
|
|
|
const Eina_Value_Struct_Member *member;
|
|
|
|
Eina_Value_Struct *st;
|
|
|
|
void *mem;
|
|
|
|
const void *ptr;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(dst, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
|
|
|
|
|
|
|
|
st = (Eina_Value_Struct *)eina_value_memory_get(dst);
|
|
|
|
if (!st)
|
|
|
|
return EINA_FALSE;
|
|
|
|
member = eina_value_struct_member_find(st, name);
|
|
|
|
if (!member)
|
|
|
|
return EINA_FALSE;
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(src->type == member->type, EINA_FALSE);
|
|
|
|
|
|
|
|
mem = eina_value_struct_member_memory_get(st, member);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ptr = eina_value_memory_get(src);
|
|
|
|
if (!ptr)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_pset(member->type, mem, ptr);
|
2012-01-24 14:56:17 -08:00
|
|
|
}
|
|
|
|
|
2012-01-25 08:58:57 -08:00
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_member_value_get(const Eina_Value *src, const Eina_Value_Struct_Member *member, Eina_Value *dst)
|
|
|
|
{
|
|
|
|
const Eina_Value_Struct *st;
|
|
|
|
const void *mem;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(src, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(member, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE);
|
|
|
|
st = (const Eina_Value_Struct *)eina_value_memory_get(src);
|
|
|
|
if (!st)
|
|
|
|
return EINA_FALSE;
|
|
|
|
mem = eina_value_struct_member_memory_get(st, member);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_setup(dst, member->type))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (!eina_value_pset(dst, mem))
|
|
|
|
{
|
|
|
|
eina_value_flush(dst);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_struct_member_value_set(Eina_Value *dst, const Eina_Value_Struct_Member *member, const Eina_Value *src)
|
|
|
|
{
|
|
|
|
Eina_Value_Struct *st;
|
|
|
|
void *mem;
|
|
|
|
const void *ptr;
|
|
|
|
|
|
|
|
EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(dst, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(member, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
|
|
|
|
|
|
|
|
st = (Eina_Value_Struct *)eina_value_memory_get(dst);
|
|
|
|
if (!st)
|
|
|
|
return EINA_FALSE;
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(src->type == member->type, EINA_FALSE);
|
|
|
|
|
|
|
|
mem = eina_value_struct_member_memory_get(st, member);
|
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ptr = eina_value_memory_get(src);
|
|
|
|
if (!ptr)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2012-02-10 13:43:55 -08:00
|
|
|
return eina_value_type_pset(member->type, mem, ptr);
|
2012-01-25 08:58:57 -08:00
|
|
|
}
|
|
|
|
|
2012-01-12 14:58:31 -08:00
|
|
|
#undef EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL
|
|
|
|
|
2015-07-08 20:57:38 -07:00
|
|
|
#define EINA_VALUE_TYPE_OPTIONAL_CHECK_RETURN_VAL(value, retval) \
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type->setup == EINA_VALUE_TYPE_OPTIONAL->setup, retval)
|
|
|
|
|
|
|
|
static inline Eina_Value*
|
2016-01-11 13:18:37 -08:00
|
|
|
eina_value_optional_empty_new(void)
|
2015-07-08 20:57:38 -07:00
|
|
|
{
|
|
|
|
return eina_value_new(EINA_VALUE_TYPE_OPTIONAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct _Eina_Value_Optional_Outer
|
|
|
|
{
|
|
|
|
Eina_Value_Type const* subtype;
|
|
|
|
void* value;
|
|
|
|
};
|
|
|
|
typedef struct _Eina_Value_Optional_Outer Eina_Value_Optional_Outer;
|
|
|
|
|
|
|
|
struct _Eina_Value_Optional_Inner
|
|
|
|
{
|
|
|
|
Eina_Value_Type const* subtype;
|
|
|
|
char value[];
|
|
|
|
};
|
|
|
|
typedef struct _Eina_Value_Optional_Inner Eina_Value_Optional_Inner;
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_optional_empty_is(const Eina_Value *value, Eina_Bool *is_empty)
|
|
|
|
{
|
2016-02-01 03:17:01 -08:00
|
|
|
void *mem;
|
|
|
|
|
2015-07-08 20:57:38 -07:00
|
|
|
EINA_VALUE_TYPE_OPTIONAL_CHECK_RETURN_VAL(value, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(is_empty, EINA_FALSE);
|
|
|
|
|
2016-02-01 03:17:01 -08:00
|
|
|
mem = eina_value_memory_get(value);
|
2015-07-08 20:57:38 -07:00
|
|
|
if (!mem)
|
|
|
|
return EINA_FALSE;
|
|
|
|
if(2*sizeof(void*) <= sizeof(Eina_Value_Union))
|
|
|
|
{
|
|
|
|
Eina_Value_Optional_Outer* opt = (Eina_Value_Optional_Outer*)mem;
|
|
|
|
*is_empty = !opt->subtype;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*is_empty = ! *(void**)mem;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const Eina_Value_Type *
|
|
|
|
eina_value_optional_type_get(Eina_Value *value)
|
|
|
|
{
|
2016-02-01 03:17:01 -08:00
|
|
|
void *mem;
|
|
|
|
|
2015-07-08 20:57:38 -07:00
|
|
|
EINA_VALUE_TYPE_OPTIONAL_CHECK_RETURN_VAL(value, (const Eina_Value_Type *)NULL);
|
|
|
|
|
2016-02-01 03:17:01 -08:00
|
|
|
mem = eina_value_memory_get(value);
|
2015-07-08 20:57:38 -07:00
|
|
|
if (!mem)
|
2015-12-14 21:12:21 -08:00
|
|
|
return NULL;
|
2015-07-08 20:57:38 -07:00
|
|
|
|
|
|
|
if(2*sizeof(void*) <= sizeof(Eina_Value_Union))
|
|
|
|
{
|
|
|
|
Eina_Value_Optional_Outer* opt = (Eina_Value_Optional_Outer*)mem;
|
|
|
|
return opt->subtype;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Eina_Value_Optional_Inner* opt = *(Eina_Value_Optional_Inner**)mem;
|
|
|
|
if(!opt)
|
|
|
|
return NULL;
|
|
|
|
return opt->subtype;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#undef EINA_VALUE_TYPE_OPTIONAL_CHECK_RETURN_VAL
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_type_setup(const Eina_Value_Type *type, void *mem)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!type->setup) return EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return type->setup(type, mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_type_flush(const Eina_Value_Type *type, void *mem)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!type->flush) return EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return type->flush(type, mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!type->copy) return EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return type->copy(type, src, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2012-01-12 14:58:31 -08:00
|
|
|
eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b)
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!type->compare) return EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return type->compare(type, a, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!type->convert_to) return EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return type->convert_to(type, convert, type_mem, convert_mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!type->convert_from) return EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return type->convert_from(type, convert, type_mem, convert_mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!type->vset) return EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return type->vset(type, mem, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!type->pset) return EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return type->pset(type, mem, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE);
|
2013-10-11 00:49:13 -07:00
|
|
|
if (!type->pget) return EINA_FALSE;
|
add eina_value.
eina value is a generic value storage, it's quite efficient to space
(16 bytes) and speed (inlines for basic types).
It's basically a structure describing how to manage memory
(Eina_Value_Type), with default implementation for char, short, int,
long, int64_t (and unsigned variants), float, double, stringshare and
string.
If a type 'value_size' is smaller than 8 bytes, it's stored
inline. Otherwise a value is allocated and managed.
Most of the methods are inline, with special handling for char, short,
int... Then no extra calls are made, allowing the compiler to optimize
them.
For array of a single type it is recommend to use Eina_Value_Array, as
it will efficiently store and access members (just a char if subtype
is EINA_VALUE_TYPE_CHAR, etc).
It can copy itself, compare itself. Including arrays.
It would be nice to have something that converts between EET and this.
SVN revision: 67035
2012-01-10 18:20:26 -08:00
|
|
|
return type->pget(type, mem, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef EINA_VALUE_TYPE_DEFAULT
|
|
|
|
#undef EINA_VALUE_TYPE_CHECK_RETURN
|
|
|
|
#undef EINA_VALUE_TYPE_CHECK_RETURN_VAL
|
|
|
|
#undef EINA_VALUE_TYPE_DISPATCH
|
|
|
|
#undef EINA_VALUE_TYPE_DISPATCH_RETURN
|
|
|
|
#endif
|