Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: windows build #504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ extern PHPCPP_EXPORT bool class_exists(const char *classname, size_t size, b
static inline bool class_exists(const char *classname, bool autoload = true) { return class_exists(classname, strlen(classname), autoload); }
static inline bool class_exists(const std::string &classname, bool autoload = true) { return class_exists(classname.c_str(), classname.size(), autoload); }
extern PHPCPP_EXPORT Value constant(const char *constant);
extern PHPCPP_EXPORT Value constant(const char *constant, size_t size);
//extern PHPCPP_EXPORT Value constant(const char *constant, size_t size);
extern PHPCPP_EXPORT Value constant(const std::string &constant);
extern PHPCPP_EXPORT bool define(const char *name, size_t size, const Value &value);
//extern PHPCPP_EXPORT bool define(const char *name, size_t size, const Value &value);
extern PHPCPP_EXPORT bool define(const char *name, const Value &value);
extern PHPCPP_EXPORT bool define(const std::string &name, const Value &value);
extern PHPCPP_EXPORT bool defined(const char *constant);
Expand All @@ -46,8 +46,8 @@ extern PHPCPP_EXPORT Value require(const char *filename);
static inline Value require(const std::string &filename) { return require(filename.c_str()); }
extern PHPCPP_EXPORT Value require_once(const char *filename);
static inline Value require_once(const std::string &filename) { return require_once(filename.c_str()); }
extern PHPCPP_EXPORT Value set_exception_handler(const std::function<Value(Parameters &params)> &handler);
extern PHPCPP_EXPORT Value set_error_handler(const std::function<Value(Parameters &params)> &handler, Message message = Message::All);
//extern PHPCPP_EXPORT Value set_exception_handler(const std::function<Value(Parameters &params)> &handler);
//extern PHPCPP_EXPORT Value set_error_handler(const std::function<Value(Parameters &params)> &handler, Message message = Message::All);
extern PHPCPP_EXPORT Value error_reporting(Message message);
extern PHPCPP_EXPORT const char *sapi_name();

Expand Down
10 changes: 5 additions & 5 deletions include/streams.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ namespace Php {
/**
* Define the out and err objects
*/
extern thread_local PHPCPP_EXPORT std::ostream out;
extern thread_local PHPCPP_EXPORT std::ostream error;
extern thread_local PHPCPP_EXPORT std::ostream notice;
extern thread_local PHPCPP_EXPORT std::ostream warning;
extern thread_local PHPCPP_EXPORT std::ostream deprecated;
extern PHPCPP_EXPORT std::ostream out;
extern PHPCPP_EXPORT std::ostream error;
extern PHPCPP_EXPORT std::ostream notice;
extern PHPCPP_EXPORT std::ostream warning;
extern PHPCPP_EXPORT std::ostream deprecated;

/**
* End namespace
Expand Down
1 change: 1 addition & 0 deletions include/throwable.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
#include <exception>
#include <string>
#include <iostream>

/**
* Forward declarations
Expand Down
94 changes: 47 additions & 47 deletions phpcpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,52 @@
/**
* Include all headers files that are related to this library
*/
#include <phpcpp/visibility.h>
#include <phpcpp/deprecated.h>
#include <phpcpp/noexcept.h>
#include <phpcpp/thread_local.h>
#include <phpcpp/platform.h>
#include <phpcpp/version.h>
#include <phpcpp/inivalue.h>
#include <phpcpp/ini.h>
#include <phpcpp/throwable.h>
#include <phpcpp/exception.h>
#include <phpcpp/error.h>
#include <phpcpp/streams.h>
#include <phpcpp/message.h>
#include <phpcpp/type.h>
#include <phpcpp/hashparent.h>
#include <phpcpp/value.h>
#include <phpcpp/valueiterator.h>
#include <phpcpp/array.h>
#include <phpcpp/object.h>
#include <phpcpp/globals.h>
#include <phpcpp/argument.h>
#include <phpcpp/byval.h>
#include <phpcpp/byref.h>
#include <phpcpp/global.h>
#include <phpcpp/hashmember.h>
#include <phpcpp/super.h>
#include <phpcpp/parameters.h>
#include <phpcpp/modifiers.h>
#include <phpcpp/base.h>
#include <phpcpp/countable.h>
#include <phpcpp/arrayaccess.h>
#include <phpcpp/iterator.h>
#include <phpcpp/traversable.h>
#include <phpcpp/serializable.h>
#include <phpcpp/classtype.h>
#include <phpcpp/classbase.h>
#include <phpcpp/constant.h>
#include <phpcpp/interface.h>
#include <phpcpp/zendcallable.h>
#include <phpcpp/class.h>
#include <phpcpp/namespace.h>
#include <phpcpp/extension.h>
#include <phpcpp/call.h>
#include <phpcpp/script.h>
#include <phpcpp/file.h>
#include <phpcpp/function.h>
#include <phpcpp/stream.h>
#include <include/visibility.h>
#include <include/deprecated.h>
#include <include/noexcept.h>
#include <include/thread_local.h>
#include <include/platform.h>
#include <include/version.h>
#include <include/inivalue.h>
#include <include/ini.h>
#include <include/throwable.h>
#include <include/exception.h>
#include <include/error.h>
#include <include/streams.h>
#include <include/message.h>
#include <include/type.h>
#include <include/hashparent.h>
#include <include/value.h>
#include <include/valueiterator.h>
#include <include/array.h>
#include <include/object.h>
#include <include/globals.h>
#include <include/argument.h>
#include <include/byval.h>
#include <include/byref.h>
#include <include/global.h>
#include <include/hashmember.h>
#include <include/super.h>
#include <include/parameters.h>
#include <include/modifiers.h>
#include <include/base.h>
#include <include/countable.h>
#include <include/arrayaccess.h>
#include <include/iterator.h>
#include <include/traversable.h>
#include <include/serializable.h>
#include <include/classtype.h>
#include <include/classbase.h>
#include <include/constant.h>
#include <include/interface.h>
#include <include/zendcallable.h>
#include <include/class.h>
#include <include/namespace.h>
#include <include/extension.h>
#include <include/call.h>
#include <include/script.h>
#include <include/file.h>
#include <include/function.h>
#include <include/stream.h>

#endif /* phpcpp.h */
2 changes: 1 addition & 1 deletion zend/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Php::Value Base::__count(Php::Parameters &params)
if (countable == nullptr) return 0;

// pass the call to the interface
return countable->count();
return (Php::Value*) countable->count();
}

