LangDev

프로그래밍 언어 개발에 관심 있는 사람들의 모임입니다.


Boost.PHP

2008-07-31 14:00:18

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" 

홍민희 님이 2008-07-31 14:01:00에 고쳤습니다.

트랙백 주소: http://langdev.net/post/trackback/125

  1. 디토 2008-07-31 17:55:43

    헉…

  2. 민군 2008-07-31 19:01:14

  3. wookay 2008-08-01 18:57:49

목록보기

← PHP 5.3 알파 1 | CUFP 2008  →