Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
bramp committed Dec 5, 2011
0 parents commit 1e681d2
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,8 @@
PHP Bindings for libphonenumber
by Andrew Brampton 2011

WORK IN PROGRESS - NO WHERE NEAR FINISHED....

Notes:
http://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend/
http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/
10 changes: 10 additions & 0 deletions config.m4
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,10 @@
PHP_ARG_ENABLE(phonenumber,
[Whether to enable libphonenumber support],
[ --enable-phonenumber Enable libphonenumber support])

if test "$PHP_PHONENUMBER" = "yes"; then
PHP_REQUIRE_CXX()
PHP_SUBST(PHONENUMBER_SHARED_LIBADD)
PHP_ADD_LIBRARY(stdc++, 1, PHONENUMBER_SHARED_LIBADD)
PHP_NEW_EXTENSION(phonenumber, phonenumber.cc, $ext_shared)
fi
57 changes: 57 additions & 0 deletions phonenumber.cc
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "php_phonenumber.h"

zend_class_entry *phonenumber_util_ce;

PHP_METHOD(PhoneNumberUtil, __construct)
{
PhoneNumberUtil::GetInstance();
}

PHP_METHOD(PhoneNumberUtil, isAlphaNumber)
{
Car *car;
car_object *obj = (car_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
car = obj->car;
if (car == NULL) {
RETURN_NULL();
}
RETURN_BOOLEAN(pn->IsAlphaNumber("hello"));
}

function_entry phonenumber_util_methods[] = {
PHP_ME(PhoneNumberUtil, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(PhoneNumberUtil, isAlphaNumber, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};


PHP_MINIT_FUNCTION(phonenumber)
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "PhoneNumberUtil", phonenumber_util_methods);
phonenumber_util_ce = zend_register_internal_class(&ce TSRMLS_CC);
return SUCCESS;
}

zend_module_entry vehicles_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
PHP_PHONENUMBER_EXTNAME,
NULL, /* Functions */
PHP_MINIT(phonenumber),
NULL, /* MSHUTDOWN */
NULL, /* RINIT */
NULL, /* RSHUTDOWN */
NULL, /* MINFO */
#if ZEND_MODULE_API_NO >= 20010901
PHP_PHONENUMBER_EXTVER,
#endif
STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_PHONENUMBER
extern "C" {
ZEND_GET_MODULE(phonenumber)
}
#endif
20 changes: 20 additions & 0 deletions php_phonenumber.h
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef PHP_HELLO_H
#define PHP_HELLO_H 1

#define PHP_PHONENUMBER_EXTNAME "phonenumber"
#define PHP_PHONENUMBER_EXTVER "1.0"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

extern "C" {
#include "php.h"
}

extern zend_module_entry phonenumber_module_entry;
#define phpext_phonenumber_ptr &phonenumber_module_entry;

#endif


0 comments on commit 1e681d2

Please sign in to comment.