1+ /*
2+ * The MIT License
3+ *
4+ * Copyright (c) 2010 - 2012 Shuhei Tanuma
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+ * THE SOFTWARE.
23+ */
24+
25+ #include "php_git2.h"
26+
27+ PHPAPI zend_class_entry * git2_index_class_entry ;
28+
29+ static void php_git2_index_free_storage (php_git2_index * object TSRMLS_DC )
30+ {
31+ if (object -> index != NULL ) {
32+ object -> index = NULL ;
33+ }
34+ zend_object_std_dtor (& object -> zo TSRMLS_CC );
35+ efree (object );
36+ }
37+
38+ zend_object_value php_git2_index_new (zend_class_entry * ce TSRMLS_DC )
39+ {
40+ zend_object_value retval ;
41+
42+ PHP_GIT2_STD_CREATE_OBJECT (php_git2_index );
43+ return retval ;
44+ }
45+
46+ ZEND_BEGIN_ARG_INFO_EX (arginfo_git2_index___construct , 0 ,0 ,1 )
47+ ZEND_ARG_INFO (0 , entry )
48+ ZEND_END_ARG_INFO ()
49+
50+ /*
51+ {{{ proto: Git2\Index::__construct(string $path)
52+ */
53+ PHP_METHOD (git2_index , __construct )
54+ {
55+ char * path ;
56+ git_index * index ;
57+ int error , path_len = 0 ;
58+ php_git2_index * m_index ;
59+
60+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
61+ "s" , & path , & path_len ) == FAILURE ) {
62+ return ;
63+ }
64+
65+ error = git_index_open (& index , path );
66+ m_index = PHP_GIT2_GET_OBJECT (php_git2_index , getThis ());
67+ m_index -> index = index ;
68+ }
69+ /* }}} */
70+
71+
72+
73+ static zend_function_entry php_git2_index_methods [] = {
74+ PHP_ME (git2_index , __construct , arginfo_git2_index___construct , ZEND_ACC_PUBLIC )
75+ {NULL ,NULL ,NULL }
76+ };
77+
78+ void php_git2_index_init (TSRMLS_D )
79+ {
80+ zend_class_entry ce ;
81+
82+ INIT_NS_CLASS_ENTRY (ce , PHP_GIT2_NS , "Index" , php_git2_index_methods );
83+ git2_index_class_entry = zend_register_internal_class (& ce TSRMLS_CC );
84+ git2_index_class_entry -> create_object = php_git2_index_new ;
85+ }
0 commit comments