zpmod  b19981f
High-performance Zsh module for script optimization and filesystem helpers
zpmod_source.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
2 #pragma once
3 #include "zpmod.mdh"
4 #include "zpmod.pro"
5 
15 typedef struct zp_sevent_node *SEventNode;
16 
20 struct source_event {
21  int id;
22  long ts;
23  char *dir_path;
24  char *file_name;
25  char *full_path;
26  double duration;
28 };
29 
31  struct hashnode node;
32  struct source_event event;
33 };
34 
37 char *zp_build_source_report(int no_paths, int *rep_size);
38 
40 mod_export enum source_return custom_source(char *s);
41 Eprog custom_try_source_file(char *file);
42 
43 /* Core reporting helper (implemented in source.c) */
44 /*
45  * Core reporting function for source-study. Some builds may only ship a stub.
46  * Declare weak so that we can test for presence at runtime and fail gracefully
47  * instead of producing an unresolved symbol error in edge staging scenarios.
48  */
49 // NOLINTBEGIN(bugprone-easily-swappable-parameters)
50 int zp_source_study_core(const char *nam, int report_count, int threshold_ms,
51  int clear_history)
52 // — API kept as (count, ms, flag)
53 #if defined(__GNUC__)
54  __attribute__((weak))
55 #endif
56  ;
57 // NOLINTEND(bugprone-easily-swappable-parameters)
Recorded event for a sourced script.
Definition: zpmod_source.h:20
char * file_name
Definition: zpmod_source.h:24
char * full_path
Definition: zpmod_source.h:25
char * dir_path
Definition: zpmod_source.h:23
double duration
Definition: zpmod_source.h:26
struct source_event event
Definition: zpmod_source.h:32
struct hashnode node
Definition: zpmod_source.h:31
Module declaration header (mdh) for zpmod.
#define mod_export
Prototype stub for zpmod when building out-of-tree.
struct hashnode * HashNode
struct eprog * Eprog
Eprog custom_try_source_file(char *file)
Try to locate or build a ZWC dump for the script and return Eprog.
Definition: source.c:322
int zp_source_study_core(const char *nam, int report_count, int threshold_ms, int clear_history)
struct zp_sevent_node * SEventNode
Definition: zpmod_source.h:15
mod_export enum source_return custom_source(char *s)
Overridden dot/source and helpers exported from core.
Definition: source.c:506
void zp_free_sevent_node(HashNode hn)
Hash lifecycle.
Definition: source.c:727
char * zp_build_source_report(int no_paths, int *rep_size)
Definition: source.c:670