[v8-juice] r2244 committed - Initial port of v8::juice::PathFinder to cvv8. Includes a core convers...

1 view
Skip to first unread message

v8-j...@googlecode.com

unread,
Apr 12, 2012, 2:24:35 PM4/12/12
to v8-juice-...@googlegroups.com
Revision: 2244
Author: sgbeal
Date: Thu Apr 12 11:24:20 2012
Log: Initial port of v8::juice::PathFinder to cvv8. Includes a core
conversion fix. First add-on generated mostly by createCCWrapper.sh :).
http://code.google.com/p/v8-juice/source/detail?r=2244

Added:
/convert/addons/pathfinder
/convert/addons/pathfinder/Makefile
/convert/addons/pathfinder/PathFinder.cpp
/convert/addons/pathfinder/PathFinder.hpp
/convert/addons/pathfinder/cvv8-PathFinder.cpp
/convert/addons/pathfinder/cvv8-PathFinder.hpp
/convert/addons/pathfinder/test.js
Modified:
/convert/addons/Makefile
/convert/addons/createCCWrapper.sh
/convert/examples/Makefile
/convert/include/cvv8/arguments.hpp
/convert/include/cvv8/detail/convert_core.hpp

=======================================
--- /dev/null
+++ /convert/addons/pathfinder/Makefile Thu Apr 12 11:24:20 2012
@@ -0,0 +1,48 @@
+#!/usr/bin/make -f
+########################################################################
+# Main makefile for v8::convert PathFinder add-on.
+#
+# Requires GNU Make 3.81+
+#
+# This file is pre-configured for compling directly from the
+# v8::convert source tree in my own personal dev environments. See the
+# comments in the various sections below for what might need to be
+# tweaked (not too much, at least for Linux boxes).
+#
+# Requirements:
+#
+# - Google v8 headers + libs.
+#
+# - v8::convert: http://code.google.com/p/v8-juice/wiki/V8Convert
+# (it's a header-only library, so required to special installation)
+#
+########################################################################
+include ../../config.make # see that file for certain configuration
options.
+
+########################################################################
+# If needed, append the CPPFLAGS to point to where <v8/convert/*.hpp> can
+# be found.
+
+ENABLE_ZLIB ?= 1
+ifeq (,$(ENABLE_ZLIB))
+ ENABLE_ZLIB := 0
+endif
+libv8PathFinder.LIB.OBJECTS := PathFinder.o cvv8-PathFinder.o
+libv8PathFinder.DLL.OBJECTS := $(libv8PathFinder.LIB.OBJECTS)
+libv8PathFinder.DLL: $(libv8PathFinder.LIB.OBJECTS)
+ifeq (1,$(ENABLE_ZLIB))
+ libv8PathFinder.DLL.LDFLAGS += -lz
+endif
+$(eval $(call ShakeNMake.CALL.RULES.LIBS,libv8PathFinder))
+all: $(libv8PathFinder.LIB)
+$(eval $(call ShakeNMake.CALL.RULES.DLLS,libv8PathFinder))
+all: $(libv8PathFinder.DLL)
+
+
+
+########################################################################
+# shell app...
+SHELL_LDFLAGS := $(LDFLAGS_V8) -L. -lv8PathFinder
+SHELL_BINDINGS_HEADER := cvv8-PathFinder.hpp
+SHELL_BINDINGS_FUNC := cvv8::SetupPathFinderBindings
+include ../shell-common.make
=======================================
--- /dev/null
+++ /convert/addons/pathfinder/PathFinder.cpp Thu Apr 12 11:24:20 2012
@@ -0,0 +1,253 @@
+// Author: stephan beal <ste...@s11n.net>
+// License: Public Domain
+
+#include <iostream>
+
+#include "PathFinder.hpp"
+
+#ifndef WIN32
+# define WIN32 0
+#endif
+
+#if WIN32
+# include <io.h>
+# include <stdio.h>
+#else
+# include <unistd.h>
+#endif
+
+namespace cvv8 {
+
+
+ PathFinder::~PathFinder()
+ {
+ // DTOROUT(PathFinder) << this->PathString() << std::endl;
+ }
+
+ PathFinder::PathFinder( const std::string & p, const std::string & e,
const std::string & pathsep )
+ {
+ this->PathSeparator( pathsep );
+ this->Path( p );
+ this->Extensions( e );
+ }
+
+
+ bool PathFinder::IsEmpty() const
+ {
+ return this->paths.empty() && this->exts.empty();
+ }
+
+ std::string PathFinder::PathSeparator() const
+ {
+ return this->pathseparator;
+ }
+
+ void PathFinder::PathSeparator( const std::string & sep )
+ {
+ this->pathseparator = sep.empty() ? ":" : sep;
+ }
+
+ std::string PathFinder::JoinList( const StringList & list, const
std::string & separator )
+ {
+ std::string ret;
+ unsigned long count = list.size();
+ unsigned long at = 0;
+ StringList::const_iterator it = list.begin();
+ StringList::const_iterator et = list.end();
+ for(; it != et; ++it )
+ {
+
+ ret += (*it);
+ if( ++at != count ) ret += separator;
+ }
+ return ret;
+ }
+ std::string PathFinder::PathString() const
+ {
+ return this->JoinList( this->paths, this->pathseparator );
+ }
+
+ PathFinder::StringList PathFinder::Path() const
+ {
+ return this->paths;
+ }
+
+ PathFinder::StringList & PathFinder::Path()
+ {
+ return this->paths;
+ }
+
+ std::string PathFinder::ExtensionsString() const
+ {
+ return this->JoinList( this->exts, this->pathseparator );
+ }
+
+ PathFinder::StringList PathFinder::Extensions() const
+ {
+ return this->exts;
+ }
+
+ PathFinder::StringList & PathFinder::Extensions()
+ {
+ return this->exts;
+ }
+
+
+ std::size_t tokenize_to_list( const std::string & str,
std::list<std::string> & li, const std::string & sep )
+ { // internal helper function
+ if( str.empty() ) return 0;
+
+ std::size_t c = 0;
+
+ std::string token;
+ std::string::size_type sz = str.size();
+ for( std::string::size_type i = 0; i < sz; i++ )
+ {
+ if( sz-1 == i ) token += str[i];
+ if( str.find( sep, i ) == i || (sz-1 == i) )
+ {
+ //CERR << "token="<<token<<std::endl;
+ li.push_back( token );
+ token = "";
+ i += sep.size() - 1;
+ continue;
+ }
+ token += str[i];
+ }
+ return c;
+ }
+
+ std::size_t PathFinder::Path( const std::string & p )
+ {
+ this->paths.erase( this->paths.begin(), this->paths.end() );
+ return tokenize_to_list( p, this->paths, this->pathseparator );
+ }
+
+ std::size_t PathFinder::Path( const PathFinder::StringList & p )
+ {
+ this->paths = p;
+ return this->paths.size();
+ }
+
+ void PathFinder::AddPath( const std::string & p )
+ {
+ tokenize_to_list( p, this->paths, this->pathseparator );
+ }
+
+
+ std::size_t PathFinder::Extensions( const std::string & p )
+ {
+ this->exts.erase( this->exts.begin(), this->exts.end() );
+ return tokenize_to_list( p, this->exts, this->pathseparator );
+ }
+
+ std::size_t PathFinder::Extensions( const PathFinder::StringList & e )
+ {
+ this->exts = e;
+ return this->exts.size();
+ }
+
+ void PathFinder::AddExtension( const std::string & p )
+ {
+ tokenize_to_list( p, this->exts, this->pathseparator );
+ }
+
+ // static
+ bool PathFinder::IsAccessible( const std::string & path )
+ {
+#if WIN32
+# define CHECKACCESS _access
+# define CHECKRIGHTS 0
+#else
+# define CHECKACCESS access
+# define CHECKRIGHTS F_OK
+#endif
+
+ return 0 == CHECKACCESS( path.c_str(), CHECKRIGHTS );
+#undef CHECKACCESS
+#undef CHECKRIGHTS
+ }
+
+ std::string PathFinder::BaseName( const std::string & name )
+ {
+ std::string::size_type slashat = name.find_last_of(
PathFinder::DirSeparator() );
+ if ( slashat == std::string::npos )
+ return name;
+ return name.substr( slashat + 1 );
+ }
+
+
+ std::string PathFinder::DirSeparator()
+ {
+#if WIN32
+ return std::string( "\\" );
+#else
+ return std::string( "/" );
+#endif
+ }
+
+
+ std::string PathFinder::Find( const std::string & resource, bool
check_cache ) const
+ {
+ //static const std::string NOT_FOUND = "PathFinder::Find() : no findie";
+ if( resource.empty() ) return resource;
+
+#define CHECKPATH(CHECKAT) \
+ if( ! CHECKAT.empty() && PathFinder::IsAccessible( CHECKAT ) ) \
+ { this->hitcache[resource] = CHECKAT; return CHECKAT; }
+
+ //CERR << "Find( " << resource << " )" << std::endl;
+ if( check_cache )
+ {
+ std::map <std::string,std::string>::iterator mapiter;
+ mapiter = this->hitcache.find( resource );
+ if( this->hitcache.end() != mapiter ) return (*mapiter).second;
+ }
+
+ CHECKPATH( resource );
+
+ StringList::const_iterator piter = this->paths.begin();
+ StringList::const_iterator eiter = this->exts.begin();
+
+ std::string path;
+ std::string ext;
+
+ if ( PathFinder::IsAccessible( resource ) )
+ return resource;
+
+ piter = this->paths.begin();
+ std::string checkhere;
+ while ( piter != this->paths.end() )
+ {
+ path = ( *piter );
+ if ( !path.empty() )
+ {
+ path += PathFinder::DirSeparator();
+ }
+ ++piter;
+ checkhere = path + resource;
+ //CERR << "Find( " << resource << " ) checking " << checkhere <<
std::endl;
+ CHECKPATH( checkhere );
+ eiter = this->exts.begin();
+ while ( eiter != this->exts.end() )
+ {
+ ext = ( *eiter );
+ ++eiter;
+ checkhere = path + resource + ext;
+ //CERR << "Find( " << resource << " ) checking " << checkhere <<
std::endl;
+ CHECKPATH( checkhere );
+ }
+ }
+ //CERR << "Find( "<<resource<<" ): not found :(" << std::endl;
+ // so arguable:
+ // this->hitcache[resource] = "";
+ return std::string();
+ }
+#undef CHECKPATH
+ void PathFinder::ClearCache()
+ {
+ this->hitcache.clear();
+ }
+
+} // namespaces
+
=======================================
--- /dev/null
+++ /convert/addons/pathfinder/PathFinder.hpp Thu Apr 12 11:24:20 2012
@@ -0,0 +1,249 @@
+#ifndef V8_JUICE_PATHFINDER_H_INCLUDED
+#define V8_JUICE_PATHFINDER_H_INCLUDED
+// Author: stephan beal <ste...@s11n.net>
+// License: Public Domain
+
+#include <string>
+#include <list>
+#include <map>
+#include <v8.h>
+namespace cvv8 {
+
+ /**
+ PathFinder searches for files using a set of prefixes
+ (paths) and suffixes (file extensions).
+
+ Example:
+
+ <pre>
+ PathFinder p;
+ p.Path( "/lib:/usr/lib" );
+ p.Extensions( ".a:.so" );
+ std::cout << p.Find( "libz" ) << std::endl;
+ </pre>
+
+ That would print an empty string if it finds nothing, or a
+ string if it finds any of the following:
+
+ - libz (that is, if the value passed is an existing file,
+ it is returned as-is).
+ - /lib/libz
+ - /lib/libz.a
+ - /lib/libz.so
+ - /usr/lib/libz
+ - /usr/lib/libz.a
+ - /usr/lib/libz.so
+
+
+ Maintainer's note:
+
+ This code was one of my very first STL-based classes, and the
+ implementation probably shows that very clearly. That said, it
+ has worked well for me for many years now without any
+ appeciable maintenance. :)
+ */
+ class PathFinder
+ {
+ public:
+
+ /**
+ A list type returned by some functions.
+
+ TODO: consider using a std::set instead of a std::list.
+ */
+ typedef std::list<std::string> StringList;
+
+ /**
+ Creates object with the given path/extension/separator list.
+ */
+ explicit PathFinder( const std::string & path = std::string(), const
std::string & ext = std::string(), const std::string & pathsep = ":" );
+
+ virtual ~PathFinder();
+
+ /**
+ Returns a PathSeparator()-separated string of all paths
+ added via add/Path().
+ */
+ std::string PathString() const;
+
+ /**
+ Sets the string used as a separator for the
+ string-based variants of Path(), extentions(), etc.
+ If sep.empty() then a default of ":" is set instead
+ (we cannot tokenize paths based on an empty separator).
+ */
+ void PathSeparator( const std::string & sep );
+
+ /**
+ Returns the path separator string. Default is ":";
+ */
+ std::string PathSeparator() const;
+
+ /**
+ Sets the path to p, which should be a PathSeparator()-delimited string.
+ Returns the number of path elements parsed from p.
+ */
+ virtual std::size_t Path( const std::string & p );
+
+ /**
+ Sets the path to the given list of directories.
+ Returns the number of elements in the list.
+ */
+ virtual std::size_t Path( const StringList & p );
+
+ /**
+ Adds p to the path. May be path_separtor()-delimited.
+ */
+ virtual void AddPath( const std::string & p );
+
+ /**
+ Adds a "search extension." Sample:
+ finder.extension( ".txt:.TXT" ); Will now try all
+ path combinations with the rightmost characters
+ matching ".txt" or ".TXT" (in that order). Be sure
+ to include a period if you want that searched -
+ that is so this class can be used to find non-files
+ and those with non-traditional extensions, like
+ "foo_EXT".
+ */
+ virtual void AddExtension( const std::string & ext );
+ /**
+ like AddExtension(), but overwrites extension list.
+ Returns the number of entries parsed from the string.
+ */
+ virtual std::size_t Extensions( const std::string & ext );
+ /**
+ Sets the extensions list to the given list.
+ Returns the number of entries in p.
+ */
+ virtual std::size_t Extensions( const StringList & p );
+
+ /**
+ Returns the PathSeparator()-delimited listed of file
+ suffixes to use when searching for a path.
+ */
+ std::string ExtensionsString() const;
+ /**
+ Returns this object's extensions list.
+ */
+ StringList Extensions() const;
+
+ /** Non-const overload, intended for serialization. */
+ StringList & Extensions();
+
+ /**
+ Helper function to collapse a list into a string.
+
+ This function was changed from a normal member to
+ static member in s11n version 1.1.3.
+ */
+ static std::string JoinList( const StringList & list, const std::string &
separator );
+
+ /**
+ Returns true if path is readable.
+ */
+ static bool IsAccessible( const std::string & path );
+
+ /**
+ Returns the "base name" of the given string: any part
+ following the final directory separator character.
+ */
+ static std::string BaseName( const std::string & );
+
+ /**
+ Returns a platform-dependent directory separator. This
+ is set when the class is compiled:
+
+ Windows: '\\'
+ Everyone else: '/'
+ */
+ static std::string DirSeparator();
+
+ /**
+ Returns the full path of the given resource,
+ provided it could be found using the available
+ lookup paths/extensions and is readable. Note that
+ this might return a relative path, especially if
+ the resourcename passed to it immediately resolves
+ to an existing resource. It returns an empty
+ string if the resourcename cannot be found in the
+ filesystem tree (or is otherwise unaccessible).
+
+ If check_cache is false then this function ignores
+ its lookup cache and searches again, otherwise it
+ uses a cache. When caching it will always return
+ the same result for any given resourcename.
+ */
+ std::string Find( const std::string & resourcename, bool check_cache )
const;
+ /** Equivalent to Find(resourcename,true). */
+ std::string Find( const std::string & resourcename ) const { return
this->Find(resourcename,true); }
+
+ /**
+ Empties the hit-cache used by Find().
+ */
+ void ClearCache();
+
+ /**
+ Returns a list of all items added via AddPath() and path().
+ */
+ StringList Path() const;
+
+ /** Non-const overload, intended mainly for serialization
+ purposes. */
+ StringList & Path();
+
+ /** Returns true if this object has no paths or extensions. */
+ bool IsEmpty() const;
+
+ private:
+ StringList paths;
+ StringList exts;
+ std::string pathseparator;
+ typedef std::map < std::string, std::string > StringStringMap;
+ typedef StringStringMap::iterator StringStringIterator;
+ mutable StringStringMap hitcache;
+ };
+
+ /**
+ Shared instance of PathFinder used for searching for scripts.
+ */
+ PathFinder & ScriptsPath();
+
+ /**
+
+ Sets up script-side access to the PathFinder class and to the
+ shared PathFinder instance available via
+ v8::juice::plugin::PluginsPath().
+
+ After calling this, the shared plugin path is available script-side
+ as the object 'PathFinder.shared.plugins'. Modifying that object
+ will modify the search path for plugin loading.
+
+ The returned object has the following functions
+ and functions:
+
+ - String pathString()
+ - int setPathString( String )
+ - Array pathArray()
+ - int setPathArray( Array )
+ - String pathSeparator()
+ - void setPathSeparator( String )
+ - Array extensionsArray()
+ - int setExtensionsArray( Array )
+ - String extensionsString()
+ - int setExtensionsString( String )
+ - void addPathString( String )
+ - void addExtensionString( String )
+ - String find( String )
+ - void clearCache()
+ - bool isEmpty()
+
+ For the full JS-side API docs see:
+
+ http://code.google.com/p/v8-juice/wiki/PathFinderClass
+ */
+ v8::Handle< ::v8::Value >
SetupPathFinderClass(const ::v8::Handle< ::v8::Object > target );
+
+} // namespace
+
+#endif // V8_JUICE_PATHFINDER_H_INCLUDED
=======================================
--- /dev/null
+++ /convert/addons/pathfinder/cvv8-PathFinder.cpp Thu Apr 12 11:24:20 2012
@@ -0,0 +1,132 @@
+
+#include "cvv8-PathFinder.hpp"
+#include "cvv8/XTo.hpp"
+#include "cvv8/properties.hpp"
+namespace cvv8 {
+ CVV8_TypeName_IMPL((PathFinder),"PathFinder");
+
+#if 0 /* needed? */
+ template <>
+ const void * ClassCreator_TypeID<PathFinder>::Value =
TypeName<PathFinder>::Value;
+#endif
+
+ void ClassCreator_WeakWrap<PathFinder>::PreWrap(
v8::Persistent<v8::Object> const &, v8::Arguments const & ){
+ return;
+ }
+ void ClassCreator_WeakWrap<PathFinder>::Wrap(
v8::Persistent<v8::Object> const &, NativeHandle ){
+ return;
+ }
+ void ClassCreator_WeakWrap<PathFinder>::Unwrap( v8::Handle<v8::Object>
const &, NativeHandle ){
+ return;
+ }
+
+ ClassCreator_Factory<PathFinder>::ReturnType
+ ClassCreator_Factory<PathFinder>::Create(v8::Persistent<v8::Object> &,
v8::Arguments const & argv ){
+ int argc = argv.Length();
+ std::string a0 = (argc>0) ? CastFromJS<std::string>(argv[0]) : "";
+ std::string a1 = (argc>1) ? CastFromJS<std::string>(argv[1]) : "";
+ std::string a2 = (argc>2) ? CastFromJS<std::string>(argv[2]) : ":";
+ PathFinder * pf = new PathFinder(a0, a1, a2);
+ return pf;
+ }
+
+ void ClassCreator_Factory<PathFinder>::Delete( PathFinder * obj ){
+ if(obj) delete obj;
+ }
+
+ static v8::Handle<v8::Value> pf_toString( v8::Arguments const & argv )
+ {
+ typedef PathFinder T;
+ T * p = CastFromJS<T>( argv.This() );
+ StringBuffer sb;
+ sb << "[object "<<TypeName<T>::Value<<"@"<<p<<"]";
+ return sb;
+ }
+
+
+ template <>
+ struct JSToNative<PathFinder::StringList> :
JSToNative_list<PathFinder::StringList> {};
+ template <>
+ struct NativeToJS<PathFinder::StringList const &> :
NativeToJS<PathFinder::StringList> {};
+
+ void ClassCreator_SetupBindings<PathFinder>::Initialize(
v8::Handle<v8::Object> const & target ) {
+ typedef PathFinder T;
+ typedef ClassCreator<T> CC;
+ CC & cc( CC::Instance() );
+ if( cc.IsSealed() ){
+ cc.AddClassTo( TypeName<T>::Value, target );
+ return;
+ }
+
+ typedef T::StringList SL;
+ typedef SL const & SLCR;
+#define CATCHER InCaCatcher_std /* convenience macro */
+
+ // ADD YOUR BINDINGS HERE, e.g...
+ cc
+ ("destroy", CC::DestroyObjectCallback )
+ ("addExtensionString",
+ MethodTo<InCa, T, void (std::string const &),
&T::AddExtension>::Call)
+ ( "addPathString",
+ MethodTo<InCa, T, void (std::string const &),
&T::AddPath>::Call )
+ ( "baseName",
+ FunctionTo<InCa, std::string (std::string const &),
T::BaseName>::Call )
+ ( "clearCache",
+ MethodTo<InCa, T, void (), &T::ClearCache>::Call )
+ ( "search",
+ MethodTo<InCa, T const, std::string (std::string const &),
&T::Find>::Call )
+ ( "isAccessible",
+ FunctionTo<InCa, bool (std::string const &),
T::IsAccessible>::Call )
+ ( "isEmpty",
+ MethodTo<InCa, T const, bool (), &T::IsEmpty>::Call )
+ ( "getPathSeparator",
+ MethodTo<InCa, T const, std::string
(),&T::PathSeparator>::Call )
+ ( "setPathSeparator",
+ MethodTo<InCa, T, void (std::string const
&) ,&T::PathSeparator>::Call )
+ ( "getPathString",
+ MethodTo<InCa, T const, std::string (),&T::PathString>::Call
)
+ ( "setPathString",
+ MethodTo<InCa, T, size_t (std::string const
&),&T::Path>::Call )
+ ( "getPathArray",
+ MethodTo<InCa, T const, SL (),&T::Path>::Call )
+ ( "setPathArray",
+ MethodTo<InCa, T, size_t (SLCR), &T::Path>::Call )
+ ( "getExtensionsArray",
+ MethodTo<InCa, T const, SL (),&T::Extensions>::Call )
+ ( "setExtensionsArray",
+ MethodTo<InCa, T, size_t (SLCR), &T::Extensions>::Call )
+ ( "getExtensionsString",
+ MethodTo<InCa, T const, std::string
(),&T::ExtensionsString>::Call )
+ ( "setExtensionsString",
+ MethodTo<InCa, T, size_t (std::string const
&),&T::Extensions>::Call )
+ ( "toString",
+ pf_toString)
+ ;
+
+#if 0
+ // Proxy accessor/mutator functions as JS properties
+ AccessorAdder acc( cc.Prototype() );
+ acc
+ ("x",
+ MethodTo< Getter, T const, uint32_t (), &T::getX >::Get,
+ MethodTo< Setter, T, void (uint32_t), &T::setX >::Set )
+ ;
+#endif
+
+#if 0
+ // Set up properties on the ctor...
+ v8::Handle<v8::Function> ctor( cc.CtorFunction() );
+ // then use ctor->Set() and friends.
+ // These MUST come after your prototype-level bindings (don't ask
me why)
+#endif
+#undef CATCHER
+ cc.AddClassTo( TypeName<T>::Value, target );
+ return;
+
+ }
+
+ void SetupPathFinderBindings( v8::Handle<v8::Object> const & target) {
+ ClassCreator_SetupBindings<PathFinder>::Initialize(target);
+ }
+} /* namespace */
+
=======================================
--- /dev/null
+++ /convert/addons/pathfinder/cvv8-PathFinder.hpp Thu Apr 12 11:24:20 2012
@@ -0,0 +1,52 @@
+#include "cvv8/ClassCreator.hpp"
+#include "PathFinder.hpp"
+namespace cvv8 {
+ CVV8_TypeName_DECL((PathFinder));
+
+ template <>
+ struct ClassCreator_InternalFields<PathFinder>
+ : ClassCreator_InternalFields_Base<PathFinder>
+ {};
+
+ template <>
+ struct ClassCreator_SearchPrototypeForThis<PathFinder> : Opt_Bool<true>
+ {};
+
+ template <>
+ class ClassCreator_Factory<PathFinder>
+ {
+ public:
+ typedef PathFinder * ReturnType;
+ static ReturnType Create( v8::Persistent<v8::Object> & jsSelf,
v8::Arguments const & argv );
+ static void Delete( ReturnType obj );
+ };
+
+ template <>
+ struct ClassCreator_WeakWrap<PathFinder>
+ {
+ typedef typename TypeInfo<PathFinder>::NativeHandle NativeHandle;
+ static void PreWrap( v8::Persistent<v8::Object> const &,
v8::Arguments const & );
+ static void Wrap( v8::Persistent<v8::Object> const &, NativeHandle
);
+ static void Unwrap( v8::Handle<v8::Object> const &, NativeHandle );
+ };
+
+ template <>
+ struct ClassCreator_SetupBindings<PathFinder>
+ {
+ static void Initialize( v8::Handle<v8::Object> const & target );
+ };
+
+
+ template <>
+ struct JSToNative<PathFinder>
+ : JSToNative_ClassCreator<PathFinder>
+ {};
+
+#if 0
+ template <>
+ struct NativeToJS<PathFinder> :
NativeToJSMap<PathFinder>::NativeToJSImpl {};
+#endif
+
+ void SetupPathFinderBindings( v8::Handle<v8::Object> const & );
+} /* namespace */
+
=======================================
--- /dev/null
+++ /convert/addons/pathfinder/test.js Thu Apr 12 11:24:20 2012
@@ -0,0 +1,17 @@
+load('../test-common.js');
+//ByteArray.enableDestructorDebug(true);
+function test1()
+{
+ var pf = new PathFinder();
+ print('pf='+pf);
+
+
pf.setPathArray(['/usr/local/bin','/usr/bin','/bin','/usr/sbin','/sbin']);
+ assert(pf.search('ls'), 'found ls' );
+ assert(pf.search('gzip'), 'found gzip' );
+ assert(!pf.search('bogoappdoesnotexist'), 'did not find imaginary
file.' );
+ pf.destroy();
+}
+
+
+test1();
+print("If you made it this far without an exception then you win!");
=======================================
--- /convert/addons/Makefile Sun Feb 19 07:00:07 2012
+++ /convert/addons/Makefile Thu Apr 12 11:24:20 2012
@@ -1,9 +1,18 @@
#!/usr/bin/make -f
default: all

-SUBDIRS := bytearray curl expat glob \
- jspdo readline shell-skel socket \
- sprintf time whio
+SUBDIRS := bytearray \
+ curl \
+ expat \
+ glob \
+ jspdo \
+ pathfinder \
+ readline \
+ shell-skel \
+ socket \
+ sprintf \
+ time \
+ whio

.PHONY: $(SUBDIRS)
$(SUBDIRS):
=======================================
--- /convert/addons/createCCWrapper.sh Thu Apr 12 10:48:16 2012
+++ /convert/addons/createCCWrapper.sh Thu Apr 12 11:24:20 2012
@@ -107,21 +107,21 @@

EOF

- local FAC="ClassCreator_Factor<${class} >"
+ local FAC="ClassCreator_Factory<${class} >"
cat <<EOF
- static ${FAC}::ReturnType ${FAC}::Create( v8::Persistent<v8::Object>
&, v8::Arguments const & argv ){
+ ${FAC}::ReturnType ${FAC}::Create( v8::Persistent<v8::Object> &,
v8::Arguments const & argv ){
return new ${class};
}

- static void ${FAC}::Delete( ${class} * obj ){
+ void ${FAC}::Delete( ${class} * obj ){
if(obj) delete obj;
}
EOF

cat <<EOF
- void ClassCreator_SetupBindings<typename ${class} >::Initialize(
v8::Handle<v8::Object> const & target ){
+ void ClassCreator_SetupBindings< ${class} >::Initialize(
v8::Handle<v8::Object> const & target ){
typedef ${class} T;
- typedef ClassCreator<T> CC:
+ typedef ClassCreator<T> CC;
CC & cc( CC::Instance() );
if( cc.IsSealed() ){
cc.AddClassTo( TypeName<T>::Value, target );
=======================================
--- /convert/examples/Makefile Thu Feb 9 10:25:13 2012
+++ /convert/examples/Makefile Thu Apr 12 11:24:20 2012
@@ -5,6 +5,7 @@
TOP_DIR := ../
include $(TOP_DIR)/config.make # see that file for certain configuration
options.

+CXXFLAGS += -std=c++0x
ConvertDemo.o: ConvertDemo.cpp
SHELL.DIR := $(TOP_DIR)/addons/shell-skel
demo.BIN.OBJECTS := demo.o ConvertDemo.o
=======================================
--- /convert/include/cvv8/arguments.hpp Mon Aug 15 04:32:39 2011
+++ /convert/include/cvv8/arguments.hpp Thu Apr 12 11:24:20 2012
@@ -376,9 +376,9 @@

Index = arg index to check.

- T is a type for which ValIs<T> is legal. The functor
- returns true if ValIs<T> returns true the argument
- at the given index.
+ T is a type for which ValIs<T> is legal. The functor returns
+ true if ValIs<T> returns true for the argument at the given
+ index.
*/
template <unsigned short Index, typename T>
struct ArgAt_IsA : ArgAt_Is< Index, ValIs<T> > {};
=======================================
--- /convert/include/cvv8/detail/convert_core.hpp Sat Apr 7 18:48:57 2012
+++ /convert/include/cvv8/detail/convert_core.hpp Thu Apr 12 11:24:20 2012
@@ -1550,10 +1550,15 @@
/** Partial specialization for std::list<>. */
template <typename T>
struct JSToNative< std::list<T> > : JSToNative_list< std::list<T> > {};
-
+ template <typename T>
+ struct JSToNative< std::list<T> const & > : JSToNative< std::list<T> >
{};
+
+
/** Partial specialization for std::vector<>. */
template <typename T>
struct JSToNative< std::vector<T> > : JSToNative_list< std::vector<T>
> {};
+ template <typename T>
+ struct JSToNative< std::vector<T> const & > : JSToNative<
std::vector<T> > {};

#if 0 // untested code
/**

Reply all
Reply to author
Forward
0 new messages