winzik/docker/ext/cryo/cryo_analysis.h
2026-11-14 17:21:23 +01:00

48 lines
1.7 KiB
C

/*
* cryo_analysis.h — live analysis functions (cryo_graph.c / cryo_reader.c).
*
* cryo_roots_of(object $o, int $max = 5): array shortest paths from the roots to $o
* cryo_orphans(): array objects kept only by uncollected cycles
* cryo_diff(string $a, string $b): array per-class diff of two .cryo files
*
* cryo.c registers them: define CRYO_ANALYSIS_ARGINFO before including this
* header (once) and put CRYO_ANALYSIS_FE in the function table.
*/
#ifndef CRYO_ANALYSIS_H
#define CRYO_ANALYSIS_H
#include "php.h"
/* In-memory snapshot of the running process (no file, epoch unchanged).
* Frame variables holding `find` are not roots; *found_id = its node id. */
zend_string *cryo_snapshot_mem(HashTable *options, zend_object *find, uint32_t *found_id);
/* `*` wildcard match (no recursion) */
bool cryo_glob(const char *p, size_t plen, const char *s, size_t slen, bool nocase);
ZEND_FUNCTION(cryo_roots_of);
ZEND_FUNCTION(cryo_orphans);
ZEND_FUNCTION(cryo_diff);
#define CRYO_ANALYSIS_FE \
ZEND_FE(cryo_roots_of, arginfo_cryo_roots_of) \
ZEND_FE(cryo_orphans, arginfo_cryo_orphans) \
ZEND_FE(cryo_diff, arginfo_cryo_diff)
#endif
#ifdef CRYO_ANALYSIS_ARGINFO
#undef CRYO_ANALYSIS_ARGINFO
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cryo_roots_of, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max, IS_LONG, 0, "5")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cryo_orphans, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_cryo_diff, 0, 2, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, a, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, b, IS_STRING, 0)
ZEND_END_ARG_INFO()
#endif