gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r9546: Cleanups of extension handlin


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9546: Cleanups of extension handling, replace C-style implementation with
Date: Wed, 30 Jul 2008 19:04:15 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9546
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2008-07-30 19:04:15 +0200
message:
  Cleanups of extension handling, replace C-style implementation with
  (unoptimized) C++ one. It won't be a bottleneck, but some further
  cleanup would be fine.
  
  Other minor cleanups.
  
  Restore -ansi now that some non-standard functions have gone and see
  how far the win32 build gets.
modified:
  configure.ac
  libbase/extension.cpp
  libbase/extension.h
  libbase/rc.h
  libbase/sharedlib.cpp
  libbase/sharedlib.h
  libcore/vm/ActionExec.cpp
    ------------------------------------------------------------
    revno: 9545.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2008-07-30 10:36:48 +0200
    message:
      Silence try debugging.
    modified:
      libcore/vm/ActionExec.cpp
    ------------------------------------------------------------
    revno: 9545.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2008-07-30 10:55:45 +0200
    message:
      Drop unused methods. They can be implemented again, perhaps better,
      if needed.
    modified:
      libbase/sharedlib.cpp
      libbase/sharedlib.h
    ------------------------------------------------------------
    revno: 9545.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2008-07-30 18:34:59 +0200
    message:
      Use boost tokenizer and strings instead of C stuff. 
    modified:
      libbase/extension.cpp
      libbase/extension.h
    ------------------------------------------------------------
    revno: 9545.1.4
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2008-07-30 19:02:39 +0200
    message:
      Fix illegal header guard.
    modified:
      libbase/rc.h
    ------------------------------------------------------------
    revno: 9545.1.5
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Wed 2008-07-30 19:02:56 +0200
    message:
      Try -ansi with windows again now that strdup is gone.
    modified:
      configure.ac
=== modified file 'configure.ac'
--- a/configure.ac      2008-07-29 22:26:53 +0000
+++ b/configure.ac      2008-07-30 17:02:56 +0000
@@ -1925,8 +1925,8 @@
     -Wnon-virtual-dtor \
     -Wunused \
     -Wextra \   
+    -ansi \
     "
-    #-ansi \
   CFLAGS="$CFLAGS \
     -W \
     -Wall \

=== modified file 'libbase/extension.cpp'
--- a/libbase/extension.cpp     2008-07-30 07:49:49 +0000
+++ b/libbase/extension.cpp     2008-07-30 16:34:59 +0000
@@ -112,7 +112,6 @@
 Extension::scanAndLoad(as_object& where)
 {
 //    GNASH_REPORT_FUNCTION;
-    std::string mod;
     
     if (_modules.empty()) {
         scanDir(_pluginsdir);
@@ -120,11 +119,11 @@
     
     std::vector<std::string>::iterator it;
     for (it = _modules.begin(); it != _modules.end(); it++) {
-        mod = *(it);
+        const std::string& mod = *it;
         log_security(_("Loading module: %s"), mod);
         initModule(mod, where);
-    }   
-               return true;
+    }
+    return true;
 }
 
 bool
@@ -161,7 +160,6 @@
 Extension::initModuleWithFunc(const std::string& module, const std::string& 
func,
        as_object &obj)
 {
-       SharedLib::initentry *symptr;
        SharedLib *sl;
 
        log_security(_("Initializing module: \"%s\""), module);
@@ -174,7 +172,7 @@
                sl = _plugins[module];
        }
 
-       symptr = sl->getInitEntry(func);
+       SharedLib::initentry *symptr = sl->getInitEntry(func);
 
        if (symptr) {
                symptr(obj);
@@ -190,7 +188,7 @@
 {
 //    GNASH_REPORT_FUNCTION;
     scanDir(_pluginsdir);
-       return true;
+    return true;
 }
 
 bool
@@ -198,68 +196,55 @@
 {
 //    GNASH_REPORT_FUNCTION;
     
-    int i;
-    struct dirent *entry;
-    //string::size_type pos;
-    char *dirlistcopy;
-    char *dir;
-    char *suffix = 0;
-
-//    scoped_lock lock(lib_mutex);
-
-    dirlistcopy = strdup(dirlist.c_str());
-    
-    dir = std::strtok(dirlistcopy, ":");
-    if (dir == NULL) {
-        dir = dirlistcopy;
-    }
-
-            
-    while (dir) {
+    Tok t(dirlist, Sep(":"));
+    for (Tok::iterator i = t.begin(), e = t.end(); i != e; ++i)
+    {
+        const std::string& dir = *i;
+
         log_debug(_("Scanning directory \"%s\" for plugins"), dir);
-        DIR *library_dir = opendir(dir);
+        DIR *libdir = opendir(dir.c_str());
 
-        if (library_dir == NULL) {
+        if (!libdir) {
             log_error(_("Can't open directory %s"), dir);
             return false;
-        }
+       }   
         
-        entry = readdir(library_dir);
-        for (i=0; entry>0; i++) {
-            // We only want shared libraries than end with the suffix, 
otherwise
+        struct dirent *entry = readdir(libdir);
+        for (int i = 0; entry > 0; ++i) {
+            // We only want shared libraries that end with the suffix, 
otherwise
             // we get all the duplicates.
-            entry = readdir(library_dir);
+            entry = readdir(libdir);
 
-            if (entry <= NULL) { // All done
+            if (entry <= 0) { // All done
                 continue;
             }
 
-            if (std::strncmp(entry->d_name, ".", 1) == 0) {
+           std::string name(entry->d_name);
+
+           // Hidden files.
+            if (name.at(0) == '.') {
                 continue;
             }            
             
-            suffix = std::strrchr(entry->d_name, '.');
-            if (suffix == 0) {
-                continue;
-            }
+           const std::string::size_type pos = name.find_last_of('.');
+           if (pos == std::string::npos) continue;
+           const std::string suffix = name.substr(pos);
+           name.erase(pos);
 
-            log_debug(_("Gnash Plugin name: %s"), entry->d_name);
-            
-            if (std::strcmp(suffix, ".so") == 0) {
-                *suffix = 0;
-                log_debug(_("Gnash Plugin name: %s"), entry->d_name);
-                _modules.push_back(entry->d_name);
-            } else {
+            if (suffix == ".so") {
+                log_debug(_("Gnash Plugin name: %s"), name);
+                _modules.push_back(name);
+            }
+           else {
                 continue;
             }
         }
         
-        if (closedir(library_dir) != 0) {
+        if (closedir(libdir) != 0) {
             return false;
         }
-        dir = std::strtok(NULL, ":");
     }
-       return true;
+    return true;
 }
 
 void

=== modified file 'libbase/extension.h'
--- a/libbase/extension.h       2008-07-30 07:49:49 +0000
+++ b/libbase/extension.h       2008-07-30 16:34:59 +0000
@@ -20,15 +20,20 @@
 
 #include <vector>
 #include <string>
+#include <boost/tokenizer.hpp>
 #include "sharedlib.h"
 #include "dsodefs.h"
 
+
 namespace gnash 
 {  
   
 class DSOEXPORT Extension
 {
-  public:
+    typedef boost::char_separator<char> Sep;
+    typedef boost::tokenizer< Sep > Tok;
+      
+public:
 
     Extension();
 

=== modified file 'libbase/rc.h'
--- a/libbase/rc.h      2008-04-27 08:12:36 +0000
+++ b/libbase/rc.h      2008-07-30 17:02:39 +0000
@@ -15,8 +15,8 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-#ifndef __RC_H__
-#define __RC_H__
+#ifndef GNASH_RC_H
+#define GNASH_RC_H
 
 // This is generated by autoconf
 #ifdef HAVE_CONFIG_H

=== modified file 'libbase/sharedlib.cpp'
--- a/libbase/sharedlib.cpp     2008-07-30 07:50:17 +0000
+++ b/libbase/sharedlib.cpp     2008-07-30 08:55:45 +0000
@@ -142,16 +142,6 @@
     return true;
 }
 
-const char *
-SharedLib::moduleName()
-{
-#ifdef WIN32
-       return NULL;    //TODO, hack
-#else
-       return basename(const_cast<char *>(_filespec.c_str()));
-#endif
-}
-
 SharedLib::initentry *
 SharedLib::getInitEntry (const std::string& symbol)
 {
@@ -197,27 +187,4 @@
     return (entrypoint*)(run);
 }
 
-// Get information about the DLL
-const char *
-SharedLib::getDllFileName ()
-{
-//    GNASH_REPORT_FUNCTION;
-
-    return  lt_dlgetinfo(_dlhandle)->filename;
-}
-
-const char *
-SharedLib::getDllModuleName ()
-{
-//    GNASH_REPORT_FUNCTION;
-    return  lt_dlgetinfo(_dlhandle)->name;
-}
-
-int
-SharedLib::getDllRefCount ()
-{
-//    GNASH_REPORT_FUNCTION;
-    return  lt_dlgetinfo(_dlhandle)->ref_count;
-}
-
 } // end of gnash namespace

=== modified file 'libbase/sharedlib.h'
--- a/libbase/sharedlib.h       2008-07-30 07:50:17 +0000
+++ b/libbase/sharedlib.h       2008-07-30 08:55:45 +0000
@@ -63,15 +63,6 @@
     // Get a C symbol from the shared library based on the name
     entrypoint *getDllSymbol (const std::string& symbol);
     initentry *getInitEntry (const std::string& symbol);
-
-    // Extract file info from the shared library
-    const char *getDllFileName();
-    const char *getDllModuleName();
-    int getDllRefCount();
-    const char *moduleName();
-
-    const std::string& getFilespec() { return _filespec; };
-    
     
 private:
 

=== modified file 'libcore/vm/ActionExec.cpp'
--- a/libcore/vm/ActionExec.cpp 2008-07-20 14:40:18 +0000
+++ b/libcore/vm/ActionExec.cpp 2008-07-30 08:36:48 +0000
@@ -52,7 +52,7 @@
 # define STACK_DUMP_LIMIT 32
 
 // Define to get debugging messages for try / catch
-#define GNASH_DEBUG_TRY 1
+//#define GNASH_DEBUG_TRY 1
 
 #endif
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]