-/* (gsmob-property gsmob property) -> object
- If property isn't present then #f is returned. */
-
-static SCM
-gdbscm_gsmob_property (SCM self, SCM property)
-{
- SCM smob;
- gdb_smob *base;
-
- smob = gsscm_get_gsmob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
- base = (gdb_smob *) SCM_SMOB_DATA (self);
-
- /* Have we switched to a hash table? */
- if (gdbscm_is_true (scm_hash_table_p (base->properties)))
- return scm_hashq_ref (base->properties, property, SCM_BOOL_F);
-
- return scm_assq_ref (base->properties, property);
-}
-
-/* (set-gsmob-property! gsmob property new-value) -> unspecified */
-
-static SCM
-gdbscm_set_gsmob_property_x (SCM self, SCM property, SCM new_value)
-{
- SCM smob, alist;
- gdb_smob *base;
-
- smob = gsscm_get_gsmob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
- base = (gdb_smob *) SCM_SMOB_DATA (self);
-
- /* Have we switched to a hash table? */
- if (gdbscm_is_true (scm_hash_table_p (base->properties)))
- {
- scm_hashq_set_x (base->properties, property, new_value);
- return SCM_UNSPECIFIED;
- }
-
- alist = scm_assq_set_x (base->properties, property, new_value);
-
- /* Did we grow the list? */
- if (!scm_is_eq (alist, base->properties))
- {
- /* If we grew the list beyond a threshold in size,
- switch to a hash table. */
- if (scm_ilength (alist) >= SMOB_PROP_HTAB_THRESHOLD)
- {
- SCM elm, htab;
-
- htab = scm_c_make_hash_table (SMOB_PROP_HTAB_THRESHOLD);
- for (elm = alist; elm != SCM_EOL; elm = scm_cdr (elm))
- scm_hashq_set_x (htab, scm_caar (elm), scm_cdar (elm));
- base->properties = htab;
- return SCM_UNSPECIFIED;
- }
- }
-
- base->properties = alist;
- return SCM_UNSPECIFIED;
-}
-
-/* (gsmob-has-property? gsmob property) -> boolean */
-
-static SCM
-gdbscm_gsmob_has_property_p (SCM self, SCM property)
-{
- SCM smob, handle;
- gdb_smob *base;
-
- smob = gsscm_get_gsmob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
- base = (gdb_smob *) SCM_SMOB_DATA (self);
-
- if (gdbscm_is_true (scm_hash_table_p (base->properties)))
- handle = scm_hashq_get_handle (base->properties, property);
- else
- handle = scm_assq (property, base->properties);
-
- return scm_from_bool (gdbscm_is_true (handle));
-}
-
-/* Helper function for gdbscm_gsmob_properties. */
-
-static SCM
-add_property_name (void *closure, SCM handle)
-{
- SCM *resultp = closure;
-
- *resultp = scm_cons (scm_car (handle), *resultp);
- return SCM_UNSPECIFIED;
-}
-
-/* (gsmob-properties gsmob) -> list
- The list is unsorted. */
-
-static SCM
-gdbscm_gsmob_properties (SCM self)
-{
- SCM smob, handle, result;
- gdb_smob *base;
-
- smob = gsscm_get_gsmob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
- base = (gdb_smob *) SCM_SMOB_DATA (self);
-
- result = SCM_EOL;
- if (gdbscm_is_true (scm_hash_table_p (base->properties)))
- {
- scm_internal_hash_for_each_handle (add_property_name, &result,
- base->properties);
- }
- else
- {
- SCM elm;
-
- for (elm = base->properties; elm != SCM_EOL; elm = scm_cdr (elm))
- result = scm_cons (scm_caar (elm), result);
- }
-
- return result;
-}