[beast: 7/12] BSE: move Bse::Item use/unuse/set_name/editable_property into bseapi.idl



commit a9659658e550e94bc881cee24172818f74f67387
Author: Tim Janik <timj gnu org>
Date:   Sun Sep 24 03:58:59 2017 +0200

    BSE: move Bse::Item use/unuse/set_name/editable_property into bseapi.idl
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/bseapi.idl   |   42 +++++++++++------------
 bse/bseitem.cc   |   33 ++++++++++++++++++
 bse/bseitem.hh   |    4 ++
 bse/bseitem.proc |   99 ------------------------------------------------------
 4 files changed, 57 insertions(+), 121 deletions(-)
---
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 784e6c6..3fdea69 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -639,29 +639,27 @@ interface Object {
 /// Base interface type for objects that can be added to a container.
 interface Item : Object {
   Icon    icon = Record ("Icon", "State dependent icon representation of this item", "rw:G");
-  Item    common_ancestor  (Item other);       ///< Find a common container (parent or grand-parent) of two 
items if any.
-  bool    check_is_a       (String type_name); ///< Check whether an item has a certain type.
-  /// Request multiple modifying actions on an item to be grouped together as a single undo operation.
-  /// @param name       Name for the undo group to be created
-  void    group_undo       (String name);
-  void    ungroup_undo     (); ///< Ends the undo grouping opened up by a previous group-undo() call.
-  Project get_project      (); ///< Retrieve an item's project.
-  Item    get_parent       (); ///< Retrieve an item's parent.
-  int32   get_seqid        (); ///< Retrieve an item's sequential ID. The sequential ID depends on the 
item's type an it's position inbetween siblings of the same type within it's immediate container.
-  String  get_type         (); ///< Retrieve an item's type name.
-  String  get_type_authors (); ///< Retrieve authors of an item's type implementation.
-  String  get_type_blurb   (); ///< Retrieve an item's type description.
-  String  get_type_license (); ///< Retrieve the license for an item's type implementation.
-  String  get_type_name    (); ///< Retrieve an item's type name.
-  String  get_uname_path   (); ///< Retrieve the project relative uname path for this item.
-  String  get_name         (); ///< Retrieve an item's name.
-  String  get_name_or_type (); ///< Retrieve an item's name or type if it has no name.
-  bool    internal         (); ///< Check whether an item is internal, i.e. owned by another non-internal 
item.
-  // bool   editable_property (String property_name); ///< Test whether a property is editable according to 
object state and property options.
+  Item    use               (); ///< Increment use count to keep an item alive.
+  void    unuse             (); ///< Decrement use count for when an item is not needed anymore.
+  void    set_name          (String name);       ///< Assign an item's name.
+  Item    common_ancestor   (Item other);        ///< Find a common container (parent or grand-parent) of 
two items if any.
+  bool    check_is_a        (String type_name);  ///< Check whether an item has a certain type.
+  void    group_undo        (String group_name); ///< Request multiple modifying actions on an item to be 
grouped together as a single undo operation.
+  void    ungroup_undo      (); ///< Ends the undo grouping opened up by a previous group-undo() call.
+  Project get_project       (); ///< Retrieve an item's project.
+  Item    get_parent        (); ///< Retrieve an item's parent.
+  int32   get_seqid         (); ///< Retrieve an item's sequential ID. The sequential ID depends on the 
item's type an it's position inbetween siblings of the same type within it's immediate container.
+  String  get_type          (); ///< Retrieve an item's type name.
+  String  get_type_authors  (); ///< Retrieve authors of an item's type implementation.
+  String  get_type_blurb    (); ///< Retrieve an item's type description.
+  String  get_type_license  (); ///< Retrieve the license for an item's type implementation.
+  String  get_type_name     (); ///< Retrieve an item's type name.
+  String  get_uname_path    (); ///< Retrieve the project relative uname path for this item.
+  String  get_name          (); ///< Retrieve an item's name.
+  String  get_name_or_type  (); ///< Retrieve an item's name or type if it has no name.
+  bool    internal          (); ///< Check whether an item is internal, i.e. owned by another non-internal 
item.
+  bool    editable_property (String property); ///< Test whether a property is editable according to object 
state and property options.
   // PropertyCandidates get_property_candidates (String property_name); ///< Retrieve tentative values for 
an item or item sequence property.
-  // void   set_name     (String name); ///< Set an item's name.
-  // void   unuse        (); ///< Decrement use count for when an item is not needed anymore.
-  // Item   use          (); ///< Increment use count to keep an item alive.
   // int32 seqid = Range ("Sequential ID", "", ":readwrite", 0, MAXINT31, 1);
 };
 
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index ca9e2be..d6a1db0 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -1242,6 +1242,39 @@ ItemImpl::ItemImpl (BseObject *bobj) :
 ItemImpl::~ItemImpl ()
 {}
 
+ItemIfaceP
+ItemImpl::use ()
+{
+  BseItem *self = as<BseItem*>();
+  ItemIfaceP iface = self->as<ItemIfaceP>();
+  assert_return (self->parent || self->use_count, iface);
+  bse_item_use (self);
+  return iface;
+}
+
+void
+ItemImpl::unuse ()
+{
+  BseItem *self = as<BseItem*>();
+  assert_return (self->use_count >= 1);
+  bse_item_unuse (self);
+}
+
+void
+ItemImpl::set_name (const std::string &name)
+{
+  BseItem *self = as<BseItem*>();
+  if (name != BSE_OBJECT_UNAME (self))
+    bse_item_set (self, "uname", name.c_str(), NULL);
+}
+
+bool
+ItemImpl::editable_property (const std::string &property)
+{
+  BseItem *self = as<BseItem*>();
+  return bse_object_editable_property (self, property.c_str());
+}
+
 ContainerImpl*
 ItemImpl::parent ()
 {
diff --git a/bse/bseitem.hh b/bse/bseitem.hh
index 572d345..1e66ca0 100644
--- a/bse/bseitem.hh
+++ b/bse/bseitem.hh
@@ -161,6 +161,10 @@ protected:
 public:
   explicit              ItemImpl         (BseObject*);
   ContainerImpl*        parent           ();
+  virtual ItemIfaceP    use               () override;
+  virtual void          unuse             () override;
+  virtual void          set_name          (const std::string &name) override;
+  virtual bool          editable_property (const std::string &property_name) override;
   virtual Icon          icon             () const override;
   virtual void          icon             (const Icon&) override;
   virtual ItemIfaceP    common_ancestor  (ItemIface &other) override;
diff --git a/bse/bseitem.proc b/bse/bseitem.proc
index 402d40a..788dd3a 100644
--- a/bse/bseitem.proc
+++ b/bse/bseitem.proc
@@ -12,81 +12,6 @@ AUTHORS      = "Tim Janik <timj gtk org>";
 LICENSE = "GNU Lesser General Public License";
 
 
-METHOD (BseItem, use) {
-  HELP = "Increment use count to keep an item alive.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = bse_param_spec_object ("used_item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item) || (!item->parent && !item->use_count))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* action */
-  bse_item_use (item);
-
-  /* set output parameters */
-  bse_value_set_object (out_values++, item);
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, unuse) {
-  HELP = "Decrement use count for when an item is not needed anymore.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* action */
-  if (item->use_count < 1)
-    return Bse::Error::NOT_OWNER;
-
-  bse_item_unuse (item);
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, set-name) {
-  HELP = "Set an item's name.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  IN   = sfi_pspec_string ("name", "Name", NULL,
-                           NULL, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-  const gchar *name = g_value_get_string (in_values++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* action */
-  if (!bse_string_equals (name, BSE_OBJECT_UNAME (item)))
-    bse_item_set (item, "uname", name, NULL);
-
-  return Bse::Error::NONE;
-}
-
 METHOD (BseItem, get-property-candidates) {
   HELP = "Retrieve tentative values for an item or item sequence property.";
   IN   = bse_param_spec_object ("item", NULL, NULL,
@@ -118,27 +43,3 @@ METHOD (BseItem, get-property-candidates) {
   return Bse::Error::NONE;
 }
 
-METHOD (BseItem, editable-property) {
-  HELP = "Test whether a property is editable according to object state and property options.";
-  IN   = bse_param_spec_object ("item", NULL, NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  IN   = sfi_pspec_string ("property_name", NULL, "Item property name",
-                           NULL, SFI_PARAM_STANDARD);
-  OUT  = sfi_pspec_bool ("editable", NULL, NULL, FALSE, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *self = (BseItem*) bse_value_get_object (in_values++);
-  const char   *property = sfi_value_get_string (in_values++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (self) || !property)
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  sfi_value_set_bool (out_values++, bse_object_editable_property (self, property));
-
-  return Bse::Error::NONE;
-}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]