[beast: 34/57] BSE: add using namespace Bse



commit 0d21e4f21116e55f9c5d5ba9488b6eb6a065c54b
Author: Tim Janik <timj gnu org>
Date:   Mon Jul 17 02:55:32 2017 +0200

    BSE: add using namespace Bse
    
    By adding more 'using namespace Bse', we can avoid 'using namespace
    Rapicorn'.
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/bsefilter.cc        |    3 ++-
 bse/bsegconfig.cc       |    2 +-
 bse/bseladspa.cc        |    1 -
 bse/bsemain.cc          |    7 +++++--
 bse/bsestartup.cc       |    3 +--
 bse/bsestorage.cc       |   41 +++++++++++++++++++----------------------
 bse/tests/filtertest.cc |    8 +++++---
 7 files changed, 33 insertions(+), 32 deletions(-)
---
diff --git a/bse/bsefilter.cc b/bse/bsefilter.cc
index b08b9f8..faf6a3d 100644
--- a/bse/bsefilter.cc
+++ b/bse/bsefilter.cc
@@ -1,7 +1,8 @@
 // CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/
 #include "bsefilter.hh"
 #include <sfi/sfi.hh>
-using namespace Rapicorn;
+
+using namespace Bse;
 
 const gchar*
 bse_iir_filter_kind_string (BseIIRFilterKind fkind)
diff --git a/bse/bsegconfig.cc b/bse/bsegconfig.cc
index 640cc80..6deab10 100644
--- a/bse/bsegconfig.cc
+++ b/bse/bsegconfig.cc
@@ -5,7 +5,7 @@
 #include <sys/types.h>
 #include <regex.h>
 
-using namespace Rapicorn;
+using namespace Bse;
 
 // == Declarations ==
 static BseGConfig*    gconfig_from_rec  (SfiRec *rec);
diff --git a/bse/bseladspa.cc b/bse/bseladspa.cc
index caa18ec..16b28d4 100644
--- a/bse/bseladspa.cc
+++ b/bse/bseladspa.cc
@@ -5,7 +5,6 @@
 #include <sfi/sfi.hh>
 #include <string.h>
 #include "ladspa.hh"
-using namespace Rapicorn;
 
 #define LDEBUG(...)     Bse::debug ("ladspa", __VA_ARGS__)
 
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 3ddc106..fe8a23e 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -18,7 +18,10 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <sfi/sfitests.hh> /* sfti_test_init() */
-using namespace Rapicorn;
+
+using namespace Bse;
+namespace Test = Rapicorn::Test;
+namespace Aida = Rapicorn::Aida;
 
 /* --- prototypes --- */
 static void    init_parse_args (int *argc_p, char **argv_p, BseMainArgs *margs, const Bse::StringVector 
&args);
@@ -558,7 +561,7 @@ init_aida_idl ()
   // setup Aida server connection, so ServerIface::__aida_connection__() yields non-NULL
   Aida::ServerConnectionP bseserver_connection =
     Aida::ServerConnection::bind<Bse::ServerIface> (string_format ("inproc://BSE-%s", Bse::version()),
-                                                    shared_ptr_cast<Bse::ServerIface> 
(&Bse::ServerImpl::instance())); // sets errno
+                                                    Bse::shared_ptr_cast<Bse::ServerIface> 
(&Bse::ServerImpl::instance())); // sets errno
   assert_return (bseserver_connection != NULL);
   static Aida::ServerConnectionP *static_connection = new Aida::ServerConnectionP (bseserver_connection); // 
keep connection alive for entire runtime
   (void) static_connection;