/**
Expand Down
5 changes: 3 additions & 2 deletions zend/callable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void Callable::initialize(zend_function_entry *entry, const char *classname, int
{
// that's nice, we simply install the callback
// no need to store any data in a lookup map
entry->handler = _callback;
entry->handler = (zif_handler) _callback;
}
else
{
Expand All @@ -107,7 +107,8 @@ void Callable::initialize(zend_function_entry *entry, const char *classname, int

// we use our own invoke method, which does a lookup
// in the map we just installed ourselves in
entry->handler = &Callable::invoke;
//entry->handler = this->invoke();
entry->handler = (zif_handler)_callback;
}

// fill the members of the entity, and hide a pointer to the current object in the name
Expand Down
6 changes: 3 additions & 3 deletions zend/classimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ zend_function *ClassImpl::getMethod(zend_object **object, zend_string *method, c
function->num_args = 0;
function->required_num_args = 0;
function->arg_info = nullptr;
function->handler = &ClassImpl::callMethod;
function->handler = (zif_handler) &ClassImpl::callMethod;

// store pointer to ourselves
data->self = self(entry);
Expand Down Expand Up @@ -267,7 +267,7 @@ zend_function *ClassImpl::getStaticMethod(zend_class_entry *entry, zend_string *
function->num_args = 0;
function->required_num_args = 0;
function->arg_info = nullptr;
function->handler = &ClassImpl::callMethod;
function->handler = (zif_handler) &ClassImpl::callMethod;

// store pointer to ourselves
data->self = self(entry);
Expand Down Expand Up @@ -311,7 +311,7 @@ int ClassImpl::getClosure(zval *object, zend_class_entry **entry_ptr, zend_funct
function->num_args = 0;
function->required_num_args = 0;
function->arg_info = nullptr;
function->handler = &ClassImpl::callInvoke;
function->handler = (zif_handler) & ClassImpl::callInvoke;

// store pointer to ourselves (note that the entry_ptr is useless
// inside this function as it is always uninitialized for some reason)
Expand Down
4 changes: 2 additions & 2 deletions zend/constantfuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Dependencies
*/
#include "includes.h"
#include "string.h"
#include "strings.h"

