Skip to content

Commit

Permalink
MSVC compatibility
Browse files Browse the repository at this point in the history
object.hpp:
* removed include of string.hpp as it doesn't seem to be necessary (that's why compilation is now possible using msvc)

Had to rearrange the include of object.hpp in some files, so the template instantiation has complete types:
* spidermonkey/exception.cpp
* filesystem-base.hpp

Some files now need to include object.hpp, so the template instantiation has complete types:
* spidermonkey/string.cpp
* spidermonkey/arguments.cpp

Some files now need to include string.hpp, as it was removed from object.hpp
* spidermonkey/evaluate.cpp

string.hpp and string.cpp:
* Removed the value- and string-tag

modules.cpp:
* isspace doesn't seem to be in std on windows (at least not the one-parameter-version from ctype.h)

value.hpp:
* removed include of convert.hpp

value.cpp:
* commented out wrap_jsval, as it was already defined somewhere else (seems to be a new bug)

filesystem-base.cpp:
* had to uncomment R_OK and W_OK

arguments.hpp:
* rewrote the "unequals"-operator. don't know why it works this way

convert.hpp:
* removed the include of spidermonkey/string.hpp as it
* replaced js_char16_t with js_char (the typedef was the only thing needed from string.hpp)
  • Loading branch information
FunkMonkey committed Aug 8, 2010
1 parent 411665a commit 741c90d
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 23 deletions.
3 changes: 2 additions & 1 deletion include/flusspferd/arguments.hpp
Expand Up @@ -186,7 +186,8 @@ inline bool operator==(
inline bool operator!=(arguments::iterator const &lhs,
arguments::iterator const &rhs)
{
return !(lhs == rhs);
return !lhs.equals(rhs); // no idea, why this compiles on MSVC and the one below doesn't
//return !(lhs == rhs);
}

}
Expand Down
4 changes: 2 additions & 2 deletions include/flusspferd/convert.hpp
Expand Up @@ -30,7 +30,7 @@ THE SOFTWARE.
#include "value.hpp"
#include "root.hpp"
#include "exception.hpp"
#include "spidermonkey/string.hpp"
//#include "spidermonkey/string.hpp"
#include <boost/noncopyable.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_float.hpp>
Expand Down Expand Up @@ -237,7 +237,7 @@ template<>
struct convert<std::string>;

template<>
struct convert<std::basic_string<js_char16_t> >;
struct convert<std::basic_string<jschar> >;

template<typename T>
struct convert_ptr<T, native_object_base>;
Expand Down
3 changes: 2 additions & 1 deletion include/flusspferd/io/filesystem-base.hpp
Expand Up @@ -27,8 +27,9 @@ THE SOFTWARE.
#ifndef FLUSSPFERD_IO_FILESYSTEM_BASE_HPP
#define FLUSSPFERD_IO_FILESYSTEM_BASE_HPP

#include "../string.hpp"
#include "../object.hpp"
#include "../string.hpp"

#include <boost/filesystem.hpp>

