Skip to content

Commit

Permalink
Change 4 spaces to tab to follow the convention
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym committed Jul 10, 2024
1 parent 02e0b43 commit bc751fb
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 196 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_compile_definitions(HAVE_RAYAOP)

# `php-config` コマンドを使ってPHPのインクルードディレクトリを取得
# link https://cmake.org/cmake/help/latest/command/execute_process.html
execute_process (
execute_process(
COMMAND php-config --include-dir
OUTPUT_VARIABLE PHP_SOURCE
)
Expand Down
90 changes: 49 additions & 41 deletions php_rayaop.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* If PHP_RAYAOP_H is not defined, then define PHP_RAYAOP_H (header guard) */
#ifndef PHP_RAYAOP_H
#define PHP_RAYAOP_H
#ifndef PHP_RAYAOP_H
#define PHP_RAYAOP_H
/* If HAVE_CONFIG_H is defined, then include config.h */
#ifdef HAVE_CONFIG_H
#include "config.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h" /* Include PHP core header file */
#include "php_ini.h" /* Include PHP INI related header file */
Expand All @@ -12,33 +12,33 @@
#include "zend_interfaces.h" /* Include Zend interface related header */
/* If in thread-safe mode,
then, include Thread Safe Resource Manager */
#ifdef ZTS
#include "TSRM.h"
#ifdef ZTS
#include "TSRM.h"
#endif
/* Define RayAOP extension version */
#define PHP_RAYAOP_VERSION "1.0.0"
#define PHP_RAYAOP_VERSION "1.0.0"
/* Define RayAOP namespace */
#define RAYAOP_NS "Ray\\Aop\\"
#define RAYAOP_NS "Ray\\Aop\\"
/* Declare rayaop module entry as external reference */
extern zend_module_entry rayaop_module_entry;
extern zend_module_entry rayaop_module_entry;
/* Define pointer to rayaop module */
#define phpext_rayaop_ptr &rayaop_module_entry
#define phpext_rayaop_ptr &rayaop_module_entry
/* If in Windows environment,
specify DLL export */
#ifdef PHP_WIN32
#define PHP_RAYAOP_API __declspec(dllexport)
#ifdef PHP_WIN32
#define PHP_RAYAOP_API __declspec(dllexport)
/* If using GCC 4 or later,
specify default visibility */
#elif defined(__GNUC__) && __GNUC__ >= 4
#define PHP_RAYAOP_API __attribute__ ((visibility("default")))
#elif defined(__GNUC__) && __GNUC__ >= 4
#define PHP_RAYAOP_API __attribute__ ((visibility("default")))
/* For other environments, no specific definition is made */
#else
#define PHP_RAYAOP_API
#define PHP_RAYAOP_API
#endif
/* If in thread-safe mode,
include Thread Safe Resource Manager again (redundant but for safety) */
#ifdef ZTS
#include "TSRM.h"
#ifdef ZTS
#include "TSRM.h"
#endif
/* Macro for debug output */
#ifdef RAYAOP_DEBUG /* If debug mode is enabled */
Expand All @@ -53,39 +53,47 @@ extern zend_module_entry rayaop_module_entry;
link: http://www.phpinternalsbook.com/php5/classes_objects/internal_structures_and_implementation.html,
link: http://php.adamharvey.name/manual/ja/internals2.variables.tables.php */
typedef struct _intercept_info {
zend_string *class_name; /* Class name to intercept */
zend_string *method_name; /* Method name to intercept */
zval handler; /* Intercept handler */
zend_string *class_name; /* Class name to intercept */
zend_string *method_name; /* Method name to intercept */
zval handler; /* Intercept handler */
} intercept_info;

/* Function declarations */
PHP_MINIT_FUNCTION(rayaop); /* Module initialization function */
PHP_MSHUTDOWN_FUNCTION(rayaop); /* Module shutdown function */
PHP_RINIT_FUNCTION(rayaop); /* Request initialization function */
PHP_RSHUTDOWN_FUNCTION(rayaop); /* Request shutdown function */
PHP_MINFO_FUNCTION(rayaop); /* Module information function */
PHP_FUNCTION(method_intercept); /* Method intercept function */
PHP_MINIT_FUNCTION(rayaop); /* Module initialization function */
PHP_MSHUTDOWN_FUNCTION(rayaop); /* Module shutdown function */
PHP_RINIT_FUNCTION(rayaop); /* Request initialization function */
PHP_RSHUTDOWN_FUNCTION(rayaop); /* Request shutdown function */
PHP_MINFO_FUNCTION(rayaop); /* Module information function */
PHP_FUNCTION(method_intercept); /* Method intercept function */
/* Utility function declarations */
void rayaop_handle_error(const char *message); /* Error handling function */
bool rayaop_should_intercept(zend_execute_data *execute_data); /* Function to determine if interception is necessary */
char* rayaop_generate_intercept_key(zend_string *class_name, zend_string *method_name, size_t *key_len); /* Function to generate intercept key */
intercept_info* rayaop_find_intercept_info(const char *key, size_t key_len); /* Function to search for intercept information */
void rayaop_execute_intercept(zend_execute_data *execute_data, intercept_info *info); /* Function to execute interception */
void rayaop_free_intercept_info(zval *zv); /* Function to free intercept information */
void rayaop_handle_error(const char *message); /* Error handling function */
bool rayaop_should_intercept(zend_execute_data *execute_data); /* Function to determine if interception is necessary */
char *rayaop_generate_intercept_key(zend_string *class_name, zend_string *method_name, size_t *key_len);

/* Function to generate intercept key */
intercept_info *rayaop_find_intercept_info(const char *key, size_t key_len);

/* Function to search for intercept information */
void rayaop_execute_intercept(zend_execute_data *execute_data, intercept_info *info);

/* Function to execute interception */
void rayaop_free_intercept_info(zval *zv); /* Function to free intercept information */
#ifdef RAYAOP_DEBUG /* If debug mode is enabled */
void rayaop_debug_print_zval(zval *value); /* Function to debug print zval value */
void rayaop_dump_intercept_info(void); /* Function to dump intercept information */
#endif
ZEND_BEGIN_MODULE_GLOBALS(rayaop) /* Start of rayaop module global variables */
HashTable *intercept_ht; /* Intercept hash table */
zend_bool is_intercepting; /* Intercepting flag */
ZEND_END_MODULE_GLOBALS(rayaop) /* End of rayaop module global variables */
ZEND_BEGIN_MODULE_GLOBALS(rayaop)
/* Start of rayaop module global variables */
HashTable *intercept_ht; /* Intercept hash table */
zend_bool is_intercepting; /* Intercepting flag */
ZEND_END_MODULE_GLOBALS(rayaop) /* End of rayaop module global variables */
/* If in thread-safe mode,
global variable access macro (thread-safe version) */
#ifdef ZTS
#define RAYAOP_G(v) TSRMG(rayaop_globals_id, zend_rayaop_globals *, v)
#ifdef ZTS
#define RAYAOP_G(v) TSRMG(rayaop_globals_id, zend_rayaop_globals *, v)
/* If in non-thread-safe mode,
global variable access macro (non-thread-safe version) */
#else
#define RAYAOP_G(v) (rayaop_globals.v)
#else
#define RAYAOP_G(v) (rayaop_globals.v)
#endif
#endif /* End of header guard */
#endif /* End of header guard */
Loading

0 comments on commit bc751fb

Please sign in to comment.