[beast: 1/12] BSE: move Item.check_is_a into bseapi.idl



commit 6a89bc43a96b7403883002a0c29fec69ac93a8e4
Author: Tim Janik <timj gnu org>
Date:   Thu Sep 7 02:36:59 2017 +0200

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

 bse/bseapi.idl   |    5 ++---
 bse/bseitem.cc   |    9 +++++++++
 bse/bseitem.hh   |    1 +
 bse/bseitem.proc |   32 --------------------------------
 4 files changed, 12 insertions(+), 35 deletions(-)
---
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 0157e18..db556f1 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -638,9 +638,8 @@ 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.
+  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   clear_undo        (); ///< Call the clear-undo function of the project corresponding to this 
item if any.
   // 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.
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 40165e5..27587ab 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -1358,6 +1358,15 @@ ItemImpl::common_ancestor (ItemIface &other)
   return common->as<ItemIfaceP>();
 }
 
+bool
+ItemImpl::check_is_a (const String &type_name)
+{
+  BseItem *self = as<BseItem*>();
+  const GType type = g_type_from_name (type_name.c_str());
+  const bool is_a = g_type_is_a (G_OBJECT_TYPE (self), type);
+  return is_a;
+}
+
 class CustomIconKey : public DataKey<Icon*> {
   virtual void destroy (Icon *icon) override    { delete icon; }
 };
diff --git a/bse/bseitem.hh b/bse/bseitem.hh
index e425702..95c901e 100644
--- a/bse/bseitem.hh
+++ b/bse/bseitem.hh
@@ -162,6 +162,7 @@ public:
   explicit           ItemImpl        (BseObject*);
   ContainerImpl*     parent          ();
   virtual ItemIfaceP common_ancestor (ItemIface &other) override;
+  virtual bool       check_is_a      (const String &type_name) override;
   virtual Icon       icon            () const override;
   virtual void       icon            (const Icon&) override;
   /// Save the value of @a property_name onto the undo stack.
diff --git a/bse/bseitem.proc b/bse/bseitem.proc
index a57999f..4c347fb 100644
--- a/bse/bseitem.proc
+++ b/bse/bseitem.proc
@@ -380,38 +380,6 @@ METHOD (BseItem, get-seqid) {
   return Bse::Error::NONE;
 }
 
-METHOD (BseItem, check-is-a) {
-  HELP  = "Check whether an item has a certain type.";
-  IN    = bse_param_spec_object ("item", "Item", "The Item",
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  IN    = sfi_pspec_string ("type_name", "Type Name", NULL,
-                           NULL, SFI_PARAM_STANDARD);
-  OUT   = sfi_pspec_bool ("is_a", NULL, 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++);
-  const char *type_name = sfi_value_get_string (in_values++);
-  GType type;
-  gboolean is_a;
-
-  /* check parameters */
-  if (!type_name)
-    type_name = "";
-
-  /* action */
-  type = g_type_from_name (type_name);
-  is_a = item && g_type_is_a (G_OBJECT_TYPE (item), type);
-
-  /* set output parameters */
-  sfi_value_set_bool (out_values++, is_a);
-
-  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]