/**
* Set up namespace
Expand All @@ -26,7 +26,7 @@ namespace Php {
Value constant(const char *name)
{
// pass on to other implementation
return constant(name, ::strlen(name));
return constant(name);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion zend/exception_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Dependencies
*/
#include "includes.h"
#include "string.h"
#include "strings.h"

/**
* Open the PHP namespace
Expand Down
2 changes: 1 addition & 1 deletion zend/exists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Dependencies
*/
#include "includes.h"
#include "string.h"
#include "strings.h"

/**
* Open the PHP namespace
Expand Down
2 changes: 1 addition & 1 deletion zend/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @copyright 2013 Copernica BV
*/
#include "includes.h"
#include "string.h"
#include "strings.h"

/**
* Namespace
Expand Down
6 changes: 3 additions & 3 deletions zend/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Module
auto iter = _handles.begin();

// remove the handle
DL_UNLOAD(*iter);
DL_UNLOAD((HMODULE) * iter);

// remove from set
_handles.erase(iter);
Expand All @@ -99,7 +99,7 @@ class Module
void add(const char *module)
{
// insert the handle
_handles.insert(DL_LOAD(module));
_handles.insert(DL_LOAD((LPCWSTR)module));
}
};

Expand All @@ -126,7 +126,7 @@ class Module
ExtensionPath path(module);

// load the module
_handle = DL_LOAD(path);
_handle = DL_LOAD((LPCWSTR)*path);

// handle should be valid
if (!_handle) return;
Expand Down
2 changes: 1 addition & 1 deletion zend/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright 2014 - 2019 Copernica BV
*/
#include "includes.h"
#include "string.h"
#include "strings.h"

/**
* Set up namespace
Expand Down
4 changes: 3 additions & 1 deletion zend/parametersimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class ParametersImpl : public Parameters
reserve(argc);

// array to store all the arguments in
zval arguments[argc];
//zval arguments[argc];

zval* arguments = new zval[argc];

// retrieve the arguments
zend_get_parameters_array_ex(argc, arguments);
Expand Down
2 changes: 1 addition & 1 deletion zend/streambuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int StreamBuf::sync()
}

// reset the buffer
pbump(-size);
pbump(size);

// done
return 0;
Expand Down
55 changes: 45 additions & 10 deletions zend/streams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,66 @@
* @copyright 2014 Copernica BV
*/
#include "includes.h"
#include <iostream>

/**
* Set up namespace
*/
namespace Php {

StreamBuf::StreamBuf(int error) : _error(error)
{
// we reserve one byte, so that when overflow is called, we still have one
// byte extra in the buffer to put the overflowed byte int
setp(_buffer, _buffer + 1024 - 1);
}


/**
* Method that is called when the internal buffer overflows
* @param c
* @return int
*/
int StreamBuf::overflow(int c)
{
// for error buffers, overflow is simply discarded
if (_error) return c;

// end-of-file has not output, we call EOF directly, and by using the
// comma operator we ensure that EOF is returned
if (c == EOF) return sync(), EOF;

// because we lied the underlying buffer about the size of the buffer
// by one byte, there is no real overflow, and we can still add the byte
// to the end of the buffer
*pptr() = c;

// increment buffer size
pbump(1);

// and now we're going to syn the buffer
return sync() == -1 ? EOF : c;
}

/**
* Some static buffers for writing data
* @var StreamBuf
*/
static thread_local StreamBuf bufOut (0);
static thread_local StreamBuf bufError (E_ERROR);
static thread_local StreamBuf bufWarning (E_WARNING);
static thread_local StreamBuf bufNotice (E_NOTICE);
static thread_local StreamBuf bufDeprecated (E_DEPRECATED);
static StreamBuf bufOut (0);
static StreamBuf bufError (E_ERROR);
static StreamBuf bufWarning (E_WARNING);
static StreamBuf bufNotice (E_NOTICE);
static StreamBuf bufDeprecated (E_DEPRECATED);

/**
* Create the actual steams
* @var std::ostream
*/
thread_local std::ostream out (&bufOut);
thread_local std::ostream error (&bufError);
thread_local std::ostream warning (&bufWarning);
thread_local std::ostream notice (&bufNotice);
thread_local std::ostream deprecated (&bufDeprecated);
std::ostream out (&bufOut);
std::ostream error (&bufError);
std::ostream warning (&bufWarning);
std::ostream notice (&bufNotice);
std::ostream deprecated (&bufDeprecated);

/**
* End namespace
Expand Down
Loading