diff --git a/bse/bsestartup.cc b/bse/bsestartup.cc
index d5ae5c0..ee35333 100644
--- a/bse/bsestartup.cc
+++ b/bse/bsestartup.cc
@@ -150,8 +150,7 @@ init_server_connection () // bse.hh
 {
   if (!client_connection)
     {
-      using namespace Rapicorn::Aida;
-      ClientConnectionP connection = ClientConnection::connect ("inproc://BSE-" BST_VERSION);
+      Rapicorn::Aida::ClientConnectionP connection = Rapicorn::Aida::ClientConnection::connect 
("inproc://BSE-" BST_VERSION);
       ServerH bseconnection_server_handle;
       if (connection)
         bseconnection_server_handle = connection->remote_origin<ServerH>(); // sets errno
diff --git a/bse/bsestorage.cc b/bse/bsestorage.cc
index a9ff5e8..7408097 100644
--- a/bse/bsestorage.cc
+++ b/bse/bsestorage.cc
@@ -17,6 +17,7 @@
 #include <signal.h>
 
 using Bse::Flac1Handle;
+namespace Aida = Bse::Aida;
 
 /* --- macros --- */
 #define parse_or_return sfi_scanner_parse_or_return
@@ -628,24 +629,23 @@ item_link_resolved (gpointer     data,
 template<typename ValueType = std::string> ValueType
 aux_vector_get (const std::vector<std::string> &auxvector, const std::string &field, const std::string &key, 
const std::string &fallback = "")
 {
-  return Rapicorn::string_to_type<ValueType> (Rapicorn::Aida::aux_vector_find (auxvector, field, key, 
fallback));
+  return Bse::string_to_type<ValueType> (Rapicorn::Aida::aux_vector_find (auxvector, field, key, fallback));
 }
 
 static bool
 any_set_from_string (BseStorage *self, Bse::Any &any, const std::string &string)
 {
-  using namespace Rapicorn;
   switch (any.kind())
     {
     case Aida::BOOL:
       if (string.size() == 2 && string.data()[0] == '#')
         any.set (bool (string.data()[1] == 't' || string.data()[1] == 'T'));
       else
-        any.set (string_to_bool (string));
+        any.set (Bse::string_to_bool (string));
       break;
-    case Aida::INT64:           any.set (string_to_int (string));        break;
-    case Aida::FLOAT64:         any.set (string_to_double (string));     break;
-    case Aida::STRING:          any.set (string_from_cquote (string));   break;
+    case Aida::INT64:           any.set (Bse::string_to_int (string));        break;
+    case Aida::FLOAT64:         any.set (Bse::string_to_double (string));     break;
+    case Aida::STRING:          any.set (Bse::string_from_cquote (string));   break;
     case Aida::ENUM:
       {
         const Aida::EnumInfo &einfo = any.get_enum_info();
@@ -704,7 +704,7 @@ scanner_parse_paren_rest (GScanner *scanner, std::string *result)
         {
           if (!rest.empty())
             rest += " ";
-          rest += Rapicorn::string_to_cquote (scanner->value.v_string);
+          rest += Bse::string_to_cquote (scanner->value.v_string);
         }
       else if (token == G_TOKEN_IDENTIFIER)
         {
@@ -716,7 +716,7 @@ scanner_parse_paren_rest (GScanner *scanner, std::string *result)
         {
           if (!rest.empty())
             rest += " ";
-          rest += Rapicorn::string_from_int (scanner->value.v_int);
+          rest += Bse::string_from_int (scanner->value.v_int);
         }
       else
         {
@@ -734,10 +734,9 @@ scanner_parse_paren_rest (GScanner *scanner, std::string *result)
 static GTokenType
 storage_parse_property_value (BseStorage *self, const std::string &name, Bse::Any &any, const 
std::vector<std::string> &aux_data)
 {
-  using namespace Rapicorn;
   assert_return (BSE_IS_STORAGE (self), G_TOKEN_ERROR);
   GScanner *scanner = bse_storage_get_scanner (self);
-  String rest;
+  std::string rest;
   GTokenType expected_token = scanner_parse_paren_rest (scanner, &rest);
   if (expected_token != G_TOKEN_NONE)
     return expected_token;
@@ -754,21 +753,20 @@ storage_parse_property_value (BseStorage *self, const std::string &name, Bse::An
 static GTokenType
 restore_cxx_item_property (BseItem *bitem, BseStorage *self)
 {
-  using namespace Rapicorn;
   GScanner *scanner = bse_storage_get_scanner (self);
   Bse::ItemImpl *item = bitem->as<Bse::ItemImpl*>();
   // need identifier
   if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
     return SFI_TOKEN_UNMATCHED;
-  String identifier = scanner->next_value.v_identifier;
+  std::string identifier = scanner->next_value.v_identifier;
   for (size_t i = 0; i < identifier.size(); i++)
     if (identifier.data()[i] == '-')
       identifier[i] = '_';
   // find identifier in item, we could search __aida_dir__, but *getting* is simpler
-  Any any = item->__aida_get__ (identifier);
+  Bse::Any any = item->__aida_get__ (identifier);
   if (any.kind())
     {
-      const std::vector<String> auxvector = item->__aida_aux_data__();
+      const std::vector<std::string> auxvector = item->__aida_aux_data__();
       // FIXME: need special casing of object references, see bse_storage_parse_item_link
       parse_or_return (scanner, G_TOKEN_IDENTIFIER);    // eat pspec name
       // parse Any value, including the closing ')'
@@ -1262,26 +1260,25 @@ store_item_properties (BseItem    *item,
 static void
 storage_store_property_value (BseStorage *self, const std::string &property_name, Bse::Any any, const 
std::vector<std::string> &aux_data)
 {
-  using namespace Rapicorn;
   if (Rapicorn::Aida::aux_vector_check_options (aux_data, property_name, "hints", "skip-default"))
     {
       const char *const invalid = "\377\377\376\376\1\2 invalid \3"; // no-value marker, (invalid UTF-8)
-      const String dflt_val = aux_vector_get (aux_data, property_name, "default", invalid);
+      const std::string dflt_val = aux_vector_get (aux_data, property_name, "default", invalid);
       if (dflt_val != invalid)
         {
-          Any dflt = any; // copy type
+          Bse::Any dflt = any; // copy type
           const bool any_from_string_conversion = any_set_from_string (self, dflt, dflt_val);
           if (any_from_string_conversion && dflt == any)
             return;     // skip storing default value
         }
     }
-  String target;
+  std::string target;
   switch (any.kind())
     {
-    case Aida::BOOL:            target = string_from_bool (any.get<bool>());            break;
-    case Aida::INT64:           target = string_from_int (any.get<int64>());            break;
-    case Aida::FLOAT64:         target = string_from_double (any.get<double>());        break;
-    case Aida::STRING:          target = string_to_cquote (any.get<String>());          break;
+    case Aida::BOOL:            target = Bse::string_from_bool (any.get<bool>());            break;
+    case Aida::INT64:           target = Bse::string_from_int (any.get<int64>());            break;
+    case Aida::FLOAT64:         target = Bse::string_from_double (any.get<double>());        break;
+    case Aida::STRING:          target = Bse::string_to_cquote (any.get<std::string>());     break;
     case Aida::ENUM:
       {
         const Aida::EnumInfo &einfo = any.get_enum_info();
diff --git a/bse/tests/filtertest.cc b/bse/tests/filtertest.cc
index 40b8af9..142c95a 100644
--- a/bse/tests/filtertest.cc
+++ b/bse/tests/filtertest.cc
@@ -10,7 +10,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <complex>
-using namespace Rapicorn;
+
+using namespace Bse;
+using namespace Rapicorn::Test;
 using std::max;
 using std::min;
 
@@ -531,7 +533,7 @@ random_filter_tests ()
   double pbe1;
   FilterSetup filters[100000] = { { 0, }, };
   uint filter_index, skip_count = 6;
-  if (!Test::slow())
+  if (!slow())
     n_orders = 9;
 #define MAKE_FILTER(frequest, filter_type) do                                   \
   {                                                                             \
@@ -673,7 +675,7 @@ test_filter_catalog ()
   /* include predesigned filters */
 #include "filtercatalog.cc"
   uint skip_count = 0, tick_count = 3;
-  if (!Test::slow())
+  if (!slow())
     {
       tick_count = 1;
       skip_count = 17;


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