namespace flusspferd {
Expand Down
4 changes: 3 additions & 1 deletion include/flusspferd/object.hpp
Expand Up @@ -33,7 +33,8 @@ THE SOFTWARE.
#include "arguments.hpp"
#include "value.hpp"
#include "convert.hpp"
#include "string.hpp"
//#include "string.hpp"

#include <string>
#include <memory>
#endif
Expand All @@ -45,6 +46,7 @@ THE SOFTWARE.
namespace flusspferd {

#ifndef PREPROC_DEBUG
class string;
class value;
class context;
class native_object_base;
Expand Down
11 changes: 4 additions & 7 deletions include/flusspferd/spidermonkey/string.hpp
Expand Up @@ -40,9 +40,6 @@ typedef jschar js_char16_t;

namespace Impl {

struct string_tag {};
struct value_tag {};

class string_impl {
JSString *str;

Expand All @@ -51,11 +48,11 @@ class string_impl {
void set(JSString *s) { str = s; }

string_impl();
explicit string_impl(JSString *s, string_tag) : str(s) { }
explicit string_impl(char const *s, string_tag);
explicit string_impl(JSString *s) : str(s) { }
explicit string_impl(char const *s);
explicit string_impl(char const *s, std::size_t n);
explicit string_impl(js_char16_t const *s, std::size_t n);
explicit string_impl(value const &v, value_tag);
explicit string_impl(value const &v);

friend JSString *get_string(string_impl &s);
friend string_impl wrap_string(JSString *s);
Expand All @@ -71,7 +68,7 @@ inline JSString *get_string(string_impl &s) {
}

inline string_impl wrap_string(JSString *s) {
return string_impl(s, string_tag());
return string_impl(s);
}

}
Expand Down
2 changes: 1 addition & 1 deletion include/flusspferd/value.hpp
Expand Up @@ -289,6 +289,6 @@ inline bool operator!=(value const &a, value const &b) {

}

#include "convert.hpp"
//#include "convert.hpp"

#endif /* FLUSSPFERD_VALUE_HPP */
6 changes: 3 additions & 3 deletions libflusspferd/io/filesystem-base.cpp
Expand Up @@ -39,8 +39,8 @@ THE SOFTWARE.

#define access _access

//int const R_OK = 04;
//int const W_OK = 02;
int const R_OK = 04;
int const W_OK = 02;

#else
#include <unistd.h>
Expand Down Expand Up @@ -240,7 +240,7 @@ double fs_base::size(std::string const &file) {
if (!security::get().check_path(file, security::ACCESS)) {
throw exception(format(error_sec) % "size" % file);
}
uintmax_t fsize = fs::file_size(file);
boost::uintmax_t fsize = fs::file_size(file);
return fsize;
}

Expand Down
6 changes: 3 additions & 3 deletions libflusspferd/modules.cpp
Expand Up @@ -745,7 +745,7 @@ static array split_args_string(value const &v) {
std::string::const_iterator i = input.begin();
std::string::const_iterator const e = input.end();
for(;i != e; ++i) {
if (!std::isspace(*i))
if (!isspace(*i))
break;
}

Expand Down Expand Up @@ -780,11 +780,11 @@ static array split_args_string(value const &v) {
current.append(backslash_count, '\\');
backslash_count = 0;
}
if (std::isspace(*i) && !inside_quoted) {
if (isspace(*i) && !inside_quoted) {
// Space outside quoted section terminate the current argument
result.push(current);
current.resize(0);
for(;i != e && std::isspace(*i); ++i)
for(;i != e && isspace(*i); ++i)
;
--i;
} else {
Expand Down
1 change: 1 addition & 0 deletions libflusspferd/spidermonkey/arguments.cpp
Expand Up @@ -27,6 +27,7 @@ THE SOFTWARE.
#include "flusspferd/arguments.hpp"
#include "flusspferd/exception.hpp"
#include "flusspferd/value.hpp"
#include "flusspferd/object.hpp"
#include <boost/foreach.hpp>
#include <cassert>
#include <js/jsapi.h>
Expand Down
1 change: 1 addition & 0 deletions libflusspferd/spidermonkey/evaluate.cpp
Expand Up @@ -24,6 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "flusspferd/evaluate.hpp"
#include "flusspferd/string.hpp"
#include "flusspferd/local_root_scope.hpp"
#include "flusspferd/init.hpp"
#include "flusspferd/spidermonkey/init.hpp"
Expand Down
3 changes: 2 additions & 1 deletion libflusspferd/spidermonkey/exception.cpp
Expand Up @@ -24,11 +24,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/


#include "flusspferd/object.hpp"
#include "flusspferd/exception.hpp"
#include "flusspferd/string.hpp"
#include "flusspferd/root.hpp"
#include "flusspferd/arguments.hpp"
#include "flusspferd/object.hpp"
#include "flusspferd/init.hpp"
#include "flusspferd/current_context_scope.hpp"
#include "flusspferd/spidermonkey/value.hpp"
Expand Down
7 changes: 4 additions & 3 deletions libflusspferd/spidermonkey/string.cpp
Expand Up @@ -24,6 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include "flusspferd/object.hpp"
#include "flusspferd/string.hpp"
#include "flusspferd/exception.hpp"
#include "flusspferd/spidermonkey/init.hpp"
Expand All @@ -38,7 +39,7 @@ Impl::string_impl::string_impl()
: str(JSVAL_TO_STRING(JS_GetEmptyStringValue(Impl::current_context())))
{ }

Impl::string_impl::string_impl(char const *s, string_tag)
Impl::string_impl::string_impl(char const *s)
: str(JS_NewStringCopyZ(Impl::current_context(), s))
{
if (!str)
Expand All @@ -59,7 +60,7 @@ Impl::string_impl::string_impl(js_char16_t const *s, std::size_t n)
throw exception("Could not create string");
}

Impl::string_impl::string_impl(value const &v, value_tag)
Impl::string_impl::string_impl(value const &v)
: str(JS_ValueToString(Impl::current_context(),
Impl::get_jsval(const_cast<value&>(v))))
{
Expand All @@ -74,7 +75,7 @@ namespace {
}

string::string() { }
string::string(value const &v) : Impl::string_impl(v, Impl::value_tag()) { }
string::string(value const &v) : Impl::string_impl(v) { }
string::string(char const *s, std::size_t n)
: Impl::string_impl(s, n ? n : std::strlen(s)) { }
string::string(js_char16_t const *s, std::size_t n)
Expand Down
2 changes: 2 additions & 0 deletions libflusspferd/spidermonkey/value.cpp
Expand Up @@ -193,10 +193,12 @@ jsid Impl::get_jsid(Impl::value_impl const &v) {
return id;
}

/*
Impl::value_impl Impl::wrap_jsid(jsid id) {
jsval value;
if(!JS_IdToValue(Impl::current_context(), id, &value)) {
throw exception("Could not convert id to value");
}
return Impl::wrap_jsval(value);
}
*/

0 comments on commit 741c90d

Please sign in to comment.