Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
php-git2/php-object.cpp at master · RogerGee/php-git2 · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
RogerGee
php-git2
Repository navigation
Code
Issues
1
(1)
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
php-git2
/
php-object.cpp
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
207 lines (164 loc) · 6.67 KB
master
Breadcrumbs
php-git2
/
php-object.cpp
Copy path
Top
File metadata and controls
Code
Blame
207 lines (164 loc) · 6.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
* php-object.cpp
*
* Copyright (C) Roger P. Gee
*
* This unit provides the generic class registration for classes we wish to
* provide to PHP userspace. The classes' methods and handlers are defined in
* their own separate compilation units.
*/
#
include
"
php-object.h
"
#
include
"
php-type.h
"
using
namespace
php_git2
;
//
Provide generic versions of the custom zend_object derivation create/free
//
handlers.
template
<
typename
StorageType>
static
zend_object*
php_create_object_handler
(zend_class_entry* ce)
{
using
php_object_t
= php_zend_object<StorageType>;
php_object_t
* object;
//
TODO Update to use zend_object_alloc().
const
size_t
nbytes =
sizeof
(
php_object_t
) +
zend_object_properties_size
(ce);
object =
new
(
emalloc
(nbytes))
php_object_t
(ce);
return
&object->
std
;
}
template
<
typename
StorageType>
static
zend_object*
php_clone_object_handler
(zend_object* zobj)
{
zend_object* newObject;
zend_object* oldObject;
oldObject = zobj;
newObject = php_create_object_handler<StorageType>(oldObject->
ce
);
zend_objects_clone_members
(newObject,oldObject);
return
newObject;
}
template
<
typename
StorageType>
static
void
php_free_object
(zend_object* zo)
{
using
php_object_t
= php_zend_object<StorageType>;
php_object_t::get_wrapper
(zo)->
~php_object_t
();
}
template
<
typename
StorageType>
static
void
php_init_object_handlers
(zend_class_entry* ce)
{
using
php_object_t
= php_zend_object<StorageType>;
const
zend_object_handlers* stdhandlers =
zend_get_std_object_handlers
();
//
Store class entry for later global lookup and set create_object function.
php_git2::class_entry[
StorageType::get_type
()] = ce;
ce->
create_object
= &php_create_object_handler<StorageType>;
//
Initialize handlers.
memcpy
(&
php_object_t
::handlers,stdhandlers,
sizeof
(zend_object_handlers));
php_object_t
::handlers.
offset
=
php_object_t::offset
();
php_object_t
::handlers.
clone_obj
= php_clone_object_handler<StorageType>;
php_object_t
::handlers.
free_obj
= &php_free_object<StorageType>;
php_object_t::init
(ce);
}
//
Define the global list of class entry structure references.
zend_class_entry* php_git2::class_entry[_php_git2_obj_top_];
//
Define handlers for any type.
template
<
typename
StorageType>
zend_object_handlers php_git2::php_zend_object<StorageType>::handlers;
//
This function registers all classes. It should be called by the MINIT startup
//
function.
void
php_git2::php_git2_register_classes
()
{
zend_class_entry ce, *pce;
//
abstract class GitODBBackend
INIT_CLASS_ENTRY
(ce,
"
GitODBBackend
"
,odb_backend_methods);
pce =
zend_register_internal_class
(&ce);
pce->
ce_flags
|=
ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
;
php_init_object_handlers<php_odb_backend_object>(pce);
//
final class GitODBBackend_Internal extends GitODBBackend
INIT_CLASS_ENTRY
(ce,
"
GitODBBackend_Internal
"
,odb_backend_internal_methods);
pce =
zend_register_internal_class_ex
(&ce,
php_git2::class_entry[php_git2_odb_backend_obj]);
pce->
ce_flags
|=
ZEND_ACC_FINAL
;
php_init_object_handlers<php_odb_backend_internal_object>(pce);
//
abstract class GitODBWritepack
INIT_CLASS_ENTRY
(ce,
"
GitODBWritepack
"
,odb_writepack_methods);
pce =
zend_register_internal_class
(&ce);
pce->
ce_flags
|=
ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
;
php_init_object_handlers<php_odb_writepack_object>(pce);
//
final class GitODBWritepack_Internal extends GitODBWritepack
INIT_CLASS_ENTRY
(ce,
"
GitODBWritepack_Internal
"
,odb_writepack_internal_methods);
pce =
zend_register_internal_class_ex
(&ce,
php_git2::class_entry[php_git2_odb_writepack_obj]);
pce->
ce_flags
|=
ZEND_ACC_FINAL
;
php_init_object_handlers<php_odb_writepack_internal_object>(pce);
//
abstract class GitODBStream
INIT_CLASS_ENTRY
(ce,
"
GitODBStream
"
,odb_stream_methods);
pce =
zend_register_internal_class
(&ce);
pce->
ce_flags
|=
ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
;
php_init_object_handlers<php_odb_stream_object>(pce);
//
final class GitODBStream_Internal extends GitODBStream
INIT_CLASS_ENTRY
(ce,
"
GitODBStream_Internal
"
,odb_stream_internal_methods);
pce =
zend_register_internal_class_ex
(&ce,
php_git2::class_entry[php_git2_odb_stream_obj]);
pce->
ce_flags
|=
ZEND_ACC_FINAL
;
php_init_object_handlers<php_odb_stream_internal_object>(pce);
//
final class GitWritestream
INIT_CLASS_ENTRY
(ce,
"
GitWritestream
"
,writestream_methods);
pce =
zend_register_internal_class
(&ce);
pce->
ce_flags
|=
ZEND_ACC_FINAL
;
php_init_object_handlers<php_writestream_object>(pce);
//
abstract class GitConfigBackend
INIT_CLASS_ENTRY
(ce,
"
GitConfigBackend
"
,config_backend_methods);
pce =
zend_register_internal_class
(&ce);
pce->
ce_flags
|=
ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
;
php_init_object_handlers<php_config_backend_object>(pce);
//
abstract class GitRefDBBackend
INIT_CLASS_ENTRY
(ce,
"
GitRefDBBackend
"
,refdb_backend_methods);
pce =
zend_register_internal_class
(&ce);
pce->
ce_flags
|=
ZEND_ACC_EXPLICIT_ABSTRACT_CLASS
;
php_init_object_handlers<php_refdb_backend_object>(pce);
//
final class GitRefDBBackend_Internal extends GitRefDBBackend
INIT_CLASS_ENTRY
(ce,
"
GitRefDBBackend_Internal
"
,refdb_backend_internal_methods);
pce =
zend_register_internal_class_ex
(&ce,
php_git2::class_entry[php_git2_refdb_backend_obj]);
pce->
ce_flags
|=
ZEND_ACC_FINAL
;
php_init_object_handlers<php_refdb_backend_internal_object>(pce);
//
final class GitClosure
INIT_CLASS_ENTRY
(ce,
"
GitClosure
"
,closure_methods);
pce =
zend_register_internal_class
(&ce);
pce->
ce_flags
|=
ZEND_ACC_FINAL
;
php_init_object_handlers<php_closure_object>(pce);
}
//
Provide implementations for generic make function.
void
php_git2::php_git2_make_object
(zval* zp,
php_git2_object_t
type)
{
object_init_ex
(zp,php_git2::class_entry[type]);
}
//
Helpers
bool
php_git2::is_method_overridden
(zend_class_entry* ce,
const
char
* method,
int
len)
{
zval* func;
zend_function* fbc;
func =
zend_hash_str_find
(&ce->
function_table
,method,len);
if
(func ==
nullptr
) {
return
false
;
}
fbc =
Z_FUNC_P
(func);
//
The method is overridden if the prototype is defined.
return
(fbc->
common
.
prototype
!=
NULL
);
}
zend_function*
php_git2::not_allowed_get_constructor
(zend_object* object)
{
zend_throw_error
(
nullptr
,
"
Instantiation of '%s' is not allowed
"
,
ZSTR_VAL
(object->
ce
->
name
));
return
nullptr
;
}
zend_function*
php_git2::disallow_base_get_constructor
(zend_object* object)
{
if
(!object->
ce
->
parent
) {
return
not_allowed_get_constructor
(object);
}
return
object->
ce
->
constructor
;
}
/*
* Local Variables:
* indent-tabs-mode:nil
* tab-width:4
* End:
*/
You can’t perform that action at this time.