[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash configure.ac Makefile.am ChangeLog libbas...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash configure.ac Makefile.am ChangeLog libbas... |
Date: |
Fri, 24 Nov 2006 04:45:05 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 06/11/24 04:45:05
Modified files:
. : configure.ac Makefile.am ChangeLog
libbase : Makefile.am sharedlib.cpp sharedlib.h
Added files:
libbase : extension.cpp extension.h
extensions/dejagnu: Makefile.am dejagnu.cpp dejagnu.h test.as
Log message:
* libbase/Makefile.am: Add new extension files. Pass a directory
based on $prefix as a constant for Gnash extensions.
* libbase/sharedlib.h: Add as_object typed entry point.
Optionally
pass in the search path for most methods. Find as_object typed
entry point differently than a generic symbol.
* libbase/sharedlib.cpp: Many changes, it basically works
now. Don't do in SharedLib class what should be done in the
Extension class. Initialize libltdl in the constructor, so it's
done before anything else. Support a path as a parameter, or use
GNASH_PLUGINS for a colon seperate path.
* libbase/extension.h, extension.cpp: New files for Gnash
extension plugins.
* extensions/Makefile.am: New file. Recurse into extension
directories.
* extensions/dejagnu/Makefile.am: Build DejaGnu extension for
Gnash.
* extensions/dejagnu/dejagnu.cpp, dejagnu.h: New files for
DejaGnu
extension. This is mostly just a template on creating custom
ActionScript extensions for Gnash.
* Makefile.am: Add extension directory, but don't build for now
from the top level.
* configure.ac: Configure extension directory.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&r1=1.195&r2=1.196
http://cvs.savannah.gnu.org/viewcvs/gnash/Makefile.am?cvsroot=gnash&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1732&r2=1.1733
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Makefile.am?cvsroot=gnash&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/sharedlib.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/sharedlib.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/extension.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/extension.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/dejagnu/Makefile.am?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/dejagnu/dejagnu.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/dejagnu/dejagnu.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/dejagnu/test.as?cvsroot=gnash&rev=1.1
Patches:
Index: configure.ac
===================================================================
RCS file: /sources/gnash/gnash/configure.ac,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -b -r1.195 -r1.196
--- configure.ac 23 Nov 2006 20:16:26 -0000 1.195
+++ configure.ac 24 Nov 2006 04:45:05 -0000 1.196
@@ -15,7 +15,7 @@
dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
dnl
-dnl $Id: configure.ac,v 1.195 2006/11/23 20:16:26 rsavoye Exp $
+dnl $Id: configure.ac,v 1.196 2006/11/24 04:45:05 rsavoye Exp $
AC_PREREQ(2.50)
AC_INIT(gnash, cvs)
@@ -26,6 +26,7 @@
AC_CANONICAL_TARGET
+dnl Some things you can only do by looking at the platform name.
case "${host}" in
powerpc-apple-darwin*)
AC_DEFINE([__powerpc64__], [], [this is a 64 bit powerpc])
@@ -785,12 +786,12 @@
testsuite/movies.all/Makefile
testsuite/server/Makefile
gui/Makefile
+extensions/Makefile
+extensions/dejagnu/Makefile
plugin/Makefile
plugin/klash/Makefile
)
dnl cygnal/Makefile
-dnl extensions/Makefile
-dnl extensions/dejagnu/Makefile
echo ""
echo "Configurable options are:"
Index: Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/Makefile.am,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- Makefile.am 23 Nov 2006 18:05:46 -0000 1.50
+++ Makefile.am 24 Nov 2006 04:45:05 -0000 1.51
@@ -15,7 +15,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
-# $Id: Makefile.am,v 1.50 2006/11/23 18:05:46 strk Exp $
+# $Id: Makefile.am,v 1.51 2006/11/24 04:45:05 rsavoye Exp $
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = 1.6.0
@@ -32,6 +32,7 @@
utilities \
gui \
testsuite
+# extensions
if PLUGIN
if HAVE_GTK2
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1732
retrieving revision 1.1733
diff -u -b -r1.1732 -r1.1733
--- ChangeLog 23 Nov 2006 20:16:26 -0000 1.1732
+++ ChangeLog 24 Nov 2006 04:45:05 -0000 1.1733
@@ -1,7 +1,29 @@
2006-11-23 Rob Savoye <address@hidden>
+ * libbase/Makefile.am: Add new extension files. Pass a directory
+ based on $prefix as a constant for Gnash extensions.
+ * libbase/sharedlib.h: Add as_object typed entry point. Optionally
+ pass in the search path for most methods. Find as_object typed
+ entry point differently than a generic symbol.
+ * libbase/sharedlib.cpp: Many changes, it basically works
+ now. Don't do in SharedLib class what should be done in the
+ Extension class. Initialize libltdl in the constructor, so it's
+ done before anything else. Support a path as a parameter, or use
+ GNASH_PLUGINS for a colon seperate path.
+ * libbase/extension.h, extension.cpp: New files for Gnash
+ extension plugins.
+ * extensions/Makefile.am: New file. Recurse into extension
+ directories.
+ * extensions/dejagnu/Makefile.am: Build DejaGnu extension for
+ Gnash.
+ * extensions/dejagnu/dejagnu.cpp, dejagnu.h: New files for DejaGnu
+ extension. This is mostly just a template on creating custom
+ ActionScript extensions for Gnash.
+ * Makefile.am: Add extension directory, but don't build for now
+ from the top level.
+
* configure.ac: Look for 64 bit OpenBSD systems, and set
- WORDSIZE.
+ WORDSIZE. Configure extension directory.
2006-11-23 Sandro Santilli <address@hidden>
Index: libbase/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libbase/Makefile.am,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- libbase/Makefile.am 10 Nov 2006 23:07:47 -0000 1.48
+++ libbase/Makefile.am 24 Nov 2006 04:45:05 -0000 1.49
@@ -14,13 +14,13 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#
-
AUTOMAKE_OPTIONS =
EXTRA_DIST =
+# this is where Gnash plugins get installed
+pluginsdir = $(prefix)/lib/gnash/plugins
+
INCLUDES = -I.. -I$(srcdir) \
-I$(top_srcdir) \
-I$(top_srcdir)/server \
@@ -54,10 +54,12 @@
EXTRA_DIST += tu_file_SDL.cpp
endif
+libgnashbase_la_CPPFLAGS = -DPLUGINSDIR=\"$(pluginsdir)\"
libgnashbase_la_SOURCES = \
config.cpp \
container.cpp \
$(DMALLOC_FILE) \
+ extension.cpp \
image.cpp \
image_filters.cpp \
jpeg.cpp \
@@ -97,6 +99,7 @@
container.h \
demo.h \
dlmalloc.h \
+ extension.h \
GnashException.h \
grid_index.h \
image.h \
Index: libbase/sharedlib.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/sharedlib.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libbase/sharedlib.cpp 22 Nov 2006 12:02:49 -0000 1.4
+++ libbase/sharedlib.cpp 24 Nov 2006 04:45:05 -0000 1.5
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: sharedlib.cpp,v 1.4 2006/11/22 12:02:49 bjacques Exp $ */
+/* $Id: sharedlib.cpp,v 1.5 2006/11/24 04:45:05 rsavoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -42,6 +42,8 @@
#include "log.h"
#include "sharedlib.h"
+using namespace std;
+
namespace {
gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
}
@@ -50,9 +52,8 @@
namespace gnash {
#ifdef LT_DLMUTEX
-
static void
-gnash_mutex_seterror (const char *err)
+gnash_mutex_seterror (void)
{
GNASH_REPORT_FUNCTION;
}
@@ -79,40 +80,78 @@
#endif
SharedLib::SharedLib()
+ : _filespec(0)
+{
+ GNASH_REPORT_FUNCTION;
+
+ char *plugindir;
+
+#ifdef LT_DLMUTEX
+// return lt_dlmutex_register (gnash_mutex_lock, gnash_mutex_unlock,
+// gnash_mutex_seterror, gnash_mutex_geterror);
+#endif
+}
+
+SharedLib::SharedLib(const char *filespec)
{
+ GNASH_REPORT_FUNCTION;
#ifdef LT_DLMUTEX
// return lt_dlmutex_register (gnash_mutex_lock, gnash_mutex_unlock,
// gnash_mutex_seterror, gnash_mutex_geterror);
#endif
+ _filespec = filespec;
+ scoped_lock lock(lib_mutex);
+
+ // Initialize libtool's dynamic library loader
+ int errors = lt_dlinit ();
+ if (errors) {
+ dbglogfile << "Couldn't initialize ltdl";
+ dbglogfile << lt_dlerror();
+ } else {
+ dbglogfile << "Initialized ltdl" << endl;
+ }
+ char *pluginsdir;
+ char *env = getenv ("GNASH_PLUGINS");
+ if (env == 0) {
+ pluginsdir = PLUGINSDIR;
+ } else {
+ pluginsdir = env;
+ }
+
+ lt_dlsetsearchpath(pluginsdir);
+}
+
+SharedLib::~SharedLib()
+{
+ GNASH_REPORT_FUNCTION;
+// closeLib();
+ lt_dlexit();
}
bool
-SharedLib::closeLib ()
+SharedLib::closeLib()
{
- return lt_dlclose (_dlhandle);
+ return lt_dlclose(_dlhandle);
+}
+
+bool
+SharedLib::openLib()
+{
+ return openLib(_filespec);
}
bool
SharedLib::openLib (string &filespec)
{
+ return openLib(filespec.c_str());
+}
+
+bool
+SharedLib::openLib (const char *filespec)
+{
GNASH_REPORT_FUNCTION;
int errors = 0;
- char pwd[PATH_MAX];
-
-#if 0
- struct stat ostats;
- if (stat (filespec.c_str(), &ostats)) {
- switch (errno) {
- case EBADF:
- case ENOENT:
- Err.SetMsg("Specified shared library doesn't exist");
- dbglogfile << "ERROR: Dynamic library, " << filespec << "
doesn't exist!" << endl;
- return false;
- break;
- }
- }
-#endif
#if 0
// ltdl should use the same mallocation as us
@@ -126,63 +165,60 @@
scoped_lock lock(lib_mutex);
- // Initialize libtool's dynamic library loader
- errors = lt_dlinit ();
+// // Initialize libtool's dynamic library loader
+// errors = lt_dlinit ();
- if (errors) {
- dbglogfile << "Couldn't initialize ltdl";
- return false;
- }
-
- dbglogfile << "Initialized ltdl" << endl;
-
- // Get the path to look for libraries in, or force a default one
- // if the GNASH_PLUGINS environment variable isn't set.
- const char *plugindir = (char *)getenv ("GNASH_PLUGINS");
- if (plugindir == NULL) {
- getcwd(pwd, PATH_MAX);
- plugindir = pwd;
- dbglogfile << "WARNING: using default DL search path" << endl;
- }
-
- errors = lt_dladdsearchdir (plugindir);
- if (errors) {
- dbglogfile << lt_dlerror();
- return false;
- }
-
- dbglogfile << "Added " << plugindir << " to the search paths" << endl;
+// if (errors) {
+// dbglogfile << "Couldn't initialize ltdl";
+// dbglogfile << lt_dlerror();
+// return false;
+// // } else {
+// // dbglogfile << "Initialized ltdl" << endl;
+// }
- dbglogfile << "Trying to open shared library " << filespec << endl;
+// cerr << "Searching in " << lt_dlgetsearchpath()
+// << "for database drivers" << endl;
- _dlhandle = lt_dlopenext (filespec.c_str());
+ dbglogfile << "Trying to open shared library \"" << filespec << "\"" <<
endl;
+ _dlhandle = lt_dlopenext (filespec);
if (_dlhandle == NULL) {
dbglogfile << lt_dlerror();
return false;
}
+ // Make this module unloadable
lt_dlmakeresident(_dlhandle);
- dbglogfile << "Opened dynamic library " << filespec << endl;
+ dbglogfile << "Opened dynamic library \"" << filespec << "\"" << endl;
+
+ _filespec = filespec;
+
return true;
}
+const char *
+SharedLib::moduleName()
+{
+ return basename(_filespec);
+}
+
SharedLib::entrypoint *
SharedLib::getDllSymbol (std::string &symbol)
{
- GNASH_REPORT_FUNCTION;
+ getDllSymbol(symbol.c_str());
+}
+SharedLib::initentry *
+SharedLib::getInitEntry (const char *symbol)
+{
+ GNASH_REPORT_FUNCTION;
lt_ptr run = NULL;
scoped_lock lock(lib_mutex);
- run = lt_dlsym (_dlhandle, symbol.c_str());
+ run = lt_dlsym (_dlhandle, symbol);
- /*
- Realistically, we should never get a valid pointer with a value of 0
- Markus: 'Id est NULL.'
- */
if (run == NULL) {
dbglogfile << "Couldn't find symbol: " << symbol << endl;
return NULL;
@@ -190,79 +226,36 @@
dbglogfile << "Found symbol " << symbol << " @ " << (void *)run <<
endl;
}
- return (entrypoint *)run;
+ return (initentry *)run;
}
-#if 0
-// Open the database
-bool
-SharedLib::ScanDir (void) {
+SharedLib::entrypoint *
+SharedLib::getDllSymbol(const char *symbol)
+{
GNASH_REPORT_FUNCTION;
- int i;
- struct device_info *info;
- struct dirent *entry;
- lt_dlhandle dlhandle;
- bool (*InitDBaddr)(void);
- lt_ptr_t addr;
- struct errcond err;
+ lt_ptr run = NULL;
scoped_lock lock(lib_mutex);
- // Initialize libdl
- lt_dlinit ();
- LTDL_SET_PRELOADED_SYMBOLS();
-
- // Get the path to look for libraries in, or force a default one
- // if the GNASH_PLUGINS environment variable isn't set.
- const char *plugindir = (char *)getenv ("GNASH_PLUGINS");
- if (plugindir == NULL) {
- plugindir = "/usr/local/lib/gnash";
- dbglogfile << "ERROR: You need to set GNASH_PLUGINS" << endl;
- }
-
- lt_dladdsearchdir (plugindir);
- // dbglogfile << timestamp << "Searching in " << gnash << "for database
drivers" << endl;
-
- DIR *library_dir = opendir (plugindir);
+ run = lt_dlsym (_dlhandle, symbol);
- // By convention, the first two entries in each directory are for . and
- // .. (``dot'' and ``dot dot''), so we ignore those.
- entry = readdir(library_dir);
- entry = readdir(library_dir);
-
- for (i=0; entry>0; i++) {
- // We only want shared libraries than end with the suffix, otherwise
- // we get all the duplicates.
- entry = readdir(library_dir);
- if ((int)entry < 1)
- return SUCCESS;
-
- // handle = dlopen (entry->d_name, RTLD_NOW|RTLD_GLOBAL);
- _dlhandle = lt_dlopen (entry->d_name);
- if (_dlhandle == NULL) {
- continue;
- }
- cout << "Opening " << entry->d_name << endl;
- // InitDBaddr = (bool (*)(...))dlsym (handle, "InitDB");
- (lt_ptr_t) InitDBaddr = lt_dlsym (_dlhandle, "InitDB");
- if (InitDBaddr != NULL) {
- // dbglogfile << "Found OpenDB in " << entry->d_name << endl;
- cout << "Found InitDB in " << entry->d_name << " at " << addr <<
endl;
- InitDBaddr();
+ /*
+ Realistically, we should never get a valid pointer with a value of 0
+ Markus: 'Id est NULL.'
+ */
+ if (run == NULL) {
+ dbglogfile << "Couldn't find symbol: " << symbol << endl;
+ return NULL;
} else {
- // dbglogfile << "Didn't find OpenDB in " << entry->d_name <<
endl;
- cout << "Didn't find InitDB in " << entry->d_name << endl;
- }
- lt_dlclose (_dlhandle);
+ dbglogfile << "Found symbol " << symbol << " @ " << (void *)run <<
endl;
}
- closedir(library_dir);
+ return (entrypoint *)run;
}
-#endif
// Get information about the DLL
-char *
+const char *
SharedLib::getDllFileName ()
{
GNASH_REPORT_FUNCTION;
@@ -270,7 +263,7 @@
return lt_dlgetinfo(_dlhandle)->filename;
}
-char *
+const char *
SharedLib::getDllModuleName ()
{
GNASH_REPORT_FUNCTION;
Index: libbase/sharedlib.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/sharedlib.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libbase/sharedlib.h 23 Nov 2006 16:40:10 -0000 1.2
+++ libbase/sharedlib.h 24 Nov 2006 04:45:05 -0000 1.3
@@ -24,37 +24,46 @@
#include <string>
#include <map>
#include <ltdl.h>
+#include "as_object.h"
namespace gnash
{
-typedef struct {
- char *name;
- void *funcptr;
-} entry_t;
-
/// TODO: document this class
class SharedLib
{
public:
// Typedefs for function pointers to keep the code readable
- typedef bool entrypoint (void *arg);
+ typedef bool entrypoint (void *obj);
+ typedef void initentry (as_object *obj);
SharedLib();
+ SharedLib(const char *filespec);
~SharedLib();
- bool openLib (std::string &name);
- bool closeLib ();
+ bool openLib();
+ bool openLib(std::string &filespec);
+ bool openLib(const char *filespec);
+ bool closeLib();
// Get a C symbol from the shared library based on the name
entrypoint *getDllSymbol (std::string &name);
+ entrypoint *getDllSymbol (const char *name);
+ initentry *getInitEntry (const char *name);
// Extract file info from the shared library
- char *getDllFileName();
- char *getDllModuleName();
+ const char *getDllFileName();
+ const char *getDllModuleName();
int getDllRefCount();
+ const char *moduleName();
+// lt_dlhandle getDllHandle { return _dlhandle; }
+ const char *getFilespec() { return _filespec; };
+
+
private:
lt_dlhandle _dlhandle;
+ const char *_filespec;
+ const char *_pluginsdir;
};
} // end of gnash namespace
Index: libbase/extension.cpp
===================================================================
RCS file: libbase/extension.cpp
diff -N libbase/extension.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libbase/extension.cpp 24 Nov 2006 04:45:05 -0000 1.1
@@ -0,0 +1,240 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+/* $Id: extension.cpp,v 1.1 2006/11/24 04:45:05 rsavoye Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if defined(_WIN32) || defined(WIN32)
+# define lock(lib_mutex);
+# define scoped_lock;
+#else
+# include <boost/detail/lightweight_mutex.hpp>
+ using boost::detail::lightweight_mutex;
+# define scoped_lock lightweight_mutex::scoped_lock
+ static lightweight_mutex lib_mutex;
+#endif
+
+#include <ltdl.h>
+#include <string.h>
+#include <iostream>
+#include <sys/types.h>
+#include "log.h"
+#include "sharedlib.h"
+#include "extension.h"
+#include "as_object.h"
+
+#if HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# if HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif
+
+using namespace std;
+namespace gnash {
+
+LogFile& dbglogfile = LogFile::getDefaultInstance();
+
+Extension::Extension()
+{
+ GNASH_REPORT_FUNCTION;
+#ifdef LT_DLMUTEX
+// return lt_dlmutex_register (gnash_mutex_lock, gnash_mutex_unlock,
+// gnash_mutex_seterror, gnash_mutex_geterror);
+#endif
+ char *env = getenv ("GNASH_PLUGINS");
+ if (env == 0) {
+ _pluginsdir = PLUGINSDIR;
+ } else {
+ _pluginsdir = env;
+ }
+
+ lt_dlsetsearchpath(_pluginsdir);
+}
+
+Extension::Extension(const char *dir)
+{
+ GNASH_REPORT_FUNCTION;
+#ifdef LT_DLMUTEX
+// return lt_dlmutex_register (gnash_mutex_lock, gnash_mutex_unlock,
+// gnash_mutex_seterror, gnash_mutex_geterror);
+#endif
+ _pluginsdir = dir;
+ lt_dlsetsearchpath(_pluginsdir);
+}
+
+Extension::~Extension()
+{
+ GNASH_REPORT_FUNCTION;
+}
+
+bool
+Extension::scanAndLoad(const char *dir, as_object *obj)
+{
+ GNASH_REPORT_FUNCTION;
+
+ lt_dlsetsearchpath(_pluginsdir);
+ _pluginsdir = dir;
+
+ return scanAndLoad(obj);
+}
+
+bool
+Extension::scanAndLoad(as_object *obj)
+{
+ GNASH_REPORT_FUNCTION;
+// const char *mod;
+ string mod;
+
+ if (_modules.size() == 0) {
+ scanDir(_pluginsdir);
+ }
+
+ vector<string>::iterator it;
+ for (it = _modules.begin(); it != _modules.end(); it++) {
+ mod = *(it);
+ dbglogfile << "Loading module: " << mod.c_str() << endl;
+ SharedLib sl;
+ initModule(mod.c_str(), obj);
+ }
+}
+
+bool
+Extension::initModule(const char *module, as_object *obj)
+{
+ GNASH_REPORT_FUNCTION;
+
+ SharedLib::initentry *symptr;
+ SharedLib *sl;
+ string symbol;
+
+ dbglogfile << "Initializing module: \"" << module << "\"" << endl;
+
+ symbol = module;
+ if (_plugins[module] == 0) {
+ sl = new SharedLib(module);
+ sl->openLib();
+ _plugins[module] = sl;
+ } else {
+ sl = _plugins[module];
+ }
+
+ symbol += "_class_init";
+ symptr = sl->getInitEntry(symbol.c_str());
+
+ if (symptr) {
+ symptr(obj);
+ } else {
+ log_warning("Couldn't get class_init symbol!");
+ }
+
+ return true;
+}
+
+bool
+Extension::scanDir()
+{
+ GNASH_REPORT_FUNCTION;
+ scanDir(_pluginsdir);
+}
+
+bool
+Extension::scanDir(const char *dirlist)
+{
+ GNASH_REPORT_FUNCTION;
+
+ int i;
+ struct dirent *entry;
+ string mod;
+ string::size_type pos;
+ char *dirlistcopy;
+ char *dir;
+
+// scoped_lock lock(lib_mutex);
+
+ dirlistcopy = strdup(dirlist);
+
+ dir = strtok(dirlistcopy, ":");
+ if (dir == NULL) {
+ dir = dirlistcopy;
+ }
+
+ while (dir) {
+ dbglogfile << "Scanning directory \"" << dir << "\" for plugins." <<
endl;
+ DIR *library_dir = opendir(dir);
+
+ // By convention, the first two entries in each directory are for . and
+ // .. (``dot'' and ``dot dot''), so we ignore those.
+ entry = readdir(library_dir);
+ entry = readdir(library_dir);
+
+ for (i=0; entry>0; i++) {
+ // We only want shared libraries than end with the suffix,
otherwise
+ // we get all the duplicates.
+ entry = readdir(library_dir);
+ if ((int)entry < 1) {
+ break;
+ }
+
+ if (strstr(entry->d_name, ".la") == 0) {
+ continue;
+ }
+
+ dbglogfile << "Gnash Plugin name: " << entry->d_name << endl;
+ mod = entry->d_name;
+ pos = mod.rfind(".", mod.size());
+ if (pos != string::npos) {
+ mod.erase(pos, mod.size());
+ } else {
+ log_warning("Couldn't remove plugin suffix!");
+ }
+// cerr << "Module name is: " << mod << endl;
+ _modules.push_back(mod);
+
+ }
+ if (closedir(library_dir) != 0) {
+ return false;
+ }
+ dir = strtok(NULL, ":");
+ }
+}
+
+void
+Extension::dumpModules()
+{
+ GNASH_REPORT_FUNCTION;
+
+ cerr << _modules.size() << " plugin(s) for Gnash installed" << endl;
+ vector<string>::iterator it;
+ for (it = _modules.begin(); it != _modules.end(); it++) {
+ cerr << "Module name is: \"" << *(it) << "\"" << endl;
+ }
+}
+
+} // end of gnash namespace
Index: libbase/extension.h
===================================================================
RCS file: libbase/extension.h
diff -N libbase/extension.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libbase/extension.h 24 Nov 2006 04:45:05 -0000 1.1
@@ -0,0 +1,63 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifndef __EXTENSION_H__
+#define __EXTENSION_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <vector>
+#include <string>
+#include "sharedlib.h"
+
+namespace gnash
+{
+
+class Extension
+{
+ public:
+// typedef bool init_func_t (as_object &obj);
+ Extension();
+ Extension(const char *dir);
+ ~Extension();
+ // scan a directory for Gnash modules
+ bool scanDir();
+ bool scanDir(const char *dir);
+ // scan the directory and open the module
+ bool scanAndLoad(as_object *obj);
+ bool scanAndLoad(const char *dir, as_object *obj);
+ // open a module
+ // initialize the module within Gnash
+ bool initModule(const char *module, as_object *obj);
+ bool initNewObject(as_object *obj);
+ void dumpModules();
+private:
+ std::vector<std::string> _modules;
+ std::map<const char *, SharedLib *> _plugins;
+ const char *_pluginsdir;
+};
+
+} // end of gnash namespace
+
+// __EXTENSION_H__
+#endif
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
Index: extensions/dejagnu/Makefile.am
===================================================================
RCS file: extensions/dejagnu/Makefile.am
diff -N extensions/dejagnu/Makefile.am
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ extensions/dejagnu/Makefile.am 24 Nov 2006 04:45:05 -0000 1.1
@@ -0,0 +1,55 @@
+## Process this file with automake to generate Makefile.in
+#
+# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+AUTOMAKE_OPTIONS =
+
+# this is where Gnash plugins get installed
+pluginsdir = $(prefix)/lib/gnash/plugins
+
+# __USLC__ makes MySQL++ use the std namespace
+AM_CXXFLAGS = -g -D__USLC__
+
+plugins_LTLIBRARIES = dejagnu.la
+
+INCLUDES = -I$(srcdir) \
+ -I$(top_srcdir)/libbase \
+ -I$(top_srcdir)/server \
+ -I$(top_srcdir)/asobjs \
+ $(INCLTDL)
+
+AM_LDFLAGS = \
+ $(top_builddir)/backend/libgnashbackend.la \
+ $(LIBADD_DL) \
+ $(LIBLTDL) \
+ $(PTHREAD_LIBS) \
+ $(NULL)
+
+dejagnu_la_SOURCES = dejagnu.cpp dejagnu.h
+dejagnu_la_LDFLAGS = -module -avoid-version # -no-undefined
+dejagnu_la_LIBDADD = $(LIBADD_DL) $(LIBLTDL) $(AM_LDFLAGS)
+
+check_PROGRAMS = SharedTest
+CLEANFILES = \
+ gnash-dbg.log
+
+SharedTest_SOURCES = SharedTest.cpp
+SharedTest_CPPFLAGS = '-DINPUT="$(srcdir)/SharedTest.cpp"'
+SharedTest_LDFLAGS = -export-dynamic
+
+install-pluginsLTLIBRARIES: $(plugins_LTLIBRARIES)
+ test -d "$(DESTDIR)$(pluginsdir)" || $(mkinstalldirs)
"$(DESTDIR)$(pluginsdir)"
+ $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG)
$(plugins_LTLIBRARIES) "$(DESTDIR)$(pluginsdir)/$(plugins_LTLIBRARIES)"
Index: extensions/dejagnu/dejagnu.cpp
===================================================================
RCS file: extensions/dejagnu/dejagnu.cpp
diff -N extensions/dejagnu/dejagnu.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ extensions/dejagnu/dejagnu.cpp 24 Nov 2006 04:45:05 -0000 1.1
@@ -0,0 +1,172 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <map>
+#include <iostream>
+#include <string>
+#include "log.h"
+#include "dejagnu.h"
+#include "sharedlib.h"
+#include "extension.h"
+#include "fn_call.h"
+#include "as_object.h"
+#include "builtin_function.h" // need builtin_function
+
+using namespace std;
+
+namespace gnash
+{
+
+void dejagnu_pass(const fn_call& fn);
+void dejagnu_fail(const fn_call& fn);
+void dejagnu_totals(const fn_call& fn);
+
+LogFile& dbglogfile = LogFile::getDefaultInstance();
+
+class dejagnu_as_object : public as_object
+{
+public:
+ DejaGnu obj;
+};
+
+static void
+attachDejaGnuInterface(as_object *obj)
+{
+ GNASH_REPORT_FUNCTION;
+
+ obj->set_member("pass", dejagnu_pass);
+ obj->set_member("fail", dejagnu_fail);
+ obj->set_member("totals", dejagnu_totals);
+}
+
+static as_object*
+getDejaGnuInterface()
+{
+ GNASH_REPORT_FUNCTION;
+ static boost::intrusive_ptr<as_object> o=NULL;
+ if (o == NULL) {
+ o = new as_object();
+ attachDejaGnuInterface(o.get());
+ }
+ return o.get();
+}
+
+static void
+dejagnu_ctor(const fn_call& fn)
+{
+ GNASH_REPORT_FUNCTION;
+ dejagnu_as_object* obj = new dejagnu_as_object();
+
+ fn.result->set_as_object(obj); // will keep alive
+}
+
+
+DejaGnu::DejaGnu()
+ : passed(0), failed(0), xpassed(0), xfailed(0)
+{
+ GNASH_REPORT_FUNCTION;
+}
+
+DejaGnu::~DejaGnu()
+{
+ GNASH_REPORT_FUNCTION;
+}
+
+const char *
+DejaGnu::pass (const char *msg)
+{
+ GNASH_REPORT_FUNCTION;
+
+ passed++;
+ dbglogfile << "PASSED: " << msg << endl;
+}
+
+const char *
+DejaGnu::fail (const char *msg)
+{
+ GNASH_REPORT_FUNCTION;
+
+ failed++;
+ dbglogfile << "FAILED: " << msg << endl;
+}
+
+void
+dejagnu_pass(const fn_call& fn)
+{
+ GNASH_REPORT_FUNCTION;
+ dejagnu_as_object *ptr = (dejagnu_as_object*)fn.this_ptr;
+ assert(ptr);
+
+ if (fn.nargs > 0) {
+ const char *text =
fn.env->bottom(fn.first_arg_bottom_index).to_string();
+ fn.result->set_string(ptr->obj.pass(text));
+ }
+}
+
+void
+dejagnu_fail(const fn_call& fn)
+{
+ GNASH_REPORT_FUNCTION;
+ dejagnu_as_object *ptr = (dejagnu_as_object*)fn.this_ptr;
+ assert(ptr);
+
+ if (fn.nargs > 0) {
+ const char *text =
fn.env->bottom(fn.first_arg_bottom_index).to_string();
+ fn.result->set_string(ptr->obj.fail(text));
+ }
+}
+
+void
+dejagnu_totals(const fn_call& fn)
+{
+ GNASH_REPORT_FUNCTION;
+ dejagnu_as_object *ptr = (dejagnu_as_object*)fn.this_ptr;
+ assert(ptr);
+
+ ptr->obj.totals();
+ fn.result->set_bool(true);
+}
+
+extern "C" {
+ void
+ dejagnu_class_init(as_object *obj)
+ {
+ GNASH_REPORT_FUNCTION;
+ // This is going to be the global "class"/"function"
+ static boost::intrusive_ptr<builtin_function> cl=NULL;
+ if (cl == NULL) {
+ cl = new builtin_function(&dejagnu_ctor, getDejaGnuInterface());
+ // replicate all interface to class, to be able to access
+ // all methods as static functions
+ attachDejaGnuInterface(cl.get());
+ }
+
+ printf ("Hello World from %s !!!\n", __PRETTY_FUNCTION__);
+ obj->set_member("DejaGnu", cl.get());
+ }
+} // end of extern C
+
+
+} // end of gnash namespace
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
Index: extensions/dejagnu/dejagnu.h
===================================================================
RCS file: extensions/dejagnu/dejagnu.h
diff -N extensions/dejagnu/dejagnu.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ extensions/dejagnu/dejagnu.h 24 Nov 2006 04:45:05 -0000 1.1
@@ -0,0 +1,66 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifndef __DEJAGNU_PLUGIN_H__
+#define __DEJAGNU_PLUGIN_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <memory> // for auto_ptr
+#include "as_object.h"
+#include "sharedlib.h"
+#include "extension.h"
+
+namespace gnash
+{
+
+class as_object;
+
+class DejaGnu {
+public:
+ DejaGnu();
+ ~DejaGnu();
+ const char *pass (const char *msg);
+ const char *fail (const char *msg);
+ const char *xpass (const char *msg);
+ const char *xfail (const char *msg);
+ void totals ();
+private:
+ int passed;
+ int failed;
+ int xpassed;
+ int xfailed;
+};
+
+extern "C" {
+ void dejagnu_class_init(as_object *obj);
+}
+
+/// Return an instance
+std::auto_ptr<as_object> init_dejagnu_instance();
+
+
+} // end of gnash namespace
+
+// __DEJAGNU_PLUGIN_H__
+#endif
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
Index: extensions/dejagnu/test.as
===================================================================
RCS file: extensions/dejagnu/test.as
diff -N extensions/dejagnu/test.as
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ extensions/dejagnu/test.as 24 Nov 2006 04:45:05 -0000 1.1
@@ -0,0 +1,47 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+//
+
+// Test case for XML ActionScript class
+// compile this test case with Ming makeswf, and then
+// execute it like this gnash -1 -r 0 -v out.swf
+
+rcsid="$Id: test.as,v 1.1 2006/11/24 04:45:05 rsavoye Exp $";
+
+var tmp = new DejaGnu();
+
+// test the XML constuctor
+if (tmp) {
+ pass("DejaGnu() constructor");
+} else {
+ fail("DejaGnu() constructor");
+}
+
+if (tmp.pass) {
+ trace("DejaGnu::pass exists");
+} else {
+ trace("DejaGnu::pass doesn't exist");
+}
+
+if (tmp.fail) {
+ trace("DejaGnu::fail exists");
+} else {
+ trace("DejaGnu::fail doesn't exist");
+}
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash configure.ac Makefile.am ChangeLog libbas...,
Rob Savoye <=