This adds eolian_show_enum, eolian_show_global, eolian_show_constant.
*
* @see eolian_show_typedef
* @see eolian_show_struct
+ * @see eolian_show_enum
+ * @see eolian_show_global
+ * @see eolian_show_constant
* @see eolian_show_all
*
* @ingroup Eolian
*
* @see eolian_show_class
* @see eolian_show_struct
+ * @see eolian_show_enum
+ * @see eolian_show_global
+ * @see eolian_show_constant
* @see eolian_show_all
*
* @ingroup Eolian
*
* @see eolian_show_class
* @see eolian_show_typedef
+ * @see eolian_show_enum
+ * @see eolian_show_global
+ * @see eolian_show_constant
* @see eolian_show_all
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_show_struct(const char *name);
+/*
+ * @brief Show information about a given enum.
+ *
+ * If @c name is NULL, this function will print information of
+ * all the enums.
+ *
+ * @param[in] name the enum to show.
+ *
+ * @return EINA_TRUE on success, EINA_FALSE otherwise (when enum is not
+ * found).
+ *
+ * @see eolian_show_class
+ * @see eolian_show_typedef
+ * @see eolian_show_struct
+ * @see eolian_show_global
+ * @see eolian_show_constant
+ * @see eolian_show_all
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Bool eolian_show_enum(const char *name);
+
+/*
+ * @brief Show information about a given global.
+ *
+ * If @c name is NULL, this function will print information of
+ * all the globals.
+ *
+ * @param[in] name the global to show.
+ *
+ * @return EINA_TRUE on success, EINA_FALSE otherwise (when global is not
+ * found).
+ *
+ * @see eolian_show_class
+ * @see eolian_show_typedef
+ * @see eolian_show_struct
+ * @see eolian_show_enum
+ * @see eolian_show_constant
+ * @see eolian_show_all
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Bool eolian_show_global(const char *name);
+
+/*
+ * @brief Show information about a given constant.
+ *
+ * If @c name is NULL, this function will print information of
+ * all the constants.
+ *
+ * @param[in] name the constant to show.
+ *
+ * @return EINA_TRUE on success, EINA_FALSE otherwise (when constant is not
+ * found).
+ *
+ * @see eolian_show_class
+ * @see eolian_show_typedef
+ * @see eolian_show_struct
+ * @see eolian_show_enum
+ * @see eolian_show_global
+ * @see eolian_show_all
+ *
+ * @ingroup Eolian
+ */
+EAPI Eina_Bool eolian_show_constant(const char *name);
+
/*
* @brief Show information about everything.
*
* @see eolian_show_class
* @see eolian_show_typedef
* @see eolian_show_struct
+ * @see eolian_show_enum
*
* @ingroup Eolian
*/
static Eina_Bool
_struct_cb(Eina_Hash *hash EINA_UNUSED, const char *name,
- const Eolian_Type *tp, const void *fdata EINA_UNUSED)
+ const Eolian_Type *tp, const void *fdata EINA_UNUSED)
{
printf("Struct: %s\n", name);
printf(" type: <");
return EINA_TRUE;
}
+static Eina_Bool
+_enum_cb(Eina_Hash *hash EINA_UNUSED, const char *name,
+ const Eolian_Type *tp, const void *fdata EINA_UNUSED)
+{
+ printf("Enum: %s\n", name);
+ printf(" type: <");
+ database_type_print((Eolian_Type*)tp);
+ printf(">\n");
+ return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+eolian_show_enum(const char *name)
+{
+ if (!name)
+ eina_hash_foreach(_enums, (Eina_Hash_Foreach)_enum_cb, NULL);
+ else
+ {
+ Eina_Stringshare *shr = eina_stringshare_add(name);
+ Eolian_Type *tp = eina_hash_find(_enums, shr);
+ eina_stringshare_del(shr);
+ if (!tp) return EINA_FALSE;
+ _enum_cb(NULL, name, tp, NULL);
+ }
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_var_cb(Eina_Hash *hash EINA_UNUSED, const char *name,
+ const Eolian_Variable *var, const void *fdata EINA_UNUSED)
+{
+ if (var->type == EOLIAN_VAR_CONSTANT)
+ printf("Constant: %s\n", name);
+ else
+ printf("Global: %s\n", name);
+ printf(" value: <");
+ database_expr_print(var->value);
+ printf(">\n");
+ return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+eolian_show_global(const char *name)
+{
+ if (!name)
+ eina_hash_foreach(_globals, (Eina_Hash_Foreach)_var_cb, NULL);
+ else
+ {
+ Eina_Stringshare *shr = eina_stringshare_add(name);
+ Eolian_Variable *var = eina_hash_find(_globals, shr);
+ eina_stringshare_del(shr);
+ if (!var) return EINA_FALSE;
+ _var_cb(NULL, name, var, NULL);
+ }
+ return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+eolian_show_constant(const char *name)
+{
+ if (!name)
+ eina_hash_foreach(_constants, (Eina_Hash_Foreach)_var_cb, NULL);
+ else
+ {
+ Eina_Stringshare *shr = eina_stringshare_add(name);
+ Eolian_Variable *var = eina_hash_find(_constants, shr);
+ eina_stringshare_del(shr);
+ if (!var) return EINA_FALSE;
+ _var_cb(NULL, name, var, NULL);
+ }
+ return EINA_TRUE;
+}
+
EAPI void
eolian_show_all()
{
database_type_print(tp->base_type);
}
+void
+database_expr_print(Eolian_Expression *exp)
+{
+ Eina_Value *val = NULL;
+ Eolian_Expression_Type et = eolian_expression_eval(exp, EOLIAN_MASK_ALL,
+ &val);
+ const char *ret = eolian_expression_value_to_literal(val, et);
+ printf("%s", ret);
+ eina_stringshare_del(ret);
+}
+
void
database_type_print(Eolian_Type *tp)
{
printf("%s", fname);
if (ef->value)
{
- Eina_Value *val = NULL;
- Eolian_Expression_Type et = eolian_expression_eval(ef->value,
- EOLIAN_MASK_INT, &val);
- const char *ret;
printf(" = ");
- ret = eolian_expression_value_to_literal(val, et);
- printf("%s", ret);
- eina_stringshare_del(ret);
+ database_expr_print(ef->value);
}
if (l != eina_list_last(tp->field_names))
printf(", ");
Eolian_Expression_Type database_expr_eval(const Eolian_Expression *expr, Eolian_Expression_Mask mask, Eina_Value **out);
void database_expr_del(Eolian_Expression *expr);
+void database_expr_print(Eolian_Expression *expr);
/* variables */