[beast: 5/12] BSE: move most Bse::Item methods into bseapi.idl



commit c34fd8f7c08b5c7e083911e05879881162e841ab
Author: Tim Janik <timj gnu org>
Date:   Sat Sep 9 01:08:10 2017 +0200

    BSE: move most Bse::Item methods into bseapi.idl
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/bseapi.idl   |   36 ++++----
 bse/bseitem.cc   |   82 +++++++++++++++++
 bse/bseitem.hh   |   31 ++++--
 bse/bseitem.proc |  269 ------------------------------------------------------
 4 files changed, 121 insertions(+), 297 deletions(-)
---
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 8155761..784e6c6 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -638,27 +638,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 single undo operation.
+  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.
+  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.
-  // 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.
-  // Item   get_parent        (); ///< Retrieve an item's parent.
   // PropertyCandidates get_property_candidates (String property_name); ///< Retrieve tentative values for 
an item or item sequence property.
-  // 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.
-  // bool   internal     (); ///< Check whether an item is internal, i.e. owned by another non-internal item.
   // 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.
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 0e8e436..ca9e2be 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -1420,4 +1420,86 @@ ItemImpl::icon (const Icon &icon)
     }
 }
 
+ItemIfaceP
+ItemImpl::get_parent ()
+{
+  return parent() ? parent()->as<ContainerIfaceP>() : NULL;
+}
+
+int
+ItemImpl::get_seqid ()
+{
+  BseItem *self = as<BseItem*>();
+  return bse_item_get_seqid (self);
+}
+
+String
+ItemImpl::get_type ()
+{
+  BseItem *self = as<BseItem*>();
+  return g_type_name (G_OBJECT_TYPE (self));
+}
+
+String
+ItemImpl::get_type_authors ()
+{
+  BseItem *self = as<BseItem*>();
+  return bse_type_get_authors (G_OBJECT_TYPE (self));
+}
+
+String
+ItemImpl::get_type_blurb ()
+{
+  BseItem *self = as<BseItem*>();
+  return bse_type_get_blurb (G_OBJECT_TYPE (self));
+}
+
+String
+ItemImpl::get_type_license ()
+{
+  BseItem *self = as<BseItem*>();
+  return bse_type_get_license (G_OBJECT_TYPE (self));
+}
+
+String
+ItemImpl::get_type_name ()
+{
+  BseItem *self = as<BseItem*>();
+  return g_type_name (G_OBJECT_TYPE (self));
+}
+
+String
+ItemImpl::get_uname_path ()
+{
+  BseItem *self = as<BseItem*>();
+  BseProject *project = bse_item_get_project (self);
+  gchar *upath = project ? bse_container_make_upath (BSE_CONTAINER (project), self) : NULL;
+  const String result = upath ? upath : "";
+  g_free (upath);
+  return result;
+}
+
+String
+ItemImpl::get_name ()
+{
+  BseItem *self = as<BseItem*>();
+  return BSE_OBJECT_UNAME (self);
+}
+
+String
+ItemImpl::get_name_or_type ()
+{
+  BseItem *self = as<BseItem*>();
+  const char *name = BSE_OBJECT_UNAME (self);
+  const String result = name ? name : BSE_OBJECT_TYPE_NAME (self);
+  return result;
+}
+
+bool
+ItemImpl::internal ()
+{
+  BseItem *self = as<BseItem*>();
+  return BSE_ITEM_INTERNAL (self);
+}
+
 } // Bse
diff --git a/bse/bseitem.hh b/bse/bseitem.hh
index d737432..572d345 100644
--- a/bse/bseitem.hh
+++ b/bse/bseitem.hh
@@ -159,17 +159,28 @@ private:
 protected:
   virtual           ~ItemImpl        ();
 public:
-  explicit           ItemImpl        (BseObject*);
-  ContainerImpl*     parent          ();
-  virtual ItemIfaceP common_ancestor (ItemIface &other) override;
-  virtual bool       check_is_a      (const String &type_name) override;
-  virtual void       group_undo      (const std::string &name) override;
-  virtual void       ungroup_undo    () override;
-  virtual ProjectIfaceP get_project  () override;
-  virtual Icon       icon            () const override;
-  virtual void       icon            (const Icon&) override;
+  explicit              ItemImpl         (BseObject*);
+  ContainerImpl*        parent           ();
+  virtual Icon          icon             () const override;
+  virtual void          icon             (const Icon&) override;
+  virtual ItemIfaceP    common_ancestor  (ItemIface &other) override;
+  virtual bool          check_is_a       (const String &type_name) override;
+  virtual void          group_undo       (const String &name) override;
+  virtual void          ungroup_undo     () override;
+  virtual ProjectIfaceP get_project      () override;
+  virtual ItemIfaceP    get_parent       () override;
+  virtual int           get_seqid        () override;
+  virtual String        get_type         () override;
+  virtual String        get_type_authors () override;
+  virtual String        get_type_blurb   () override;
+  virtual String        get_type_license () override;
+  virtual String        get_type_name    () override;
+  virtual String        get_uname_path   () override;
+  virtual String        get_name         () override;
+  virtual String        get_name_or_type () override;
+  virtual bool          internal         () override;
   /// Save the value of @a property_name onto the undo stack.
