Skip to content

Commit

Permalink
Merge 32ec21d into 14fc707
Browse files Browse the repository at this point in the history
  • Loading branch information
jbboehr committed Nov 9, 2018
2 parents 14fc707 + 32ec21d commit 14cb7c9
Show file tree
Hide file tree
Showing 20 changed files with 0 additions and 528 deletions.
1 change: 0 additions & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ if test "$PHP_MUSTACHE" != "no"; then
PHP_MUSTACHE_ADD_SOURCES([
php_mustache.cpp
mustache_ast.cpp
mustache_code.cpp
mustache_mustache.cpp
mustache_exceptions.cpp
mustache_data.cpp
Expand Down
22 changes: 0 additions & 22 deletions mustache.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,6 @@ public function setStartSequence($start) {}
*/
public function setStopSequence($stop) {}

/**
* Compiles a template to bytecode and returns a class representing it.
*
* @param mixed $tmpl The input template maybe be a string or an
* instance of MustacheTemplate or MustacheAST
* @param mixed $partials (Optional) The template partials. Must be an array
* with each value either a string, or an instance of
* MustacheTemplate or MustacheAST
* @return MustacheCode The compiled template
*/
public function compile($tmpl, $partials = null) {}

/**
* Executes compiled bytecode.
*
* @param MustacheCode $code The input bytecode
* @param mixed $data The input data. May be any array, scalar, or object,
* or an instance of MustacheData
* @return string The string output
*/
public function execute(MustacheCode $code, $data) {}

/**
* Tokenizes and parses a template and returns a class representing it.
*
Expand Down
145 changes: 0 additions & 145 deletions mustache_code.cpp

This file was deleted.

22 changes: 0 additions & 22 deletions mustache_code.hpp

This file was deleted.

104 changes: 0 additions & 104 deletions mustache_mustache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "php_mustache.h"
#include "php5to7.h"
#include "mustache_ast.hpp"
#include "mustache_code.hpp"
#include "mustache_data.hpp"
#include "mustache_exceptions.hpp"
#include "mustache_template.hpp"
Expand Down Expand Up @@ -38,14 +37,6 @@ ZEND_BEGIN_ARG_INFO_EX(Mustache__setStopSequence_args, ZEND_SEND_BY_VAL, ZEND_RE
ZEND_ARG_INFO(0, stopSequence)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(Mustache__compile_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
ZEND_ARG_INFO(0, tmpl)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(Mustache__execute_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
ZEND_ARG_INFO(0, code)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(Mustache__parse_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
ZEND_ARG_INFO(0, tmpl)
ZEND_END_ARG_INFO()
Expand Down Expand Up @@ -74,8 +65,6 @@ static zend_function_entry Mustache_methods[] = {
PHP_ME(Mustache, setEscapeByDefault, Mustache__setEscapeByDefault_args, ZEND_ACC_PUBLIC)
PHP_ME(Mustache, setStartSequence, Mustache__setStartSequence_args, ZEND_ACC_PUBLIC)
PHP_ME(Mustache, setStopSequence, Mustache__setStopSequence_args, ZEND_ACC_PUBLIC)
PHP_ME(Mustache, compile, Mustache__compile_args, ZEND_ACC_PUBLIC)
PHP_ME(Mustache, execute, Mustache__execute_args, ZEND_ACC_PUBLIC)
PHP_ME(Mustache, parse, Mustache__parse_args, ZEND_ACC_PUBLIC)
PHP_ME(Mustache, render, Mustache__render_args, ZEND_ACC_PUBLIC)
PHP_ME(Mustache, tokenize, Mustache__tokenize_args, ZEND_ACC_PUBLIC)
Expand Down Expand Up @@ -586,99 +575,6 @@ PHP_METHOD(Mustache, setStopSequence)
}
/* }}} Mustache::setStartSequence */

/* {{{ proto MustacheCode Mustache::compile(string template) */
PHP_METHOD(Mustache, compile)
{
try {
// Custom parameters
zval * tmpl = NULL;
zval * partials = NULL;

// Check parameters
zval * _this_zval = NULL;
if( zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), (char *) "Oz|z",
&_this_zval, Mustache_ce_ptr, &tmpl, &partials) == FAILURE) {
throw PhpInvalidParameterException();
}

// Class parameters
_this_zval = getThis();
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Prepare template tree
mustache::Node templateNode;
mustache::Node * templateNodePtr = &templateNode;
if( !mustache_parse_template_param(tmpl, payload->mustache, &templateNodePtr TSRMLS_CC) ) {
RETURN_FALSE;
return;
}

// Prepare partials
mustache::Node::Partials templatePartials;
mustache_parse_partials_param(partials, payload->mustache, &templatePartials TSRMLS_CC);

// Compile
uint8_t * codes;
size_t codes_length;
payload->mustache->compile(templateNodePtr, &templatePartials, &codes, &codes_length);

// Initialize new object
object_init_ex(return_value, MustacheCode_ce_ptr);
zend_update_property_stringl(MustacheCode_ce_ptr, return_value,
"binaryString", sizeof("binaryString") - 1, (char *) codes, codes_length TSRMLS_CC);

} catch(...) {
mustache_exception_handler(TSRMLS_C);
}
}
/* }}} Mustache::compile */

/* {{{ proto string Mustache::execute(MustacheCode code) */
PHP_METHOD(Mustache, execute)
{
try {
// Custom parameters
zval * code = NULL;
zval * data = NULL;

// Check parameters
zval * _this_zval = NULL;
if( zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), (char *) "OOz",
&_this_zval, Mustache_ce_ptr, &code, MustacheCode_ce_ptr, &data) == FAILURE) {
throw PhpInvalidParameterException();
}

// Class parameters
_this_zval = getThis();
struct php_obj_Mustache * payload = php_mustache_mustache_object_fetch_object(_this_zval TSRMLS_CC);

// Prepare code
zval rv;
zval * value = _zend_read_property(Z_OBJCE_P(code), code, "binaryString", sizeof("binaryString")-1, 1, &rv);
if( !value || Z_TYPE_P(value) != IS_STRING ) {
throw PhpInvalidParameterException();
}

// Prepare template data
mustache::Data templateData;
mustache::Data * templateDataPtr = &templateData;
if( !mustache_parse_data_param(data, payload->mustache, &templateDataPtr TSRMLS_CC) ) {
RETURN_FALSE;
}

// Execute bytecode
std::string output;
payload->mustache->execute((uint8_t *) Z_STRVAL_P(value), Z_STRLEN_P(value), templateDataPtr, &output);

// Output
_RETVAL_STRINGL(output.c_str(), output.length());

} catch(...) {
mustache_exception_handler(TSRMLS_C);
}
}
/* }}} Mustache::execute */

/* {{{ proto MustacheAST Mustache::parse(string template) */
PHP_METHOD(Mustache, parse)
{
Expand Down
2 changes: 0 additions & 2 deletions mustache_mustache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ PHP_METHOD(Mustache, getStopSequence);
PHP_METHOD(Mustache, setEscapeByDefault);
PHP_METHOD(Mustache, setStartSequence);
PHP_METHOD(Mustache, setStopSequence);
PHP_METHOD(Mustache, compile);
PHP_METHOD(Mustache, execute);
PHP_METHOD(Mustache, parse);
PHP_METHOD(Mustache, render);
PHP_METHOD(Mustache, tokenize);
Expand Down
6 changes: 0 additions & 6 deletions php_mustache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "php_mustache.h"
#include "php5to7.h"
#include "mustache_ast.hpp"
#include "mustache_code.hpp"
#include "mustache_exceptions.hpp"
#include "mustache_mustache.hpp"
#include "mustache_data.hpp"
Expand All @@ -32,7 +31,6 @@ static PHP_MINIT_FUNCTION(mustache)
REGISTER_INI_ENTRIES();
PHP_MINIT(mustache_ast)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(mustache_code)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(mustache_mustache)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(mustache_data)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(mustache_template)(INIT_FUNC_ARGS_PASSTHRU);
Expand All @@ -55,17 +53,13 @@ static PHP_MSHUTDOWN_FUNCTION(mustache)
/* {{{ PHP_MINFO_FUNCTION */
static PHP_MINFO_FUNCTION(mustache)
{
char opsize[3];
snprintf(opsize, 3, "%d", _C_OP_SIZE);
php_info_print_table_start();
php_info_print_table_row(2, "Version", PHP_MUSTACHE_VERSION);
php_info_print_table_row(2, "Released", PHP_MUSTACHE_RELEASE);
php_info_print_table_row(2, "Revision", PHP_MUSTACHE_BUILD);
php_info_print_table_row(2, "Authors", PHP_MUSTACHE_AUTHORS);
php_info_print_table_row(2, "Spec Version", PHP_MUSTACHE_SPEC);
php_info_print_table_row(2, "Libmustache Version", mustache_version());
php_info_print_table_row(2, "Libmustache Operand Size", opsize);
#if MUSTACHE_HAVE_CXX11
php_info_print_table_row(2, "c++11 unordered map support", "enabled");
#else
Expand Down
15 changes: 0 additions & 15 deletions tests/MustacheCode____construct.phpt

This file was deleted.

Loading

0 comments on commit 14cb7c9

Please sign in to comment.