Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 1e681d2087c7b9ae27d0bec1d7df09097c9847a4 @bramp committed Dec 5, 2011
Showing with 95 additions and 0 deletions.
  1. +8 −0 README
  2. +10 −0 config.m4
  3. +57 −0 phonenumber.cc
  4. +20 −0 php_phonenumber.h
8 README
@@ -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/
@@ -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
@@ -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
@@ -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.