-  void               push_property_undo (const String &property_name);
+  void               push_property_undo  (const String &property_name);
   /// Push an undo @a function onto the undo stack, the @a self argument to @a function must match @a this.
   template<typename ItemT, typename... FuncArgs, typename... CallArgs> void
   push_undo (const String &blurb, ItemT &self, Error (ItemT::*function) (FuncArgs...), CallArgs... args)
diff --git a/bse/bseitem.proc b/bse/bseitem.proc
index b99f1b6..402d40a 100644
--- a/bse/bseitem.proc
+++ b/bse/bseitem.proc
@@ -12,198 +12,6 @@ AUTHORS     = "Tim Janik <timj gtk org>";
 LICENSE = "GNU Lesser General Public License";
 
 
-METHOD (BseItem, get-type) {
-  HELP = "Retrieve an item's type name.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = sfi_pspec_string ("string", NULL, 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++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  sfi_value_set_static_string (out_values++, g_type_name (G_OBJECT_TYPE (item)));
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, get-type-name) {
-  HELP = "Retrieve an item's type name.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = sfi_pspec_string ("string", NULL, 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++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  sfi_value_set_string (out_values++, g_type_name (G_OBJECT_TYPE (item)));
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, get-type-blurb) {
-  HELP = "Retrieve an item's type description.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = sfi_pspec_string ("string", NULL, 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++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  sfi_value_set_string (out_values++, bse_type_get_blurb (G_OBJECT_TYPE (item)));
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, get-type-authors) {
-  HELP = "Retrieve authors of an item's type implementation.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = sfi_pspec_string ("string", NULL, 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++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  sfi_value_set_string (out_values++, bse_type_get_authors (G_OBJECT_TYPE (item)));
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, get-type-license) {
-  HELP = "Retrieve the license for an item's type implementation.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = sfi_pspec_string ("string", NULL, 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++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  sfi_value_set_string (out_values++, bse_type_get_license (G_OBJECT_TYPE (item)));
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, get-parent) {
-  HELP = "Retrieve an item's parent.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = bse_param_spec_object ("parent", "Parent", 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;
-
-  /* set output parameters */
-  bse_value_set_object (out_values++, item->parent);
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, get-uname-path) {
-  HELP = "Retrieve the project relative uname path for this item.";
-  IN   = bse_param_spec_object ("item", NULL, NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = sfi_pspec_string ("uname_path", NULL, 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++);
-  BseProject *project;
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  project = bse_item_get_project (item);
-
-  /* set output parameters */
-  sfi_value_take_string (out_values++,
-                        project ? bse_container_make_upath (BSE_CONTAINER (project), item) : NULL);
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, internal) {
-  HELP = "Check whether an item is internal, i.e. owned by another non-internal item.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = sfi_pspec_bool ("internal", "Internal", NULL,
-                          FALSE, 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;
-
-  /* set output parameters */
-  sfi_value_set_bool (out_values++, BSE_ITEM_INTERNAL (item));
-
-  return Bse::Error::NONE;
-}
-
 METHOD (BseItem, use) {
   HELP = "Increment use count to keep an item alive.";
   IN   = bse_param_spec_object ("item", "Item", NULL,
@@ -279,83 +87,6 @@ METHOD (BseItem, set-name) {
   return Bse::Error::NONE;
 }
 
-
-METHOD (BseItem, get-name) {
-  HELP = "Retrieve an item's name.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = 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++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  sfi_value_set_string (out_values++, BSE_OBJECT_UNAME (item));
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, get-name-or-type) {
-  HELP = "Retrieve an item's name or type if it has no name.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = 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++);
-  gchar *name = NULL;
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  name = BSE_OBJECT_UNAME (item);
-  if (name)
-    sfi_value_set_string (out_values++, name);
-  else
-    sfi_value_set_string (out_values++, BSE_OBJECT_TYPE_NAME (item));
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, get-seqid) {
-  HELP = ("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.");
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = sfi_pspec_int ("seq_id", "Sequential ID", NULL,
-                        0, 0, G_MAXINT, 1, 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;
-
-  /* set output parameters */
-  sfi_value_set_int (out_values++, bse_item_get_seqid (item));
-
-  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,


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