Skip to content

Commit

Permalink
Generate class entries via stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
Girgias committed Sep 22, 2021
1 parent 91f961d commit 33ec919
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 27 deletions.
1 change: 1 addition & 0 deletions Zend/zend_exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern ZEND_API zend_class_entry *zend_ce_value_error;
extern ZEND_API zend_class_entry *zend_ce_arithmetic_error;
extern ZEND_API zend_class_entry *zend_ce_division_by_zero_error;
extern ZEND_API zend_class_entry *zend_ce_unhandled_match_error;
extern ZEND_API zend_class_entry *zend_ce_io;

ZEND_API void zend_exception_set_previous(zend_object *exception, zend_object *add_previous);
ZEND_API void zend_exception_save(void);
Expand Down
32 changes: 7 additions & 25 deletions ext/standard/io_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,17 @@ PHPAPI zend_class_entry *zend_ce_insufficient_permissions;
PHPAPI zend_class_entry *zend_ce_temporary_failure;

PHP_MINIT_FUNCTION(io_exceptions) {
zend_class_entry ce;

/* Register interfaces */
INIT_CLASS_ENTRY(ce, "FileSystem", class_FileSystem_methods);
zend_ce_filesystem = zend_register_internal_interface(&ce);

INIT_CLASS_ENTRY(ce, "Network", class_Network_methods);
zend_ce_network = zend_register_internal_interface(&ce);
zend_ce_filesystem = register_class_FileSystem(zend_ce_io);
zend_ce_network = register_class_Network(zend_ce_io);

/* Register exceptions */
INIT_CLASS_ENTRY(ce, "FileSystemError", class_FileSystemError_methods);
zend_ce_filesystem_error = zend_register_internal_class_ex(&ce, zend_ce_exception);
zend_class_implements(zend_ce_filesystem_error, 1, zend_ce_filesystem);

INIT_CLASS_ENTRY(ce, "FileNotFound", class_FileNotFound_methods);
zend_ce_file_not_found = zend_register_internal_class_ex(&ce, zend_ce_exception);
zend_class_implements(zend_ce_file_not_found, 1, zend_ce_filesystem);

INIT_CLASS_ENTRY(ce, "NotDirectory", class_FileNotFound_methods);
zend_ce_not_directory = zend_register_internal_class_ex(&ce, zend_ce_exception);
zend_class_implements(zend_ce_not_directory, 1, zend_ce_filesystem);

INIT_CLASS_ENTRY(ce, "InsufficientPermissions", class_InsufficientPermissions_methods);
zend_ce_insufficient_permissions = zend_register_internal_class_ex(&ce, zend_ce_exception);
zend_class_implements(zend_ce_insufficient_permissions, 1, zend_ce_filesystem);
zend_ce_filesystem_error = register_class_FileSystemError(zend_ce_exception, zend_ce_filesystem);
zend_ce_file_not_found = register_class_FileNotFound(zend_ce_exception, zend_ce_filesystem);
zend_ce_not_directory = register_class_NotDirectory(zend_ce_exception, zend_ce_filesystem);
zend_ce_insufficient_permissions = register_class_InsufficientPermissions(zend_ce_exception, zend_ce_filesystem);

INIT_CLASS_ENTRY(ce, "TemporaryFailure", class_TemporaryFailure_methods);
zend_ce_temporary_failure = zend_register_internal_class_ex(&ce, zend_ce_exception);
zend_class_implements(zend_ce_temporary_failure, 1, zend_ce_network);
zend_ce_temporary_failure = register_class_TemporaryFailure(zend_ce_exception, zend_ce_network);

return SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/io_exceptions.stub.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/** @generate-function-entries */
/** @generate-class-entries */

interface FileSystem extends IO {}

Expand Down
79 changes: 78 additions & 1 deletion ext/standard/io_exceptions_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: c4ecc9d6fb58a424dc63d5c5a039843b89273142 */
* Stub hash: a253c10f25a4e0cd8243881a3144a4f913c4b38f */



Expand Down Expand Up @@ -37,3 +37,80 @@ static const zend_function_entry class_InsufficientPermissions_methods[] = {
static const zend_function_entry class_TemporaryFailure_methods[] = {
ZEND_FE_END
};

static zend_class_entry *register_class_FileSystem(zend_class_entry *class_entry_IO)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "FileSystem", class_FileSystem_methods);
class_entry = zend_register_internal_interface(&ce);
zend_class_implements(class_entry, 1, class_entry_IO);

return class_entry;
}

static zend_class_entry *register_class_Network(zend_class_entry *class_entry_IO)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "Network", class_Network_methods);
class_entry = zend_register_internal_interface(&ce);
zend_class_implements(class_entry, 1, class_entry_IO);

return class_entry;
}

static zend_class_entry *register_class_FileSystemError(zend_class_entry *class_entry_Exception, zend_class_entry *class_entry_FileSystem)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "FileSystemError", class_FileSystemError_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
zend_class_implements(class_entry, 1, class_entry_FileSystem);

return class_entry;
}

static zend_class_entry *register_class_FileNotFound(zend_class_entry *class_entry_Exception, zend_class_entry *class_entry_FileSystem)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "FileNotFound", class_FileNotFound_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
zend_class_implements(class_entry, 1, class_entry_FileSystem);

return class_entry;
}

static zend_class_entry *register_class_NotDirectory(zend_class_entry *class_entry_Exception, zend_class_entry *class_entry_FileSystem)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "NotDirectory", class_NotDirectory_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
zend_class_implements(class_entry, 1, class_entry_FileSystem);

return class_entry;
}

static zend_class_entry *register_class_InsufficientPermissions(zend_class_entry *class_entry_Exception, zend_class_entry *class_entry_FileSystem)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "InsufficientPermissions", class_InsufficientPermissions_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
zend_class_implements(class_entry, 1, class_entry_FileSystem);

return class_entry;
}

static zend_class_entry *register_class_TemporaryFailure(zend_class_entry *class_entry_Exception, zend_class_entry *class_entry_Network)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "TemporaryFailure", class_TemporaryFailure_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
zend_class_implements(class_entry, 1, class_entry_Network);

return class_entry;
}

0 comments on commit 33ec919

Please sign in to comment.