Permalink
Browse files

[indexer] update code base

  • Loading branch information...
chobie committed Jan 15, 2014
1 parent bc11496 commit 384367d90ad58453bc6a24cbc27b3e532d3d865b
Showing with 92 additions and 71 deletions.
  1. +76 −59 indexer.c
  2. +13 −12 indexer.h
  3. +1 −0 ng.php
  4. +2 −0 php_git2.h
View
135 indexer.c
@@ -2,102 +2,119 @@
#include "php_git2_priv.h"
#include "indexer.h"
/* {{{ proto resource git_indexer_new(path, mode, odb, progress_cb, progress_cb_payload)
*/
/* {{{ proto resource git_indexer_new(string $path, long $mode, resource $odb, $progress_cb, $progress_cb_payload)
*/
PHP_FUNCTION(git_indexer_new)
{
char *path = {0};
int path_len;
long mode;
zval *odb;
php_git2_t *_odb;
zval *progress_cb;
php_git2_t *_progress_cb;
php_git2_t *result = NULL, *_odb = NULL;
git_indexer *out = NULL;
char *path = NULL;
int path_len = 0, error = 0;
long mode = 0;
zval *odb = NULL, *progress_cb = NULL, *progress_cb_payload = NULL;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
php_git2_cb_t *cb = NULL;
/* TODO(chobie): implement this */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "git_indexer_new not implemented yet");
return;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"slrfz", &path, &path_len, &mode, &odb, &fci, &fcc, &progress_cb_payload) == FAILURE) {
return;
}
// if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
// "slrr", &path, &path_len, &mode, &odb, &progress_cb, &progress_cb_payload) == FAILURE) {
// return;
// }
// ZEND_FETCH_RESOURCE(_path, php_git2_t*, &path, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
ZEND_FETCH_RESOURCE(_odb, php_git2_t*, &odb, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
if (php_git2_cb_init(&cb, &fci, &fcc, progress_cb_payload TSRMLS_CC)) {
RETURN_FALSE;
}
//error = git_indexer_new(&out, path, mode, PHP_GIT2_V(_odb, odb), progress_cb, cb);
if (php_git2_check_error(error, "git_indexer_new" TSRMLS_CC)) {
RETURN_FALSE;
}
if (php_git2_make_resource(&result, PHP_GIT2_TYPE_INDEXER, out, 1 TSRMLS_CC)) {
RETURN_FALSE;
}
ZVAL_RESOURCE(return_value, GIT2_RVAL_P(result));
}
/* }}} */
/* {{{ proto long git_indexer_append(idx, data, size, stats)
*/
/* {{{ proto long git_indexer_append(resource $idx, $data, long $size, $stats)
*/
PHP_FUNCTION(git_indexer_append)
{
zval *idx;
php_git2_t *_idx;
zval *stats;
php_git2_t *_stats;
/* TODO(chobie): implement this */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "git_indexer_append not implemented yet");
return;
int result = 0, error = 0;
zval *idx = NULL, *stats = NULL;
php_git2_t *_idx = NULL;
zval *data = NULL;
long size = 0;
// if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
// "rr", &idx, &data, &size, &stats) == FAILURE) {
// "r<void>l<git_transfer_progress>", &idx, &data, &size, &stats) == FAILURE) {
// return;
// }
//
// ZEND_FETCH_RESOURCE(_idx, php_git2_t*, &idx, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
// result = git_indexer_append(PHP_GIT2_V(_idx, indexer), data, size, stats);
// RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_indexer_commit(idx, stats)
*/
/* {{{ proto long git_indexer_commit(resource $idx, $stats)
*/
PHP_FUNCTION(git_indexer_commit)
{
zval *idx;
php_git2_t *_idx;
zval *stats;
php_git2_t *_stats;
/* TODO(chobie): implement this */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "git_indexer_commit not implemented yet");
return;
int result = 0, error = 0;
zval *idx = NULL, *stats = NULL;
php_git2_t *_idx = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rr", &idx, &stats) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_idx, php_git2_t*, &idx, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
// if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
// "r<git_transfer_progress>", &idx, &stats) == FAILURE) {
// return;
// }
//
// ZEND_FETCH_RESOURCE(_idx, php_git2_t*, &idx, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
// result = git_indexer_commit(PHP_GIT2_V(_idx, indexer), stats);
// RETURN_LONG(result);
}
/* }}} */
/* {{{ proto resource git_indexer_hash(idx)
*/
/* {{{ proto resource git_indexer_hash(resource $idx)
*/
PHP_FUNCTION(git_indexer_hash)
{
zval *idx;
php_git2_t *_idx;
/* TODO(chobie): implement this */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "git_indexer_hash not implemented yet");
return;
const git_oid *result = NULL;
zval *idx = NULL;
php_git2_t *_idx = NULL;
char __result[GIT2_OID_HEXSIZE] = {0};
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &idx) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_idx, php_git2_t*, &idx, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
result = git_indexer_hash(PHP_GIT2_V(_idx, indexer));
git_oid_fmt(__result, result);
RETURN_STRING(__result, 1);
}
/* }}} */
/* {{{ proto void git_indexer_free(idx)
*/
/* {{{ proto void git_indexer_free(resource $idx)
*/
PHP_FUNCTION(git_indexer_free)
{
zval *idx;
php_git2_t *_idx;
/* TODO(chobie): implement this */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "git_indexer_free not implemented yet");
return;
zval *idx = NULL;
php_git2_t *_idx = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &idx) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_idx, php_git2_t*, &idx, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
if (GIT2_SHOULD_FREE(_idx)) {
git_indexer_free(PHP_GIT2_V(_idx, indexer));
GIT2_SHOULD_FREE(_idx) = 0;
};
zval_ptr_dtor(&idx);
}
/* }}} */
View
@@ -26,7 +26,8 @@
#ifndef PHP_GIT2_INDEXER_H
#define PHP_GIT2_INDEXER_H
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_indexer_new, 0, 0, 5)
ZEND_BEGIN_ARG_INFO_EX(arginfo_git_indexer_new, 0, 0, 6)
ZEND_ARG_INFO(0, out)
ZEND_ARG_INFO(0, path)
ZEND_ARG_INFO(0, mode)
ZEND_ARG_INFO(0, odb)
@@ -54,24 +55,24 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_git_indexer_free, 0, 0, 1)
ZEND_ARG_INFO(0, idx)
ZEND_END_ARG_INFO()
/* {{{ proto resource git_indexer_new(path, mode, odb, progress_cb, progress_cb_payload)
*/
/* {{{ proto resource git_indexer_new(string $path, long $mode, resource $odb, $progress_cb, $progress_cb_payload)
*/
PHP_FUNCTION(git_indexer_new);
/* {{{ proto long git_indexer_append(idx, data, size, stats)
*/
/* {{{ proto long git_indexer_append(resource $idx, $data, long $size, $stats)
*/
PHP_FUNCTION(git_indexer_append);
/* {{{ proto long git_indexer_commit(idx, stats)
*/
/* {{{ proto long git_indexer_commit(resource $idx, $stats)
*/
PHP_FUNCTION(git_indexer_commit);
/* {{{ proto resource git_indexer_hash(idx)
*/
/* {{{ proto resource git_indexer_hash(resource $idx)
*/
PHP_FUNCTION(git_indexer_hash);
/* {{{ proto void git_indexer_free(idx)
*/
/* {{{ proto void git_indexer_free(resource $idx)
*/
PHP_FUNCTION(git_indexer_free);
#endif
#endif
View
1 ng.php
@@ -407,6 +407,7 @@ public function shouldResource(Arg $arg)
"git_push",
"git_refspec",
"git_filter",
"git_indexer",
);
}
View
@@ -125,6 +125,7 @@ enum php_git2_resource_type {
PHP_GIT2_TYPE_SUBMODULE,
PHP_GIT2_TYPE_PUSH,
PHP_GIT2_TYPE_REFSPEC,
PHP_GIT2_TYPE_INDEXER,
};
typedef struct php_git2_t {
@@ -177,6 +178,7 @@ typedef struct php_git2_t {
git_submodule *submodule;
git_push *push;
git_refspec *refspec;
git_indexer *indexer;
} v;
int should_free_v;
int resource_id;

0 comments on commit 384367d

Please sign in to comment.