Permalink
Browse files

Adding exceptions, general cleanup

  • Loading branch information...
1 parent 9549b64 commit afe3a9af1108ae9348bd16dd6b2a41652749d018 @jbboehr committed Mar 22, 2012
Showing with 57 additions and 1 deletion.
  1. +1 −1 mustache
  2. +40 −0 mustache_exceptions.cpp
  3. +16 −0 mustache_exceptions.hpp
Submodule mustache updated 2 files
+16 −2 exception.hpp
+7 −7 tokenizer.cpp
View
@@ -0,0 +1,40 @@
+
+#include "php_mustache.hpp"
+#include "mustache_exceptions.hpp"
+
+
+
+// Class Entries --------------------------------------------------------------
+
+PHPAPI zend_class_entry * MustacheException_ce_ptr;
+PHPAPI zend_class_entry * MustacheParserException_ce_ptr;
+
+
+
+// MINIT -----------------------------------------------------------------------
+
+PHP_MINIT_FUNCTION(mustache_exceptions)
+{
+ try {
+ zend_class_entry * exception_ce = zend_exception_get_default(TSRMLS_C);
+
+ // MustacheException
+ zend_class_entry mustache_exception_ce;
+ INIT_CLASS_ENTRY_EX(mustache_exception_ce, "MustacheException", strlen("MustacheException"), NULL);
+ MustacheException_ce_ptr = zend_register_internal_class_ex(&mustache_exception_ce,
+ exception_ce, NULL TSRMLS_CC);
+ MustacheException_ce_ptr->create_object = exception_ce->create_object;
+
+ // MustacheParserException
+ zend_class_entry mustache_parser_exception_ce;
+ INIT_CLASS_ENTRY_EX(mustache_parser_exception_ce, "MustacheParserException", strlen("MustacheParserException"), NULL);
+ MustacheParserException_ce_ptr = zend_register_internal_class_ex(&mustache_parser_exception_ce,
+ MustacheException_ce_ptr, NULL TSRMLS_CC);
+ MustacheParserException_ce_ptr->create_object = MustacheException_ce_ptr->create_object;
+
+ return SUCCESS;
+ } catch(...) {
+ mustache_exception_handler(TSRMLS_C);
+ return FAILURE;
+ }
+}
View
@@ -0,0 +1,16 @@
+
+#ifndef PHP_MUSTACHE_EXCEPTIONS_HPP
+#define PHP_MUSTACHE_EXCEPTIONS_HPP
+
+
+#include "php.h"
+
+
+extern PHPAPI zend_class_entry * MustacheException_ce_ptr;
+extern PHPAPI zend_class_entry * MustacheParserException_ce_ptr;
+
+
+PHP_MINIT_FUNCTION(mustache_exceptions);
+
+
+#endif

0 comments on commit afe3a9a

Please sign in to comment.