LangDev

Boost.PHP

홍민희

Boost.PHP

누가 Boost.Python 보고 삘받아서 PHP로도 만들었군요. PHP 확장도 이제 발로 만들 수 있을듯…

#include "boost/php/module.hpp" 
#include "boost/php/function.hpp" 

using namespace boost;

class m002_module
    : public php::module,
      public php::function_container<m002_module> {
public:
    class handler
        : public php::module::handler {
    public:
        handler(m002_module* mod)
            :php::module::handler(mod) {}

        int add(int a, int b) {
            return a + b;
        }

        int sub(int a, int b) {
            return a - b;
        }
    };
public:
    m002_module(zend_module_entry* entry)
        : php::module(entry) {
        entry->functions =
             defun("add", &handler::add).
             defun("sub", &handler::sub);
    }
};

#define BOOST_PHP_MODULE_NAME m002
#define BOOST_PHP_MODULE_CAPITALIZED_NAME M002
#define BOOST_PHP_MODULE_VERSION "0.1" 
#define BOOST_PHP_MODULE_CLASS_NAME m002_module

#include "boost/php/module_def.hpp"

헉...

디토

민군

wookay