Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5021078

Browse files
authored
provide access to return_value, function's type, filename, line number (#217)
1 parent7902372 commit5021078

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

‎phper/src/functions.rs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,29 @@ impl ZFunc {
647647
}
648648
}
649649

650+
/// Get the type of the function (sys::ZEND_USER_FUNCTION,
651+
/// sys::ZEND_INTERNAL_FUNCTION, or sys::ZEND_EVAL_CODE).
652+
pubfnget_type(&self) ->u32{
653+
unsafe{self.inner.type_asu32}
654+
}
655+
656+
/// For a user function or eval'd code, get the filename from op_array.
657+
pubfnget_filename(&self) ->Option<&ZStr>{
658+
unsafe{
659+
match u32::from(self.inner.type_){
660+
ZEND_USER_FUNCTION |ZEND_EVAL_CODE =>{
661+
let ptr =self.inner.op_array.filename;
662+
if ptr.is_null(){
663+
None
664+
}else{
665+
ZStr::try_from_ptr(ptr)
666+
}
667+
}
668+
_ =>None,
669+
}
670+
}
671+
}
672+
650673
/// Get the function or method fully-qualified name.
651674
pubfnget_function_or_method_name(&self) ->ZString{
652675
unsafe{

‎phper/src/values.rs‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,51 @@ impl ExecuteData {
130130
unsafe{ZFunc::from_mut_ptr(self.inner.func)}
131131
}
132132

133+
/// Gets the current opline line number if available. This represents the
134+
/// line number in the source code where the current operation is being
135+
/// executed.
136+
pubfnget_lineno(&self) ->Option<u32>{
137+
unsafe{
138+
match u32::from((*self.inner.func).type_){
139+
ZEND_USER_FUNCTION |ZEND_EVAL_CODE =>{
140+
let opline =self.inner.opline;
141+
if opline.is_null(){
142+
None
143+
}else{
144+
Some((*opline).lineno)
145+
}
146+
}
147+
_ =>None,
148+
}
149+
}
150+
}
151+
152+
/// Gets associated return value.
153+
pubfnget_return_value(&self) ->Option<&ZVal>{
154+
unsafe{
155+
let val =self.inner.return_value;
156+
ZVal::try_from_ptr(val)
157+
}
158+
}
159+
160+
/// Gets mutable reference to associated return value.
161+
pubfnget_return_value_mut(&mutself) ->Option<&mutZVal>{
162+
unsafe{
163+
let val =self.inner.return_value;
164+
ZVal::try_from_mut_ptr(val)
165+
}
166+
}
167+
168+
/// Gets associated return value pointer.
169+
pubfnget_return_value_mut_ptr(&mutself) ->*mutZVal{
170+
self.inner.return_valueas*mutZVal
171+
}
172+
173+
/// Gets immutable pointer to associated return value.
174+
pubfnget_return_value_ptr(&self) ->*constZVal{
175+
self.inner.return_valueas*constZVal
176+
}
177+
133178
/// Gets associated `$this` object if exists.
134179
pubfnget_this(&mutself) ->Option<&ZObj>{
135180
unsafe{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp