-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,103 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the sj-i/php-profiler package. | ||
* | ||
* (c) sji <sji@sj-i.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpProfiler\Lib\FFI; | ||
|
||
use FFI\CData; | ||
use FFI\CInteger; | ||
use FFI\CPointer; | ||
|
||
class Cast | ||
{ | ||
/** @param CPointer $cdata */ | ||
public static function castPointerToInt(CData &$cdata): int | ||
{ | ||
/** @var CInteger $casted */ | ||
$casted = \FFI::cast('long', $cdata); | ||
return $casted->cdata; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the sj-i/php-profiler package. | ||
* | ||
* (c) sji <sji@sj-i.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpProfiler\Lib\PhpInternals\Types\C; | ||
|
||
use FFI\CInteger; | ||
use PhpProfiler\Lib\PhpInternals\CastedCData; | ||
use PhpProfiler\Lib\Process\Pointer\Dereferencable; | ||
use PhpProfiler\Lib\Process\Pointer\Pointer; | ||
|
||
final class RawInt32 implements Dereferencable | ||
{ | ||
public int $value; | ||
|
||
/** @param CastedCData<CInteger> $casted_cdata */ | ||
public function __construct( | ||
private CastedCData $casted_cdata, | ||
) { | ||
$this->value = $this->casted_cdata->casted->cdata; | ||
} | ||
|
||
public static function getCTypeName(): string | ||
{ | ||
return 'int32_t'; | ||
} | ||
|
||
public static function fromCastedCData( | ||
CastedCData $casted_cdata, | ||
Pointer $pointer | ||
): static { | ||
/** @var CastedCData<CInteger> $casted_cdata */ | ||
return new self($casted_cdata); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the sj-i/php-profiler package. | ||
* | ||
* (c) sji <sji@sj-i.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpProfiler\Lib\PhpInternals\Types\Zend; | ||
|
||
use FFI\PhpInternals\Bucket as ZendBucket; | ||
use PhpProfiler\Lib\PhpInternals\CastedCData; | ||
use PhpProfiler\Lib\Process\Pointer\Dereferencable; | ||
use PhpProfiler\Lib\Process\Pointer\Pointer; | ||
|
||
final class Bucket implements Dereferencable | ||
{ | ||
/** @psalm-suppress PropertyNotSetInConstructor */ | ||
public Zval $val; | ||
/** @psalm-suppress PropertyNotSetInConstructor */ | ||
public int $h; | ||
/** | ||
* @psalm-suppress PropertyNotSetInConstructor | ||
* @var Pointer<ZendString> | ||
*/ | ||
public Pointer $key; | ||
|
||
/** @param CastedCData<ZendBucket> $casted_cdata */ | ||
public function __construct( | ||
private CastedCData $casted_cdata, | ||
) { | ||
unset($this->val); | ||
unset($this->h); | ||
unset($this->key); | ||
} | ||
|
||
public function __get(string $field_name): mixed | ||
{ | ||
return match ($field_name) { | ||
'val' => $this->val = new Zval($this->casted_cdata->casted->val), | ||
'h' => $this->h = 0xFFFF_FFFF & $this->casted_cdata->casted->h, | ||
'key' => $this->key = Pointer::fromCData( | ||
ZendString::class, | ||
$this->casted_cdata->casted->key | ||
), | ||
}; | ||
} | ||
|
||
public static function getCTypeName(): string | ||
{ | ||
return 'Bucket'; | ||
} | ||
|
||
public static function fromCastedCData( | ||
CastedCData $casted_cdata, | ||
Pointer $pointer | ||
): static { | ||
/** @var CastedCData<ZendBucket> $casted_cdata */ | ||
return new self($casted_cdata); | ||
} | ||
} |
Oops, something went wrong.