Skip to content

Commit

Permalink
add CodeTips & update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeke committed Mar 29, 2018
1 parent 304b6f4 commit d645b1e
Show file tree
Hide file tree
Showing 4 changed files with 279 additions and 4 deletions.
90 changes: 90 additions & 0 deletions CodeTips/JsonNetCodeTips.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/**
* @author [email protected]
* Date: 18/3/29 下午7:51
*/

const JSONNET_PHP_VERSION = 'v1.3.0';
const JSONNET_PHP_AUTHOR = '[email protected]';

const CODE_SUCCESS = 1000;
const CODE_ERROR = 900;

/**
* @return string
*/
function jsonnet_get_version()
{
return JSONNET_PHP_VERSION;
}

function jsonnet_get_author()
{
return JSONNET_PHP_AUTHOR;
}

class JsonNet
{
public function __construct()
{
#JsonNet init
}

public function __destruct()
{
#JsonNet destroy
}

/**
* @param $file_path
*
* @return array
* @throws Exception
*/
static public function evaluateFile($file_path)
{
throw new Exception('JsonNet::evaluateFile #error', CODE_ERROR);

return array();
}

/**
* @param $snippet_string
*
* @return array
* @throws Exception
*/
static public function evaluateSnippet($snippet_string)
{
throw new Exception('JsonNet::evaluateSnippet #error', CODE_ERROR);

return array();
}

/**
* @param $file_path
*
* @return array
* @throws Exception
*/
static public function fmtFile($file_path)
{
throw new Exception('JsonNet::fmtFile #error', CODE_ERROR);

return array();
}

/**
* @param $snippet_string
*
* @return array
* @throws Exception
*/
static public function fmtSnippet($snippet_string)
{
throw new Exception('JsonNet::fmtSnippet #error', CODE_ERROR);

return array();
}

}
166 changes: 166 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,170 @@ or

var_dump(JsonNet::evaluateSnippet($Snippet));

```

### PHP Re Result
```
/usr/local/php/php-7.0.6-zts-debug/bin/php --re jsonnet
Extension [ <persistent> extension #40 JsonNet version v1.3.0 ] {
- Constants [2] {
Constant [ string JSONNET_PHP_VERSION ] { v1.3.0 }
Constant [ string JSONNET_PHP_AUTHOR ] { Chitao.Gao [ [email protected] ] }
}
- Functions {
Function [ <internal:JsonNet> function jsonnet_get_version ] {
}
Function [ <internal:JsonNet> function jsonnet_get_author ] {
}
}
- Classes [1] {
Class [ <internal:JsonNet> class JsonNet ] {
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [4] {
Method [ <internal:JsonNet> static public method evaluateFile ] {
- Parameters [1] {
Parameter #0 [ <required> $file_path ]
}
}
Method [ <internal:JsonNet> static public method evaluateSnippet ] {
- Parameters [1] {
Parameter #0 [ <required> $snippet_string ]
}
}
Method [ <internal:JsonNet> static public method fmtFile ] {
- Parameters [1] {
Parameter #0 [ <required> $file_path ]
}
}
Method [ <internal:JsonNet> static public method fmtSnippet ] {
- Parameters [1] {
Parameter #0 [ <required> $snippet_string ]
}
}
}
- Properties [0] {
}
- Methods [2] {
Method [ <internal:JsonNet, ctor> public method __construct ] {
}
Method [ <internal:JsonNet, dtor> public method __destruct ] {
}
}
}
}
}
```

###CodeTips
```
<?php
/**
* @author [email protected]
* Date: 18/3/29 下午7:51
*/
const JSONNET_PHP_VERSION = 'v1.3.0';
const JSONNET_PHP_AUTHOR = '[email protected]';
const CODE_SUCCESS = 1000;
const CODE_ERROR = 900;
/**
* @return string
*/
function jsonnet_get_version()
{
return JSONNET_PHP_VERSION;
}
function jsonnet_get_author()
{
return JSONNET_PHP_AUTHOR;
}
class JsonNet
{
public function __construct()
{
#JsonNet init
}
public function __destruct()
{
#JsonNet destroy
}
/**
* @param $file_path
*
* @return array
* @throws Exception
*/
static public function evaluateFile($file_path)
{
throw new Exception('JsonNet::evaluateFile #error', CODE_ERROR);
return array();
}
/**
* @param $snippet_string
*
* @return array
* @throws Exception
*/
static public function evaluateSnippet($snippet_string)
{
throw new Exception('JsonNet::evaluateSnippet #error', CODE_ERROR);
return array();
}
/**
* @param $file_path
*
* @return array
* @throws Exception
*/
static public function fmtFile($file_path)
{
throw new Exception('JsonNet::fmtFile #error', CODE_ERROR);
return array();
}
/**
* @param $snippet_string
*
* @return array
* @throws Exception
*/
static public function fmtSnippet($snippet_string)
{
throw new Exception('JsonNet::fmtSnippet #error', CODE_ERROR);
return array();
}
}
```
24 changes: 20 additions & 4 deletions jsonnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,31 @@ const zend_function_entry jsonnet_functions[] =
}
};

ZEND_BEGIN_ARG_INFO_EX(jsonnet_evaluateFile_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, file_path)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(jsonnet_evaluateSnippet_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, snippet_string)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(jsonnet_fmtFile_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, file_path)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(jsonnet_fmtSnippet_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, snippet_string)
ZEND_END_ARG_INFO()

const zend_function_entry jsonnet_methods[] =
{
PHP_ME(JSONNET_RES_NAME, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(JSONNET_RES_NAME, __destruct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR)

PHP_ME(JSONNET_RES_NAME, evaluateFile, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(JSONNET_RES_NAME, evaluateSnippet, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(JSONNET_RES_NAME, fmtFile, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(JSONNET_RES_NAME, fmtSnippet, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(JSONNET_RES_NAME, evaluateFile, jsonnet_evaluateFile_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(JSONNET_RES_NAME, evaluateSnippet, jsonnet_evaluateSnippet_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(JSONNET_RES_NAME, fmtFile, jsonnet_fmtFile_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(JSONNET_RES_NAME, fmtSnippet, jsonnet_fmtSnippet_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)

{
NULL, NULL, NULL
Expand Down
3 changes: 3 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<file role="src" name="Jsonnet.h"/>
<file role="src" name="php7_wrapper.h"/>
</dir>
<dir name="CodeTips">
<file role="src" name="JsonNetCodeTips.php"/>
</dir>
<dir name="test">
<file role="src" name="bar_menu.1.jsonnet"/>
<file role="src" name="bar_menu.2.jsonnet"/>
Expand Down

0 comments on commit d645b1e

Please sign in to comment.