Commit c01dd91c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Add coordinates (VLC_VAR_COORDS) variable type

parent 0759e71b
...@@ -420,9 +420,10 @@ typedef union ...@@ -420,9 +420,10 @@ typedef union
vlc_object_t * p_object; vlc_object_t * p_object;
vlc_list_t * p_list; vlc_list_t * p_list;
mtime_t i_time; mtime_t i_time;
struct { int32_t x; int32_t y; } coords;
/* Make sure the structure is at least 64bits */ /* Make sure the structure is at least 64bits */
struct { char a, b, c, d, e, f, g, h; } padding; uint8_t padding[8];
} vlc_value_t; } vlc_value_t;
...@@ -456,6 +457,7 @@ struct vlc_list_t ...@@ -456,6 +457,7 @@ struct vlc_list_t
#define VLC_VAR_ADDRESS 0x0070 #define VLC_VAR_ADDRESS 0x0070
#define VLC_VAR_MUTEX 0x0080 #define VLC_VAR_MUTEX 0x0080
#define VLC_VAR_LIST 0x0090 #define VLC_VAR_LIST 0x0090
#define VLC_VAR_COORDS 0x00A0
/**@}*/ /**@}*/
/***************************************************************************** /*****************************************************************************
......
...@@ -223,6 +223,16 @@ static inline int var_SetTime( vlc_object_t *p_obj, const char *psz_name, int64_ ...@@ -223,6 +223,16 @@ static inline int var_SetTime( vlc_object_t *p_obj, const char *psz_name, int64_
return var_SetChecked( p_obj, psz_name, VLC_VAR_TIME, val ); return var_SetChecked( p_obj, psz_name, VLC_VAR_TIME, val );
} }
static inline int var_SetCoords( vlc_object_t *obj, const char *name,
int32_t x, int32_t y )
{
vlc_value_t val;
val.coords.x = x;
val.coords.y = y;
return var_SetChecked (obj, name, VLC_VAR_COORDS, val);
}
#define var_SetCoords(o,n,x,y) var_SetCoords(VLC_OBJECT(o),n,x,y)
/** /**
* Set the value of a float variable * Set the value of a float variable
* *
...@@ -323,6 +333,21 @@ static inline int64_t var_GetTime( vlc_object_t *p_obj, const char *psz_name ) ...@@ -323,6 +333,21 @@ static inline int64_t var_GetTime( vlc_object_t *p_obj, const char *psz_name )
return 0; return 0;
} }
static inline void var_GetCoords( vlc_object_t *obj, const char *name,
int32_t *px, int32_t *py )
{
vlc_value_t val;
if (likely(!var_GetChecked (obj, name, VLC_VAR_COORDS, &val)))
{
*px = val.coords.x;
*py = val.coords.y;
}
else
*px = *py = 0;
}
#define var_GetCoords(o,n,x,y) var_GetCoords(VLC_OBJECT(o),n,x,y)
/** /**
* Get a float value * Get a float value
* *
......
...@@ -751,6 +751,7 @@ static void DumpVariable (const void *data, const VISIT which, const int depth) ...@@ -751,6 +751,7 @@ static void DumpVariable (const void *data, const VISIT which, const int depth)
MYCASE( VARIABLE, "variable" ); MYCASE( VARIABLE, "variable" );
MYCASE( FLOAT, "float" ); MYCASE( FLOAT, "float" );
MYCASE( TIME, "time" ); MYCASE( TIME, "time" );
MYCASE( COORDS, "coords" );
MYCASE( ADDRESS, "address" ); MYCASE( ADDRESS, "address" );
MYCASE( MUTEX, "mutex" ); MYCASE( MUTEX, "mutex" );
MYCASE( LIST, "list" ); MYCASE( LIST, "list" );
...@@ -786,6 +787,10 @@ static void DumpVariable (const void *data, const VISIT which, const int depth) ...@@ -786,6 +787,10 @@ static void DumpVariable (const void *data, const VISIT which, const int depth)
case VLC_VAR_TIME: case VLC_VAR_TIME:
printf( ": %"PRIi64, (int64_t)p_var->val.i_time ); printf( ": %"PRIi64, (int64_t)p_var->val.i_time );
break; break;
case VLC_VAR_COORDS:
printf( ": %"PRId32"x%"PRId32,
p_var->val.coords.x, p_var->val.coords.y );
break;
case VLC_VAR_ADDRESS: case VLC_VAR_ADDRESS:
printf( ": %p", p_var->val.p_address ); printf( ": %p", p_var->val.p_address );
break; break;
......
...@@ -157,7 +157,8 @@ int_ops = { CmpInt, DupDummy, FreeDummy, }, ...@@ -157,7 +157,8 @@ int_ops = { CmpInt, DupDummy, FreeDummy, },
list_ops = { CmpAddress, DupList, FreeList, }, list_ops = { CmpAddress, DupList, FreeList, },
mutex_ops = { CmpAddress, DupDummy, FreeMutex, }, mutex_ops = { CmpAddress, DupDummy, FreeMutex, },
string_ops = { CmpString, DupString, FreeString, }, string_ops = { CmpString, DupString, FreeString, },
time_ops = { CmpTime, DupDummy, FreeDummy, }; time_ops = { CmpTime, DupDummy, FreeDummy, },
coords_ops = { NULL, DupDummy, FreeDummy, };
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -271,6 +272,10 @@ int var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) ...@@ -271,6 +272,10 @@ int var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
p_var->ops = &time_ops; p_var->ops = &time_ops;
p_var->val.i_time = 0; p_var->val.i_time = 0;
break; break;
case VLC_VAR_COORDS:
p_var->ops = &coords_ops;
p_var->val.coords.x = p_var->val.coords.y = 0;
break;
case VLC_VAR_ADDRESS: case VLC_VAR_ADDRESS:
p_var->ops = &addr_ops; p_var->ops = &addr_ops;
p_var->val.p_address = NULL; p_var->val.p_address = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment