id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
29,063
hgenetic_algorithm_refined.lsp
AndreaCimminoArriaga_ColoreadoDeGrafos/HGenetic Algorithm refined/hgenetic_algorithm_refined.lsp
;;Importing data from file 'data.lsp' (load "data.lsp") ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| Initialice genetic algorithm parameters as described in the paper: |;; ;;|______________________________________________________________________________________________________________|;; (defparameter *population_length* 2) (defparameter *half_population_length* 1) (defparameter *population* '()) (load "functions.lsp") (defparameter *population* (generate_random_population)) (defparameter *generation* 0) (defparameter *max_generations* 20000) (defparameter *best_chromosomes* '() ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| |;; ;;| # GENETIC ALGORITHM MAIN FUNCTIONS # |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| max_generation_reached () -> This function returns true if the algorith has iterated over the maximum |;; ;;| number of generations as described in the paper |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun max_generation_reached () (IF (= *max_generations* (EVAL (defparameter *generation* (+ *generation* 1) )) ) T NIL) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| pick_top_half_population () -> This frunction takes the first half number of chromosomes in the population |;; ;;| but only works if the number of the population is even. |;; ;;| |;; ;;| USES: |;; ;;| - nthcar_2 (n list) |;; ;;|______________________________________________________________________________________________________________|;; (defun pick_top_half_population () (IF (EVENP *population_length*) (nthcar_2 (- *half_population_length* 1) *population*) Nil ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| create_new_generation (chromosome) -> This frunction takes the first half number of chromosomes in the |;; ;;| populationbut and add to it the given chromosome and after that |;; ;;| fill the rest with random chromosomes until arrive to the max length |;; ;;| USES: |;; ;;| - pick_top_half_population () |;; ;;| - generate_random_half_population () |;; ;;|______________________________________________________________________________________________________________|;; (defun create_new_generation (chromosome) (= *population_length* (LENGTH (EVAL (defparameter *population* (APPEND (ACONS chromosome (fitness_score chromosome) (pick_top_half_population)) (generate_random_half_population) ) )) ))) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| exists_optimal_solution () -> T if exists a chromosome with fitness equal to 0. |;; ;;| |;; ;;| USES: |;; ;;| - parent_selection_2 () |;; ;;| - fitness_score (chromosome) |;; ;;|______________________________________________________________________________________________________________|;; (defun exists_optimal_solution () ( let (( best (EVAL ( defparameter *best_chromosomes* (parent_selection_2))) )) (IF (OR (= 0 (CDR (FIRST best))) (= 0 (CDR (SECOND best)))) T Nil ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| get_optimal_solution () -> Return the optimal solution. |;; ;;| |;; ;;| USES: |;; ;;| - parent_selection_2 () |;; ;;| - fitness_score (chromosome) |;; ;;|______________________________________________________________________________________________________________|;; (defun get_optimal_solution () (IF (= (CDR (FIRST *best_chromosomes*)) 0 ) (CAR (FIRST *best_chromosomes*)) (CAR (SECOND *best_chromosomes*)) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| algorithm_1 () -> This function implements the configuration of algorithm1 described in the paper |;; ;;| |;; ;;| USES: |;; ;;| - mutation_1 () |;; ;;| - crossover (chromosome_1 chromosome_2) |;; ;;| - parent_selection_1 () |;; ;;|______________________________________________________________________________________________________________|;; (defun algorithm_1 () (mutation_1 (crossover (parent_selection_1) (parent_selection_1))) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| algorithm_2 () -> This function implements the configuration of algorithm2 described in the paper |;; ;;| |;; ;;| USES: |;; ;;| - mutation_2 () |;; ;;| - crossover (chromosome_2 chromosome_2) |;; ;;| - parent_selection_2 () |;; ;;|______________________________________________________________________________________________________________|;; (defun algorithm_2 () (mutation_2 (crossover (CAR (FIRST *best_chromosomes* )) (CAR (SECOND *best_chromosomes* )) ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| choose_algorithm () -> As described in the paper in base of the fitness of the best chromosomes pair selects |;; ;;| an algorithm or another. |;; ;;| |;; ;;| USES: |;; ;;| - parent_selection_2 |;; ;;| - fitness_score (chromosome) |;; ;;| - create_new_generation (chromosome) |;; ;;| - algorithm_1 () |;; ;;| - algorithm_2 () |;; ;;|______________________________________________________________________________________________________________|;; (defun choose_algorithm () (IF (OR (> (CDR (FIRST *best_chromosomes*)) 4) (> (CDR (SECOND *best_chromosomes*)) 4) ) (create_new_generation (algorithm_1)) (create_new_generation (algorithm_2)) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| |;; ;;| # wisdom_of_artificial_crowds # |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defparameter *expert_chromosomes* Nil) (defparameter *color_array* Nil) (defparameter *best_chromosome* Nil) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| inc_color_counter (color) -> Given a color increments the param *color_array* in the position of that color |;; ;;| |;; ;;| USES: |;; ;;| - set_element (n elem list) |;; ;;|______________________________________________________________________________________________________________|;; (defun inc_color_counter (color) ( IF (OR (<= color 0) (> color *k*)) Nil (EVAL (defparameter *color_array* (set_element (- color 1) (+ 1 (NTH (- color 1) *color_array*)) *color_array* ) )) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| count_color (vertex chromosome) -> Given a vertex calculates how many times uses each color |;; ;;| |;; ;;| USES: |;; ;;| - inc_color_counter (color) |;; ;;|______________________________________________________________________________________________________________|;; (defun count_color (vertex chromosome) (inc_color_counter (vertex_color vertex chromosome)) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| most_used_color (vertex) -> Returns the array with the count of each color in base of how many times are |;; ;;| used |;; ;;| USES: |;; ;;| - inc_color_counter (color) |;; ;;|______________________________________________________________________________________________________________|;; (defun most_used_color_aux (vertex n) ( IF (= n *half_population_length*) *color_array* (IF (EQ Nil (count_color vertex (CAR (NTH n *expert_chromosomes* )) ) ) Nil (most_used_color_aux vertex (+ n 1)) ) )) (defun most_used_color (vertex) ( let ((array_color (most_used_color_aux vertex 0))) (IF (< 0 (LENGTH (EVAL (defparameter *color_array* (MAKE-LIST *k* :INITIAL-ELEMENT 0) ))) ) array_color Nil ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| get_most_used_color (vertex) () -> Given a vertex returns the most used color with that vertex |;; ;;| |;; ;;| USES: |;; ;;| - most_used_color (vertex) |;; ;;|______________________________________________________________________________________________________________|;; (defun get_most_used_color_aux (counter counter_max value array_color) (IF (= counter (LENGTH array_color)) counter_max (IF (> (NTH counter array_color) value) ( get_most_used_color_aux (+ 1 counter) counter (NTH counter array_color) array_color ) ( get_most_used_color_aux (+ 1 counter) counter_max value array_color) ) ) ) (defun get_most_used_color (vertex) ( let ((array_color (most_used_color vertex) )) (+ 1 (get_most_used_color_aux 0 0 0 array_color)) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| wisdom_of_artificial_crowds () -> As described in the paper this function it's called when the maximum |;; ;;| generation ir reached and the algorithm has no found a solution. |;; ;;| |;; ;;| USES: |;; ;;| - set_element (n elem list) |;; ;;| - fitness_vertex_score (vertex chromosome) |;; ;;| - get_most_used_color (vertex) |;; ;;|______________________________________________________________________________________________________________|;; (defun wisdom_of_artificial_crowds_aux ( vertex ) (IF (= vertex *v*) T ( IF (= (fitness_vertex_score vertex *best_chromosome*) 0) (wisdom_of_artificial_crowds_aux (+ 1 vertex)) (IF (< 0 (LENGTH(EVAL(defparameter *best_chromosome* (set_element vertex (get_most_used_color vertex) *best_chromosome*) )))) (wisdom_of_artificial_crowds_aux (+ 1 vertex)) Nil ) ) ) ) (defun apply_wisdom_of_artificial_crowds_aux (n) (IF (= n *v*) T (IF (EQ T (wisdom_of_artificial_crowds_aux n) ) (apply_wisdom_of_artificial_crowds_aux (+ 1 n)) Nil ) ) ) (defun apply_wisdom_of_artificial_crowds () (apply_wisdom_of_artificial_crowds_aux 0 )) (defun wisdom_of_artificial_crowds () ( let ( ( best (EVAL (defparameter *best_chromosome* (fitter (FIRST *best_chromosomes*) (SECOND *best_chromosomes*)))) ) ( best_half (EVAL (defparameter *expert_chromosomes* (best_half_population))) ) (array_color (EVAL (defparameter *color_array* (MAKE-LIST *k* :INITIAL-ELEMENT 0) ))) ) (IF (EQ T (apply_wisdom_of_artificial_crowds)) *best_chromosome* Nil ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| |;; ;;| # GENETIC ALGORITHM # |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun start () (IF (EQ (exists_optimal_solution) T) (get_optimal_solution) ( IF (EQ (max_generation_reached) T) (wisdom_of_artificial_crowds) (IF (EQ (choose_algorithm) T) (start) Nil) ) ) ) (defun start_one () (IF (EQ (exists_optimal_solution) T) (get_optimal_solution) ( IF (EQ (max_generation_reached) T) (wisdom_of_artificial_crowds) (IF (EQ (choose_algorithm) T) (exists_optimal_solution) NIL) ) ) )
15,863
Common Lisp
.l
276
52.92029
232
0.324682
AndreaCimminoArriaga/ColoreadoDeGrafos
0
0
0
GPL-2.0
9/19/2024, 11:37:01 AM (Europe/Amsterdam)
ae7c52489bacfd59ab8bf9a5b75c2e97b42285099a721fc01bec0cc862b7c7f1
29,063
[ -1 ]
29,065
islands_model.lsp
AndreaCimminoArriaga_ColoreadoDeGrafos/Islands Model/islands_model.lsp
;;Importing data from file 'data.lsp' (load "data.lsp") ;;Importing functions from file 'functions.lsp' (load "functions.lsp") ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| Initialice genetic algorithm and island model parameters as described in the paper: |;; ;;|______________________________________________________________________________________________________________|;; (defparameter *island_1* '()) (defparameter *island_2* '()) (defparameter *island_3* '()) (defparameter *island_4* '()) (defparameter *generation* 0) (defparameter *max_generations* 20000) (defparameter *emigrate_each_n_generations* 4) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| |;; ;;| # ISLAND MODEL AUXILIAR AND MAIN FUNCTIONS # |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| distribute_population (population) -> If the length of the given param population is not divisible by five |;; ;;| fills the given param population with random pair chromosome and his |;; ;;| fitness score when reach a number of elems that is divisible then |;; ;;| distribute the population by the islands params. |;; ;;| USES: |;; ;;| - nthcar (n list) |;; ;;| - generate_random_pair (list) |;; ;;|______________________________________________________________________________________________________________|;; (defun distribute_population_aux (population) ( let ( (island1 (EVAL (defparameter *island_1* ( nthcar (/ (LENGTH population) 4) population) ) )) (island2 (EVAL (defparameter *island_2* ( nthcdr (/ (LENGTH population) 4) (nthcar (* (/ (LENGTH population) 4) 2) population)) ) )) (island3 (EVAL (defparameter *island_3* ( nthcdr (* (/ (LENGTH population) 4) 2) (nthcar (* (/ (LENGTH population) 4) 3) population)) ))) (island4 (EVAL (defparameter *island_4* ( nthcdr (* (/ (LENGTH population) 4) 3) (nthcar (* (/ (LENGTH population) 4) 4) population)) ))) ) (AND (= (LENGTH island1) (LENGTH island2) (LENGTH island3) (LENGTH island4) ) ) ) ) (defun distribute_population (population) ( IF (= (MOD (LENGTH population) 4) 0) (distribute_population_aux population) (distribute_population (generate_random_pair population) ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| transform_population (population) -> Takes the population and create an A-list with each elem of the given |;; ;;| list and the fitness_score of each chromosome of the given list. |;; ;;| |;; ;;| USES: |;; ;;| - fitness_score (chromorome) |;; ;;|______________________________________________________________________________________________________________|;; (defun transform_population_aux (population result n) ( let (( elem (NTH n population))) (IF (= (LENGTH population) (LENGTH result)) result (transform_population_aux population (APPEND result (ACONS elem (fitness_score elem) '())) (+ n 1)) ) ) ) (defun transform_population (population) (transform_population_aux population '() 0)) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| add_to_island (list) -> Takes the list given by param and add it to the corresponding island. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun add_to_island_1 (list) (< 0 (LENGTH (EVAL (defparameter *island_1* (APPEND list *island_1*)))))) (defun add_to_island_2 (list) (< 0 (LENGTH (EVAL (defparameter *island_2* (APPEND list *island_2*)))))) (defun add_to_island_3 (list) (< 0 (LENGTH (EVAL (defparameter *island_3* (APPEND list *island_3*)))))) (defun add_to_island_4 (list) (< 0 (LENGTH (EVAL (defparameter *island_4* (APPEND list *island_4*)))))) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| take_best3_island (list) -> Takes the best three chromosomes from the corresponding island and erase from |;; ;;| there. |;; ;;| USES: |;; ;;| - nthcar (n list) |;; ;;|______________________________________________________________________________________________________________|;; (defun take_best3_island1 () (let (( ordered_island (sort *island_1* #'< :key #'cdr) )) (IF (<= 0 (LENGTH (EVAL (defparameter *island_1* (nthcdr 3 *island_1*) )))) (nthcar 3 ordered_island) Nil ) ) ) (defun take_best3_island2 () (let (( ordered_island (sort *island_2* #'< :key #'cdr) )) (IF (<= 0 (LENGTH (EVAL (defparameter *island_2* (nthcdr 3 *island_2*) )))) (nthcar 3 ordered_island) Nil ) ) ) (defun take_best3_island3 () (let (( ordered_island (sort *island_3* #'< :key #'cdr) )) (IF (<= 0 (LENGTH (EVAL (defparameter *island_3* (nthcdr 3 *island_3*) )))) (nthcar 3 ordered_island) Nil ) ) ) (defun take_best3_island4 () (let (( ordered_island (sort *island_4* #'< :key #'cdr) )) (IF (<= 0 (LENGTH (EVAL (defparameter *island_4* (nthcdr 3 *island_4*) )))) (nthcar 3 ordered_island) Nil ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| emigrate (population) -> This function take the best three chromosomes from each island and makes them |;; ;;| emigrate like is described in the paper of this work. |;; ;;| |;; ;;| USES: |;; ;;| - take_best3_island () |;; ;;| - add_to_island (list) |;; ;;|______________________________________________________________________________________________________________|;; (defun emigrate () ( let ( (best3_1 (take_best3_island1)) (best3_2 (take_best3_island2)) (best3_3 (take_best3_island3)) (best3_4 (take_best3_island4)) ) (AND (add_to_island_1 (LIST (FIRST best3_3) (SECOND best3_4) (FIRST best3_2) ) ) (add_to_island_2 (LIST (THIRD best3_1) (SECOND best3_3) (THIRD best3_4) ) ) (add_to_island_3 (LIST (FIRST best3_1) (SECOND best3_2) (FIRST best3_4) ) ) (add_to_island_4 (LIST (THIRD best3_3) (SECOND best3_1) (THIRD best3_2) ) ) ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| exists_solution_in_island () -> This function return a list with the solution that finds in each island or |;; ;;| Nil if they don't exists. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun exists_solution_in_island () (LIST (RASSOC 0 *island_1*) (RASSOC 0 *island_2*) (RASSOC 0 *island_3*) (RASSOC 0 *island_4*) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| |;; ;;| # GENETIC ALGORITHM MAIN FUNCTIONS # |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| get_solution (list) -> This function return a solution if exists. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun get_solution (list) (IF (EQ (FIRST list) NIL) (IF (EQ (SECOND list) NIL) (IF (EQ (THIRD list) NIL) (IF (EQ (NTH 3 list) NIL) NIL (NTH 3 list) ) (THIRD list) ) (SECOND list) ) (FIRST list) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| max_generation_reached () -> This function returns true if the algorith has iterated over the maximum |;; ;;| number of generations as described in the paper |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun max_generation_reached () (IF (= *max_generations* (EVAL (defparameter *generation* (+ *generation* 1) )) ) T NIL) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| parent_selection () -> Return the two best chromosomes in the given population. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun parent_selection (population) (nthcar 2 (sort population #'< :key #'cdr) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| crossover (chromosome1 chromosome2) -> This function cross two parents in a random way, like in the prior |;; ;;| work. |;; ;;| |;; ;;| USES: |;; ;;| - nthcar_2 (n list) |;; ;;|______________________________________________________________________________________________________________|;; (defun crossover_aux (chromosome1 chromosome2 crosspoint) (APPEND (nthcar_2 crosspoint chromosome1 ) (NTHCDR (+ 1 crosspoint) chromosome2)) ) (defun crossover (chromosome1 chromosome2) (crossover_aux chromosome1 chromosome2 (RANDOM (LENGTH chromosome1)))) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| mutation (chromosome n) -> The function implements the same steps as the mutation_1 in the prior work. |;; ;;| |;; ;;| USES: |;; ;;| - fitness_vertex_score (vertex chromosome) |;; ;;| - set_element (n elem list) |;; ;;| - select_color (n chromosome) |;; ;;|______________________________________________________________________________________________________________|;; (defun mutation_aux (chromosome n) (IF (>= n *v*) chromosome (IF (= (fitness_vertex_score n chromosome) 0 ) (mutation_aux chromosome (+ n 1) ) (mutation_aux (set_element n (select_color n chromosome) chromosome ) (+ n 1) ) ) ) ) (defun mutation (chromosome) (mutation_aux chromosome 0)) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| FUNCTION: |;; ;;| |;; ;;| create_new_generation (chromosome population) -> This functions takes the new chromosome and add it to the |;; ;;| population, ten order the population by fitness score and |;; ;;| erase the worst half and add a new random half. |;; ;;| |;; ;;| USES: |;; ;;| - fitness_vertex_score (vertex chromosome) |;; ;;| - set_element (n elem list) |;; ;;| - select_color (n chromosome) |;; ;;|______________________________________________________________________________________________________________|;; (defun create_new_generation_aux (chromosome population) (set_element (- (LENGTH population) 1) (FIRST(ACONS chromosome (fitness_score chromosome) '() )) (sort population #'< :key #'cdr)) ) (defun create_new_generation (chromosome population) ( let ( (best_half (nthcar (FLOOR (/ (LENGTH population) 2)) (sort population #'< :key #'cdr))) (tam (LENGTH population)) ) (IF (EQ (EVENP tam) T) (APPEND (create_new_generation_aux chromosome best_half) (generate_random_array_list_pairs 0 '() (/ tam 2) )) (APPEND (create_new_generation_aux chromosome best_half) (generate_random_array_list_pairs 0 '() (+ 1 (FLOOR (/ tam 2)) ))) ) ) ) (defun create_new_generation_2 (chromosome population) (create_new_generation_aux chromosome population)) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| |;; ;;| # ISLAND MODEL & GENETIC ALGORITHM # |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun genetic_algorithm (population) ( let ( (chromosomes (parent_selection population)) ) (create_new_generation (mutation (crossover (CAR (FIRST chromosomes )) (CAR (SECOND chromosomes )) )) population) ) ) (defun genetic_algorithm_2 (population) ( let ( (chromosomes (parent_selection population)) ) (create_new_generation_2 (mutation (crossover (CAR (FIRST chromosomes )) (CAR (SECOND chromosomes )) )) population) ) ) (defun lauch_genetics_algorithms () (let ( ( result_1 (LENGTH (EVAL (defparameter *island_1* (genetic_algorithm *island_1*)))) ) ( result_2 (LENGTH (EVAL (defparameter *island_2* (genetic_algorithm *island_2*)))) ) ( result_3 (LENGTH (EVAL (defparameter *island_3* (genetic_algorithm_2 *island_3*)))) ) ( result_4 (LENGTH (EVAL (defparameter *island_4* (genetic_algorithm_2 *island_4*)))) ) ) (IF (< 0 (+ result_1 result_2 result_3 result_4)) T Nil) ) ) (defun start () ( let (( solution (get_solution (exists_solution_in_island)) )) (IF (NOT (EQ NIL solution)) (CAR solution) (IF (EQ T (max_generation_reached) ) 0 (IF (= 0 (MOD *generation* *emigrate_each_n_generations*)) (IF (EQ (AND (emigrate) (lauch_genetics_algorithms)) T) (start) Nil ) (IF (EQ (lauch_genetics_algorithms) T) (start) Nil) ) ) ) ) ) (defun start_island_model (population) ( let ( (correct_distributed (distribute_population(transform_population population)) ) ) (IF (EQ correct_distributed T) (start) NIL) ) ) (defparameter *population* (generate_random_array_list 0 '() 25))
17,260
Common Lisp
.l
300
51.993333
155
0.376219
AndreaCimminoArriaga/ColoreadoDeGrafos
0
0
0
GPL-2.0
9/19/2024, 11:37:01 AM (Europe/Amsterdam)
c45ddbc46a63e4cecc4d6d2811ed163b00dd76ef7794cae2d38e19b6c954c753
29,065
[ -1 ]
29,066
functions.lsp
AndreaCimminoArriaga_ColoreadoDeGrafos/Islands Model/functions.lsp
;;| |;; ;;| ############################################################## |;; ;;| ##### Main and auxiliar functions ###### |;; ;;| ############################################################## |;; ;;| |;; ;;| |;; ;;| |;; ;;| This file contains all the functions required by the algorithm, i write a little description of each one |;; ;;| and the tipe (main or auxiliar). Normaly an auxiliar function is used in the next main function at any rate |;; ;;| in the description of the function there are indicate the dependences. |;; ;;| |;; ;;| -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -|;; ;;| |;; ;;| Funtions in the file: |;; ;;| |;; ;;| - nthcar (n list) : AUXILIAR FUNCTION (line 58) |;; ;;| - nthcar_2 (n list) : AUXILIAR FUNCTION (line 69) |;; ;;| - vertex_color (vertex chromosome) : AUXILIAR FUNCTION (line 81) |;; ;;| - colors (vertex_list chromosome) : AUXILIAR FUNCTION (line 95) |;; ;;| - neighbour (vertex) : AUXILIAR FUNCTION (line 107) |;; ;;| - neighbour_colors (vertex chromosome) : AUXILIAR FUNCTION (line 123) |;; ;;| - bad_edges (color color_list n) : AUXILIAR FUNCTION (line 137) |;; ;;| - fitness_vertex_score (vertex chromosome) : AUXILIAR FUNCTION (line 159) |;; ;;| - fitness_score (chromosome) : AUXILIAR FUNCTION (line 180) |;; ;;| - generate_random_array (n list) : AUXILIAR FUNCTION (line 192) |;; ;;| - generate_random_chromosome () : AUXILIAR FUNCTION (line 213) |;; ;;| - pair_chromosome_score (chromosome list) : AUXILIAR FUNCTION (line 226) |;; ;;| - generate_random_pair (list) : AUXILIAR FUNCTION (line 242) |;; ;;| - generate_random_array_list (n list) : AUXILIAR FUNCTION (line 254) |;; ;;| - set_element (n elem list) : AUXILIAR FUNCTION (line 279) |;; ;;| - pick_randomly (n list) : AUXILIAR FUNCTION (line 295) |;; ;;| - valid_colors (color_list) : AUXILIAR FUNCTION (line 328) |;; ;;| - select_color (n chromosome) : AUXILIAR FUNCTION (line 346) |;; ;;| |;; ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| nthcar (n list) -> This function returns the list from the elem 0 to the elem n-1, below there is a |;; ;;| a modification of this function that returns up to the n elem. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun nthcar_aux (n m list list_res) (IF (= m n) (REVERSE list_res) (IF (= (LENGTH list) 0) (REVERSE list_res) (nthcar_aux n (+ m 1) (CDR list) (CONS (FIRST list) list_res) ) ) ) ) (defun nthcar (n list) (nthcar_aux n 0 list '()) ) (defun nthcar_aux_2 (n m list list_res) (IF (= m n) (REVERSE (CONS(FIRST list) list_res)) (IF (= (LENGTH list) 0) (REVERSE list_res) (nthcar_aux_2 n (+ m 1) (CDR list) (CONS (FIRST list) list_res) ) ) ) ) (defun nthcar_2 (n list) (nthcar_aux_2 n 0 list '()) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| vertex_color (vertex chromosome) -> Return the color of the vertex using a given chromosome. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun vertex_color (vertex chromosome) (NTH vertex chromosome)) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| colors (vertex_list chromosome ) -> This function takes a list of vertex and calculate the color of each |;; ;;| vertex using a given chromosome and return a list with the colors of |;; ;;| the vertexes. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun colors (vertex_list chromosome) (MAPCAR #'* vertex_list chromosome) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| neighbour (vertex) -> Return the list of neighbours vertexes of a vertex given. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun neighbour (vertex) (NTH vertex *matrix_adj*) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| neighbour_colors (vertex chromosome) -> This functions return a list with the colors of his neighbour |;; ;;| vertex using a given chromosome. |;; ;;| |;; ;;| USES: |;; ;;| - colors (vertex_list chromosome) |;; ;;| - neighbour (vertex) |;; ;;|______________________________________________________________________________________________________________|;; (defun neighbour_colors (vertex chromosome) ( colors (EVAL (neighbour vertex)) chromosome) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| bad_edges (color color_list) -> Return the number of times that the given color appears in the list. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun eq_color (c1 c2) (IF (= c1 c2) 1 0 ) ) (defun bad_edges (color color_list n) (IF (= (LENGTH color_list) 0) n (bad_edges color (CDR color_list) (+ n (eq_color color (FIRST color_list))) ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| fitness_vertex_score (vertex chromosome) -> calculate the fitness score as described in the paper |;; ;;| 'Generic Algorithm Applied to the Graph Coloring Problem' for a |;; ;;| given vertex. |;; ;;| |;; ;;| USES: |;; ;;| - bad_edges (color color_list n) |;; ;;| - vertex_color (vertex chromosome) |;; ;;| - neighbour_colors (vertex chromosome) |;; ;;|______________________________________________________________________________________________________________|;; (defun fitness_vertex_score (vertex chromosome) ( bad_edges (vertex_color vertex chromosome) (neighbour_colors vertex chromosome) 0) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| fitness_score ( chromosome ) -> Calculate the fitness score as described in the paper 'Generic Algorithm |;; ;;| Applied to the Graph Coloring Problem' |;; ;;| |;; ;;| USES: |;; ;;| - fitness_vertex_score (vertex chromosome) |;; ;;|______________________________________________________________________________________________________________|;; (defun fitness_score_aux (chromosome n fitness) (IF (= n *v*) fitness (fitness_score_aux chromosome (+ n 1) (+ fitness (fitness_vertex_score n chromosome)) ) ) ) (defun fitness_score (chromosome) (fitness_score_aux chromosome 0 0)) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| generate_random_array (n list) -> Generates an array filled with random numbers in the range ok *k* and |;; ;;| which length is: ( *v* - n ). |;; ;;|______________________________________________________________________________________________________________|;; (defun generate_random_array (n list) (IF (= n *v*) list ( generate_random_array (+ n 1) (cons (+ 1 (random *k*)) list ) ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| generate_random_chromosome () -> Generates in a random way a chromosome using the params defined in the data |;; ;;| file. Namely, an array a length of *v* and filled of collors in the range |;; ;;| of *k* choosed randomly. |;; ;;| |;; ;;| USES: |;; ;;| - generate_random_array (n list) |;; ;;|______________________________________________________________________________________________________________|;; (defun generate_random_chromosome () (generate_random_array 0 '() ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| pair_chromosome_score (chromosome list) -> Generates a pair chromosome and his score |;; ;;| |;; ;;| USES: |;; ;;| - fitness_score (chromosome) |;; ;;|______________________________________________________________________________________________________________|;; (defun pair_chromosome_score (chromosome list) (ACONS chromosome (fitness_score chromosome) list)) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| generate_random_pair (list) -> Generates a random chromosome and return a pair with his score and |;; ;;| the chromosome. |;; ;;| |;; ;;| USES: |;; ;;| - pair_chromosome_score (chromosome list) |;; ;;| - generate_random_chromosome () |;; ;;|______________________________________________________________________________________________________________|;; (defun generate_random_pair (list) (pair_chromosome_score (generate_random_chromosome) list) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| generate_random_array_list (n list) -> Generates a list of array of random numbers in the range of *k* and |;; ;;| which size is: ( *v* - n ). |;; ;;|______________________________________________________________________________________________________________|;; (defun generate_random_array_list (n list top) (IF (= n top) list ( generate_random_array_list (+ n 1) (cons (generate_random_chromosome) list ) top) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: set_element (n elem list) -> This function take a list and a position from that list an |;; ;;| changes the elem in that position with the given by the user.|;; ;;| If the position is greather than the lenght of the list the |;; ;;| function will return the original list. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun set_element_aux (n m elem list list_res) ( IF (= n m) ( APPEND (REVERSE (CONS elem list_res )) (NTHCDR (+ n 1) list) ) (set_element_aux n (+ 1 m) elem list (CONS (NTH m list) list_res) ) ) ) (defun set_element (n elem list) (IF (= n (LENGTH list) ) list (set_element_aux n 0 elem list '() ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| pick-randomly (n l) -> This function pick up in a random way n elements from the list l. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun pick-randomly (n l) (if (= n 0) '() (IF (<= (LENGTH l) 0) '() (let ((pos-select (random (length l)))) (cons (nth pos-select l) (pick-randomly (- n 1) (append (subseq l 0 pos-select) (subseq l (1+ pos-select)))))) ) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| valid_colors (color_list) -> By a color list given return the colors non used. |;; ;;| |;; ;;|______________________________________________________________________________________________________________|;; (defun valid_colors_aux (color_list k list) (IF (/= k 0) (IF (EQ (MEMBER k color_list) NIL) (valid_colors_aux color_list (- k 1) (CONS k list) ) (valid_colors_aux color_list (- k 1) list ) ) list ) ) (defun valid_colors (color_list) ( valid_colors_aux color_list *k* '() ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| select_color (n chromosome) -> Given a vertex the function return a 'valid color' given the neighbour |;; ;;| color and the vertex color. If not exists a valid color returns the vertex |;; ;;| same color. |;; ;;| |;; ;;| USES: |;; ;;| - valid_colors (color_list) |;; ;;| - vertex_color (vertex chromosome) |;; ;;| - pick_randomly (n list) |;; ;;|______________________________________________________________________________________________________________|;; (defun select_color (n chromosome) (IF (EQ Nil (set 'final_color (FIRST (pick-randomly 1 (valid_colors (neighbour_colors n chromosome) )))) ) (vertex_color n chromosome) (EVAL 'final_color) ) ) ;;.______________________________________________________________________________________________________________.;; ;;| |;; ;;| AUXILIAR FUNCTION: |;; ;;| |;; ;;| generate_random_array_list_pairs (n list top) -> Generates a list of array of random numbers in the range |;; ;;| of *k* and which size is: ( *v* - n ). And their fitness score. |;; ;;| |;; ;;| USES: |;; ;;| - generate_random_pair (list) |;; ;;|______________________________________________________________________________________________________________|;; (defun generate_random_array_list_pairs (n list top) (IF (= n top) list ( generate_random_array_list_pairs (+ n 1) (generate_random_pair list) top ) ) )
17,727
Common Lisp
.l
287
58.034843
144
0.330297
AndreaCimminoArriaga/ColoreadoDeGrafos
0
0
0
GPL-2.0
9/19/2024, 11:37:01 AM (Europe/Amsterdam)
d7fbe6b46ac38510061aaac1bf97faf3aa09ad02c7f943adc232e7f7d5241910
29,066
[ -1 ]
29,094
patternmatch4.lsp
elainekmao_pattern-matcher/patternmatch4.lsp
(defun match (p d) (rpm p d nil)) (defun rpm (p d a) (cond ((and (null p)(null d)) (cond (a a) (t t))) ((and (or (null p) (null d)) (not (or (equal '* (first p)) (equal '* (first d))))) nil) ((is-vbl (first p)) (cond ((assoc (first p) a) (cond ((equal (first d) (cdr (assoc (first p) a))) (rpm (rest p) (rest d) a)) (t (cond ((not (null (rest p))) (cond ((equal '* (first (rest p))) (let ((newd d)) (cond ((and (not (null (rpm (rest p) (rest newd) a))) (not (null (rest newd)))) (rpm p (rest newd) (cons (list (first p) (first newd)) a))) (t (rpm (rest p) (rest newd) (cons (list (first p) (first newd)) a)))))) (t (rpm (rest p) (rest d) (cons (list (first p) (first d)) a))))) (t nil))))) (t (cond ((not (null (rest p))) (cond ((equal '* (first (rest p))) (let ((newd d)) (cond ((and (not (null (rpm (rest p) (rest newd) a))) (not (null (rest newd)))) (rpm p (rest newd) (cons (list (first p) (first newd)) a))) (t (rpm (rest p) (rest newd) (cons (list (first p) (first newd)) a)))))) (t (rpm (rest p) (rest d) (cons (list (first p) (first d)) a))))) (t (rpm (rest p) (rest d) (cons (list (first p) (first d)) a))))))) ((equal '? (first p)) (rpm (rest p) (rest d) a)) ((equal '* (first p)) (or (rpm (rest p) d a) (rpm p (rest d) a))) ((atom (first p)) (cond ((eql (first p) (first d)) (rpm (rest p) (rest d) a)) (t nil))) (t (cond ((and (listp p) (listp d)) (let ((newa (rpm (first p) (first d) a))) (cond ((null newa) nil) ((listp newa) (rpm (rest p) (rest d) newa)) (t (rpm (rest p) (rest d) nil))))) (t nil))))) (defun is-vbl (x) (cond ((numberp x) nil) ((listp x) nil) (t (and (equal #\? (char (string x) 0)) (> (length (string x)) 1)))))
2,377
Common Lisp
.l
49
32.55102
114
0.385278
elainekmao/pattern-matcher
0
0
0
GPL-2.0
9/19/2024, 11:37:17 AM (Europe/Amsterdam)
d73136ee4f4341ec81661d68323dd17f57274cde2cf00dfd226df271d3e1377e
29,094
[ -1 ]
29,110
tic-tac-toe.lisp
selsah_lisp-mastery/tic-tac-toe.lisp
;;;;;play a game of tic tac toe with computer that has knowledge of basic strategy (defparameter *board* (list 'board 0 0 0 0 0 0 0 0 0)) ;converts binary symbol into eith an "x" or "o" to be printed (defun convert-to-letter (number) (cond ((equal 10 number) "x") ((equal 1 number) "o") (t " "))) ;prints a single line (defun print-line (a b c) (format t "~& ~A | ~A | ~A" (convert-to-letter a) (convert-to-letter b) (convert-to-letter c))) ;prints board (defun print-board (board) (print-line (second board) (third board) (fourth board)) (format t "~& -------------") (print-line (fifth board) (sixth board) (seventh board)) (format t "~& -------------") (print-line (eighth board) (ninth board) (tenth board)) (format t "~%~%~%")) ;takes in a number, symbol, board and makes move as long as space is available and input is valid (defun make-move (number symbol boar) (and (equal (nth number boar) 0) (and (> number 0) (< number 10)) (setf (nth number boar) symbol))) ;player makes a move...retruns true if move was succesfully executed otherwise prints a statement (defun player-move () (cond ((equal (winner *board*) 3) '(Computer loveeee)) ((full-board *board*) '(Tie game)) (t (format t "~&What's your next move? ") (let ((move (read))) (cond ((not (null (make-move move 10 *board*))) (make-move move 10 *board*) (print-board *board*) (computer-move)) (t (format t "~& not a valid move") (player-move))))))) ;checks to see if board is full (defun full-board (board) (cond ((not (member 0 board)) t) (t nil))) ;returns true if move was successfully made, otherwise prints statement (defun computer-move () (cond ((equal (winner *board*) 30) nil) ((full-board *board*) nil) (t (let ((guess (+ 1 (random 9)))) (cond ((or (equal (block-or-win (return-triplet (find-two *board*))) 2) (equal (block-or-win (return-triplet (find-two *board*))) 20)) (format t "My Move:") (make-move (block-win) 1 *board*) (print-board *board*) (player-move)) ((null (make-move guess 1 *board*)) (computer-move)) (t (format t "My Move:") (make-move guess 1 *board*) (print-board *board*) (player-move))))))) ;returns true if x or o is a winner otherwise returns nil (defun winner (*board*) (let ((win (mapcar #'(lambda (triplet) (let ((sum (+ (nth (first triplet) *board*) (nth (second triplet) *board*) (nth (third triplet) *board*)))) (cond ((equal sum 30) 30) ((equal sum 3) 3) (t nil)))) *triplets*))) (cond ((member 3 win) 3) ((member 30 win) 30) (t nil)))) ;sets board back to beginning state new board (defun new-board () (setf *board* '(board 0 0 0 0 0 0 0 0 0))) (defun play-game () (if (yes-or-no-p "Would you like to go first") (player-move) (computer-move)) (cond ((equal (winner *board*) 3) '(I win I computer)) ((equal (winner *board*) 30) '(You win)) (t '(Tie game)))) (defparameter *triplets* '((1 2 3) (4 5 6) (7 8 9) (1 4 7) (2 5 8) (3 6 9) (1 5 9) (3 5 7))) ;checks entire board to see if opponent has two in a row...return a list containing all positions that do (defun find-two (board) (mapcar #'(lambda (triplet) (let ((sum (+ (nth (first triplet) board) (nth (second triplet) board) (nth (third triplet) board)))) (cond ((equal sum 20) triplet) ((equal sum 2) triplet) (t nil)))) *triplets*)) ;returns triplet if there is one from a list of items...useful for find-two function (defun return-triplet (list) (find-if #'(lambda (item) (cond ((not (null item)) item) (t nil))) list)) ;finds empty space on the board...useful for finding the empty space to block when opponent is about to win. (defun block-space (list) (find-if #'(lambda (item) (cond ((equal (nth item *board*) 0) item) (t nil))) list)) ;makes use of three functions that were defined to return the space to be blocked when opponent is about to win (defun block-win () (block-space (return-triplet (find-two *board*)))) ;returns the result of checking to see what the sum of a three number list is ... returns two or twenty letting us know ;two would mean go for win in this game...twenty block opponent win (defun block-or-win (list) (cond ((null list) nil) (t (let ((sum (+ (nth (first list) *board*) (nth (second list) *board*) (nth (third list) *board*)))) (cond ((equal sum 2) 2) ((equal sum 20) 20) (t nil))))))
4,695
Common Lisp
.lisp
124
32.766129
120
0.609097
selsah/lisp-mastery
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
8a36af574568b8f4b1053a011fc2d1bec909f53c7fc4781282590c8a3d0530de
29,110
[ -1 ]
29,127
bpirate-uart.lisp
grepz_bpirate-cl/src/bpirate-uart.lisp
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (in-package #:bpirate-cl) (defparameter +BP-UART-SPEED+ (list sb-posix:B300 #b0000 sb-posix:B1200 #b0001 sb-posix:B2400 #b0010 sb-posix:B4800 #b0011 sb-posix:B9600 #b0100 sb-posix:B19200 #b0101 ;; 0110=31250 sb-posix:B38400 #b0111 sb-posix:B57600 #b1000 sb-posix:B115200 #b1001)) (defparameter +BP-UART-PARITY-8/N+ 0) (defparameter +BP-UART-PARITY-8/E+ 1) (defparameter +BP-UART-PARITY-8/O+ 2) (defparameter +BP-UART-PARITY-9/N+ 3) (defparameter +BP-UART-STOPBIT/1+ 0) (defparameter +BP-UART-STOPBIT/2+ 1) (defparameter +BP-UART-PINOUT/HiZ+ 0) (defparameter +BP-UART-PINOUT/3.3V+ 1) (defparameter +BP-UART-POLARITY/1+ 0) (defparameter +BP-UART-POLARITY/0+ 1) (defparameter +BP-UART-VERSION-CMD+ #b1 "00000001 – Display mode version string, responds 'ARTx' Once in binary UART mode, send 0×01 to get the current mode version string. The Bus Pirate responds ‘ARTx’, where x is the binary UART protocol version (currently 1). Get the version string at any time by sending 0×01 again. This command is the same in all binary modes, the current mode can always be determined by sending 0x01.") (defparameter +BP-UART-ECHO-CMD-MASK+ #b10 "0000001x – Start (0)/stop(1) echo UART RX In binary UART mode the UART is always active and receiving. Incoming data is only copied to the USB side if UART RX echo is enabled. This allows you to configure and control the UART mode settings without random data colliding with response codes. UART mode starts with echo disabled. This mode has no impact on data transmissions. Responds 0x01. Clears buffer overrun bit. ") (defparameter +BP-UART-BAUDCFG-CMD+ #b111 "00000111 – Manual baud rate configuration, send 2 bytes Configures the UART using custom baud rate generator settings. This command is followed by two data bytes that represent the BRG register value. Send the high 8 bits first, then the low 8 bits. Use the UART manual or an online calculator to find the correct value (key values: fosc 32mHz, clock divider = 2, BRGH=1) . Bus Pirate responds 0x01 to each byte. Settings take effect immediately.") (defparameter +BP-UART-BRIDGE-CMD+ #b1111 "00001111 - UART bridge mode (reset to exit) Starts a transparent UART bridge using the current configuration. Unplug the Bus Pirate to exit.") (defparameter +BP-UART-WRITE-CMD-MASK+ #b10000 "0001xxxx – Bulk UART write, send 1-16 bytes (0=1byte!) Bulk write transfers a packet of xxxx+1 bytes to the UART. Up to 16 data bytes can be sent at once. Note that 0000 indicates 1 byte because there’s no reason to send 0. BP replies 0×01 to each byte.") (defparameter +BP-UART-PERIPHCFG-CMD-MASK+ #b1000000 "0100wxyz – Configure peripherals w=power, x=pullups, y=AUX, z=CS Enable (1) and disable (0) Bus Pirate peripherals and pins. Bit w enables the power supplies, bit x toggles the on-board pull-up resistors, y sets the state of the auxiliary pin, and z sets the chip select pin. Features not present in a specific hardware version are ignored. Bus Pirate responds 0×01 on success. Note: CS pin always follows the current HiZ pin configuration. AUX is always a normal pin output (0=GND, 1=3.3volts).") (defparameter +BP-UART-BAUDSET-CMD-MASK+ #b1100000 "0110xxxx - Set UART speed Set the UART at a preconfigured speed value: 0000=300, 0001=1200, 0010=2400,0011=4800,0100=9600,0101=19200,0110=31250 (MIDI), 0111=38400,1000=57600,1010=115200 Start default is 300 baud. Bus Pirate responds 0×01 on success. A read command is planned but not implemented in this version.") (defparameter +BP-UART-CONF-CMD-MASK+ #b10000000 "100wxxyz – Configure UART settings w= pin output HiZ(0)/3.3v(1) xx=databits and parity 8/N(0), 8/E(1), 8/O(2), 9/N(3) y=stop bits 1(0)/2(1) z=RX polarity idle 1 (0), idle 0 (1) Startup default is 00000. Bus Pirate responds 0x01 on success. A read command is planned but not implemented in this version. Note: that this command code is three bits because the databits and parity setting consists of two bits. It is not quite the same as the binary SPI mode configuration command code.") (defclass bpirate-uart-mode (bpirate-mode) ((bridge :accessor uart-bridge) (baud :accessor uart-baud) (stopbit :accessor uart-stopbit) (polarity :accessor uart-polarity) (parity :accessor uart-parity) (pinout :accessor uart-pinout))) (defmethod bpirate-mode-start ((obj bpirate-uart-mode) stream &key (arg-baud sb-posix:B115200) (arg-stopbit +BP-UART-STOPBIT/1+) (arg-polarity +BP-UART-POLARITY/1+) (arg-parity +BP-UART-PARITY-8/N+) (arg-pinout +BP-UART-PINOUT/HiZ+) arg-bridge &allow-other-keys) (with-slots (bridge baud stopbit polarity parity pinout) obj (setf bridge arg-bridge baud arg-baud stopbit arg-stopbit polarity arg-polarity parity arg-parity pinout arg-pinout) (with-bp-cmd (out stream (make-array 1 :initial-element +BB-UART-CMD+ :element-type '(unsigned-byte 8)) :timeout 1) (format t "Starting UART mode, output '~a'" out) (flexi-streams:octets-to-string out)))) (defmethod bpirate-mode-stop ((obj bpirate-uart-mode) stream &key &allow-other-keys) (with-bp-cmd (out stream (make-array 1 :initial-element +BB-RESET-CMD+ :element-type '(unsigned-byte 8)) :timeout 1) (flexi-streams:octets-to-string out))) (defmethod bpirate-uart-write ((obj bpirate-uart-mode) stream data) (process-data-chunk stream data 16 'bpirate-write-chunk)) (defun bpirate-write-chunk (stream chunk sz) (let ((cmd (logior +BP-UART-WRITE-CMD-MASK+ (1- sz)))) (format t "Writing chunk(#~b) ~(~a, ~)/~a~%" cmd chunk sz) (with-bp-cmd (out stream (make-array 1 :element-type '(unsigned-byte 8) :initial-element cmd)) (when (/= (aref out 0) 1) (return-from bpirate-write-chunk 0))) (with-bp-cmd (out stream chunk :timeout 0.5) (loop for x across out with cnt = 0 when (= x 1) do (incf cnt) finally (return cnt))))) (defmethod bpirate-uart-echo ((obj bpirate-uart-mode) stream on) (let ((cmd (logior +BP-UART-ECHO-CMD-MASK+ on))) (format t "Setting UART echo ~[start~;stop~]~%" on) (with-bp-cmd (out stream (make-array 1 :element-type '(unsigned-byte 8) :initial-element cmd)) out))) (defmethod bpirate-uart-speed ((obj bpirate-uart-mode) stream speed) (let ((cmd (logior +BP-UART-BAUDSET-CMD-MASK+ (getf +BP-UART-SPEED+ speed)))) (format t "Setting UART speed: #~b~%" cmd) (with-bp-cmd (out stream (make-array 1 :element-type '(unsigned-byte 8) :initial-element cmd)) out))) (defmethod bpirate-uart-config ((obj bpirate-uart-mode) stream &key polarity stopbit parity pinout) (let ((cmd (logior +BP-UART-CONF-CMD-MASK+ (if polarity polarity (slot-value obj 'polarity)) (ash (if stopbit stopbit (slot-value obj 'stopbit)) 1) (ash (if parity parity (slot-value obj 'parity)) 2) (ash (if pinout pinout (slot-value obj 'pinout)) 4)))) (format t "Setting UART config: #~b~%" cmd) (with-bp-cmd (out stream (make-array 1 :element-type '(unsigned-byte 8) :initial-element cmd)) out))) (defmethod bpirate-uart-periph ((obj bpirate-uart-mode) stream &key (power 0) (pullups 0) (aux 0) (cs 0)) (let ((cmd (logior +BP-UART-PERIPHCFG-CMD-MASK+ cs (ash aux 1) (ash pullups 2) (ash power 3)))) (format t "Setting UART periph: #~b~%" cmd) (with-bp-cmd (out stream (make-array 1 :element-type '(unsigned-byte 8) :initial-element cmd)) out)))
7,592
Common Lisp
.lisp
158
44.436709
78
0.720504
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
9559361cfd0cd20e10e9824e5eed8b798576216fa82b409a8686e900d7df0cbe
29,127
[ -1 ]
29,128
package.lisp
grepz_bpirate-cl/src/package.lisp
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (defpackage #:bpirate-cl (:use :cl :sb-sys) (:export :bpirate-start :bpirate-stop))
156
Common Lisp
.lisp
6
23.166667
60
0.644295
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
f24684a0b03f0959af662c0cadebe7da8ea202e4f541aa1560732dd7f57b0277
29,128
[ -1 ]
29,129
serial.lisp
grepz_bpirate-cl/src/serial.lisp
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (in-package #:bpirate-cl) (defconstant +FIONREAD+ #x541B) (defun serial-open (path baud &key (vmin 0) (vtime 1)) ;; sb-posix:O-NDELAY sb-posix:O-NONBLOCK (let* ((fd (sb-posix:open path (logior sb-posix:O-NOCTTY sb-posix:O-RDWR))) (old (sb-posix:tcgetattr fd)) (new (sb-posix:tcgetattr fd))) (setf ;; LFLAG (sb-posix:termios-lflag new) (logandc2 (sb-posix:termios-lflag old) (logior sb-posix:icanon sb-posix:echo sb-posix:echoe sb-posix:echok sb-posix:echonl)) ;; CFLAG: baud | CS8 | CREAD | CLOCAL (sb-posix:termios-cflag new) (logior sb-posix:CS8 sb-posix:CREAD sb-posix:CLOCAL baud) ;; VMIN (aref (sb-posix:termios-cc new) sb-posix:vmin) vmin ;; VTIME (aref (sb-posix:termios-cc new) sb-posix:vtime) vtime) (sb-posix:tcflush fd sb-posix:TCIFLUSH) (sb-posix:tcsetattr fd sb-posix:TCSAFLUSH new) (make-fd-stream fd :input t :output t :buffering :none :element-type '(unsigned-byte 8)))) (defun serial-close (s) ;; TODO: (unless (null s) (close s))) (defun serial-recv-len (s) (sb-alien:with-alien ((bytes sb-alien:int)) (sb-posix:ioctl (fd-stream-fd s) +FIONREAD+ (sb-alien:addr bytes)) bytes)) (defun serial-read (s &key) (let ((n (serial-recv-len s))) (unless (zerop n)) (let ((res (make-sequence 'vector n))) (loop for i from 0 below n do (setf (aref res i) (read-byte s)) finally (return res))))) (defun serial-write (s data) (declare (vector data)) (loop for x across data do (write-byte x s) finally (finish-output s)))
1,656
Common Lisp
.lisp
45
32.044444
77
0.647756
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
926c2cca10a0fc0a7978c4e6e0fc09591fac9d35f7c88e00b1bfd33c25ff9f56
29,129
[ -1 ]
29,130
bpirate-mode.lisp
grepz_bpirate-cl/src/bpirate-mode.lisp
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (in-package #:bpirate-cl) (defparameter +BB-MODE-SIG+ "BBIO1") (defparameter +BB-SPI-MODE-SIG+ "SPI1") (defparameter +BB-I2C-MODE-SIG+ "I2C1") (defparameter +BB-UART-MODE-SIG+ "ART1") (defparameter +BB-1WIRE-MODE-SIG+ "1W01") (defparameter +BB-RAWWIRE-MODE-SIG+ "RAW1") (defparameter +BB-RESET-CMD+ #b0) (defparameter +BB-SPI-CMD+ #b1) (defparameter +BB-I2C-CMD+ #b10) (defparameter +BB-UART-CMD+ #b11) (defparameter +BB-1WIRE-CMD+ #b100) (defparameter +BB-RAWWIRE-CMD+ #b101) (defparameter +BB-JTAG-CMD+ #b110) (defparameter +BB-VP-MEASURE-CMD+ #b10100) (defparameter +BB-VP-MEASURE-FLOW-CMD+ #b10101) (defparameter +BB-FREQ-MEASURE-CMD+ #b10110) (defclass bpirate-mode () ((signature :initarg :signature))) (defgeneric bpirate-mode-start (obj s &key &allow-other-keys)) (defgeneric bpirate-mode-stop (obj s &key &allow-other-keys)) (defgeneric bpirate-mode-reset (obj s &key &allow-other-keys))
1,070
Common Lisp
.lisp
23
45.130435
62
0.660577
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
9b734534a878851bb9a26d92c8fb530d94e8ee8d3b315d7b83dedf6ec6bff376
29,130
[ -1 ]
29,131
bpirate.lisp
grepz_bpirate-cl/src/bpirate.lisp
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (in-package #:bpirate-cl) (defparameter +BB-TRY+ 20) (defparameter +BB-BP-RESET-CMD+ #b1111) (defparameter +BB-PINOUT-MASK+ #b01000000) (defparameter +BB-ONOFF-MASK+ #b10000000) (defparameter +BB-MODE-EXIT+ #xFF) (defclass bpirate () ((stream :reader bpirate-stream) (mode :reader bpirate-mode) (baud :accessor bpirate-baud) (device :accessor bpirate-device) (status :reader bpirate-status :initform '(:stream nil :bbmode nil)))) (defmethod initialize-instance :after ((obj bpirate) &key path (baud-key sb-posix:B115200) bbmode) (with-slots (baud device) obj (setf baud baud-key device path) (bpirate-start obj) (when bbmode (bpirate-bbmode obj)))) (defgeneric bpirate-start (obj)) (defmethod bpirate-start ((obj bpirate)) (with-slots (stream status baud device) obj (unless (getf status :stream) (setf stream (serial-open device baud)) (when stream (setf (getf status :stream) t) (serial-read stream))))) (defgeneric bpirate-stop (obj)) (defmethod bpirate-stop ((obj bpirate)) (with-slots (stream status) obj (when (getf status :stream) ;; Close device stream (close stream) (setf (getf status :stream) nil)))) (defgeneric bpirate-bbmode (obj &key mode-on)) (defmethod bpirate-bbmode ((obj bpirate) &key (mode-on t)) (with-slots (stream status) obj (when (getf (slot-value obj 'status) :stream) (if mode-on ;; Turn ON (unless (getf status :bbmode) (with-bp-cmd (out stream (make-sequence 'vector +BB-TRY+) :timeout 1) (when (string= +BB-MODE-SIG+ (flexi-streams:octets-to-string out)) (setf (getf status :bbmode) t)))) ;; Turn OFF (when (getf status :bbmode) (with-bp-cmd (out stream (make-array 1 :initial-element +BB-BP-RESET-CMD+ :element-type '(unsigned-byte 8))) (format t "~a" (flexi-streams:octets-to-string out)) (setf (getf status :bbmode) nil))))))) (defgeneric bpirate-init-mode (obj mode)) (defmethod bpirate-init-mode ((obj bpirate) bpmode) (with-slots (mode) obj (setf mode (cond ((eq bpmode :pwm) (make-instance 'bpirate-pwm-mode)) ((eq bpmode :uart) (make-instance 'bpirate-uart-mode)) ((eq bpmode :spi) (make-instance 'bpirate-spi-mode)) ((eq bpmode :test) (make-instance 'bpirate-test-mode)) (t nil))))) (defgeneric bpirate-deinit-mode (obj)) (defmethod bpirate-deinit-mode ((obj bpirate)) (setf (slot-value obj 'mode) nil))
2,527
Common Lisp
.lisp
71
31.478873
73
0.678557
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
4faeb8ba386664bd36700f4b58004b4a13f03b0058e2d0da207dee0648b56c9d
29,131
[ -1 ]
29,132
utils.lisp
grepz_bpirate-cl/src/utils.lisp
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (in-package #:bpirate-cl) (defmacro with-bp-cmd ((var s cmd &key (timeout 0.1)) &body body) `(let ((,var (gensym))) (serial-write ,s ,cmd) (sleep ,timeout) (setf ,var (serial-read ,s)) ,@body)) (defun oct-to-string (oct) (let* ((len (length oct)) (str (make-string len))) (loop for x from 0 below len do (setf (char str x) (code-char (aref oct x))) finally (return str)))) (defun process-data-chunk (stream data chunk fn) (loop with data-len = (length data) with ret = 0 with cpos = 0 for diff-len = (- data-len cpos) for chunk-len = (if (>= diff-len chunk) chunk diff-len) do (setf ret (apply fn (list stream (subseq data cpos (+ cpos chunk-len)) chunk-len))) (setf cpos (+ cpos chunk-len)) summing ret into total while (and (< cpos data-len) (= ret chunk-len)) finally (return total))) (defmacro test-list (lst f) (declare (symbol f) (list lst)) `(loop for l in ,lst always `(,@(funcall ,f l))))
1,099
Common Lisp
.lisp
34
27.5
66
0.596226
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
526c3058715ac32f612d9c20c387c259457acf15a2defc44ccc027a1ea963a54
29,132
[ -1 ]
29,133
bpirate-test.lisp
grepz_bpirate-cl/src/bpirate-test.lisp
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (in-package #:bpirate-cl) (defparameter +BB-SELFTEST-SHORT-CMD+ #b10000) (defparameter +BB-SELFTEST-LONG-CMD+ #b10001) (defclass bpirate-test-mode (bpirate-mode) ()) (defmethod bpirate-mode-start ((obj bpirate-test-mode) stream &key long-test &allow-other-keys) (with-bp-cmd (out stream (make-array 1 :initial-element (if long-test +BB-SELFTEST-LONG-CMD+ +BB-SELFTEST-SHORT-CMD+) :element-type '(unsigned-byte 8)) :timeout 1) out)) (defmethod bpirate-mode-stop ((obj bpirate-test-mode) stream &key &allow-other-keys) (with-bp-cmd (out stream (make-array 1 :initial-element +BB-MODE-EXIT+ :element-type '(unsigned-byte 8)) :timeout 1) out))
799
Common Lisp
.lisp
21
32.428571
72
0.658473
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
c12cee16d2e5fa29e6fc1371beb6c1075a1a05ad5fd5854c9686205aa16434db
29,133
[ -1 ]
29,134
bpirate-pwm.lisp
grepz_bpirate-cl/src/bpirate-pwm.lisp
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (in-package #:bpirate-cl) (defparameter +BP-OSC-FREQ+ 32000000) (defparameter +BP-PRESCALER-VALUES+ '(1 0 8 1 64 2 256 3)) ;; Plist (defparameter +BB-PWM-CMD+ #b10010) (defparameter +BB-PWM-CLR-CMD+ #b10011) (defclass bpirate-pwm-mode (bpirate-mode) ((ocr :accessor pwm-ocr) (pry :accessor pwm-pry) (tcy :accessor pwm-tcy))) (defmethod bpirate-mode-start ((obj bpirate-pwm-mode) stream &key prescaler period cycle &allow-other-keys) (with-slots (ocr pry tcy) obj (setf tcy (/ 2.0 +BP-OSC-FREQ+) pry (floor (1- (/ period (* Tcy prescaler)))) ocr (floor (* PRy cycle))) (let ((cmd (make-array 6 :element-type '(unsigned-byte 8) :initial-contents (list +BB-PWM-CMD+ (getf +BP-PRESCALER-VALUES+ prescaler) (logand (ash OCR -8) #xFF) (logand OCR #xFF) (logand (ash PRy -8) #xFF) (logand PRy #xFF))))) (format t "Setup. Period: ~a, Tcy: ~a, Prescaler: ~a, PRy: ~a, OCR: ~a.~%" period Tcy prescaler PRy OCR) (with-bp-cmd (out stream cmd) out)))) (defmethod bpirate-mode-stop ((obj bpirate-pwm-mode) stream &key &allow-other-keys) (with-bp-cmd (out stream (make-array 1 :element-type '(unsigned-byte 8) :initial-element +BB-PWM-CLR-CMD+)) out))
1,314
Common Lisp
.lisp
31
37.774194
80
0.643192
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
41825f8007b8907b3e183b30246ceceed10a2a488dce19e5496b2f9e53919c97
29,134
[ -1 ]
29,135
test.lisp
grepz_bpirate-cl/src/test.lisp
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (in-package #:bpirate-cl) (defparameter *test* nil) ;; XXX: Start (setq *test* nil) (setq *test* (make-instance 'bpirate :path "/dev/bp4" :bbmode t)) (bpirate-status *test*) ;; XXX: PWM (bpirate-init-mode *test* :pwm) (bpirate-mode-start (bpirate-mode *test*) (bpirate-stream *test*) :prescaler 1 :period 0.001 :cycle 0.5) (bpirate-mode-stop (bpirate-mode *test*) (bpirate-stream *test*)) (bpirate-deinit-mode *test*) ;; XXX: Self-test (bpirate-init-mode *test* :test) (bpirate-mode-start (bpirate-mode *test*) (bpirate-stream *test*)) (bpirate-mode-stop (bpirate-mode *test*) (bpirate-stream *test*)) (bpirate-deinit-mode *test*) ;; XXX: UART (bpirate-init-mode *test* :uart) (bpirate-mode-start (bpirate-mode *test*) (bpirate-stream *test*)) (bpirate-mode-stop (bpirate-mode *test*) (bpirate-stream *test*)) (bpirate-deinit-mode *test*) #+nil(bpirate-uart-write (bpirate-mode *test*) (bpirate-stream *test*) (make-array 5 :element-type '(unsigned-byte 8) :initial-contents (mapcar 'char-int '(#\t #\e #\s #\t #\linefeed)))) (bpirate-uart-echo (bpirate-mode *test*) (bpirate-stream *test*) 1) (bpirate-uart-speed (bpirate-mode *test*) (bpirate-stream *test*) sb-posix:B115200) (bpirate-uart-config (bpirate-mode *test*) (bpirate-stream *test*) :pinout +BP-UART-PINOUT/HiZ+) (bpirate-uart-periph (bpirate-mode *test*) (bpirate-stream *test*) :power 1 :pullups 0 :aux 1 :cs 0) #+nil(loop for x from 0 to 1000 with data = (make-array 19 :element-type '(unsigned-byte 8) :initial-contents (mapcar 'char-int '(#\t #\e #\s #\t #\! #\! #\! #\! #\@ #\# #\$ #\% #\^ #\& #\f #\o #\o #\linefeed #\newline))) do (bpirate-uart-write (bpirate-mode *test*) (bpirate-stream *test*) data) (sleep 0.5)) #+nil(loop for x from 0 to 1000 for data = (serial-read (bpirate-stream *test*)) do (sleep 0.1) (when (/= (length data) 0) (print data))) #+nil(loop for x across (serial-read (bpirate-stream *test*)) collect (code-char x)) ;; XXX: Stop (bpirate-bbmode *test* :mode-on nil) (bpirate-stop *test*) ;;; (bpirate-bbmode *test* :mode-on t) (bpirate-status *test*)
2,285
Common Lisp
.lisp
62
32.951613
70
0.638462
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
a42c4939dd5a10180ba14a5a129b4d111d004456f6d477695d200eb0e1c6af53
29,135
[ -1 ]
29,136
bpirate-cl.asd
grepz_bpirate-cl/bpirate-cl.asd
;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Coding:utf-8 -*- (asdf:defsystem bpirate-cl :version "0" :description "BusPirate v4 binary interface" :maintainer "Stanislav M. Ivankin <[email protected]>" :author "Stanislav M. Ivankin <[email protected]>" :licence "GPLv2" :depends-on (:sb-posix :flexi-streams) :serial t ;; components likely need manual reordering :components ((:module "src" :serial t :components ((:file "package") (:file "serial") (:file "utils") (:file "bpirate-mode") (:file "bpirate-test") (:file "bpirate-pwm") (:file "bpirate-uart") (:file "bpirate")))) ;; :long-description "" )
696
Common Lisp
.asd
22
26.454545
60
0.625557
grepz/bpirate-cl
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
c22cbc0f4f40bd019a82d1d4a583121a65960dcf5571d87dc27438b4431902fb
29,136
[ -1 ]
29,163
documentation-builder.lisp
foss-santanu_code-tools/code-docs/documentation-builder.lisp
;;; This is a wrapper around USER-MANUAL and XREF ;;; Collects the outputs from the tools in strings ;;; then preprocesses the strings to save in Markdown format (cl:defpackage "CODE-DOCS" (:use "COMMON-LISP") (:export #:create-xrefdb-for-source #:save-docs-for-source #:build-documentation)) (in-package "CODE-DOCS") (let ((xref-dbcreated (make-hash-table :test #'equal))) (defun spit-call-tree-to-stream (source-file) "spit-call-tree-to-stream: outputs XREF caller tree to a stream. Checks if XREF database for file is already created otherwise creates it. Arguments: source-file - full file path as string" (when (not (gethash source-file xref-dbcreated)) (xref:xref-file source-file nil nil) (setf (gethash source-file xref-dbcreated) t)) (setf string-call-tree (make-array '(0) :element-type 'base-char :fill-pointer 0 :adjustable t)) (xref:print-caller-trees :compact t)) (defun create-xrefdb-for-source (source-dir &optional (file-type "lisp")) "create-xrefdb-for-source: creates XREF database for all source files in SOURCE-DIR. Marks XREF-DBCREATED for the source file to TRUE. Arguments: source-dir - source directory path in string file-type - source file extension (default is lisp)" (setq source-files (directory (make-pathname :name :wild :type file-type :defaults (concatenate 'string source-dir "**/")))) (xref:clear-tables) (dolist (source-file source-files) (setq source-file (namestring source-file)) (xref:xref-file source-file nil nil) (setf (gethash source-file xref-dbcreated) t) )) ) (defmacro escape-markdown-before-output (&rest forms) "Escapes all the output strings for markdown format characters before passing them to standard output. FORMS represent valid LISP forms that produces output to standard output stream." `(let ((forms-output (make-array '(0) :element-type 'base-char :fill-pointer 0 :adjustable t))) ;; capture output to a string (with-output-to-string (*standard-output* forms-output) (progn ,@forms)) ;; escape each line of output for markdown (with-input-from-string (stream forms-output) (do ((line (read-line stream nil "EOF"))) ((string= line "EOF")) (if (zerop (length line)) (format t "~%") ;; only new-line character (progn (setq escaped-line (escape-line-markdown line)) (format t "~A~%" escaped-line))) (setq line (read-line stream nil "EOF")))))) (flet ((spit-documentation-for-file (source-file) (setq file-name (file-namestring source-file)) (setq dir-path (directory-namestring source-file)) (format t "~2&## Rudimentary Documentation for ~:@(~A~)" file-name) (format t "~2&*Containing Directory ~A*" dir-path) (format t "~2&### API Documentation~2%") (user-man:create-user-manual source-file :output-format :markdown))) (defun save-docs-for-source (source-dir &optional (file-type "lisp") doc-dir) "save-docs-for-source: saves source documentation in user_manual.md file. Also assumes that XREF database has been created for files in SOURCE-DIR. Arguments: source-dir - soure directory path in string file-type - source file extension (default is lisp) doc-dir - directory where user_manual.md is saved (default is source-dir" (when (not doc-dir) (setq doc-dir source-dir)) (setq source-files (directory (make-pathname :name :wild :type file-type :defaults (concatenate 'string source-dir "**/")))) (setq doc-file (make-pathname :name "user_manual" :type "md" :defaults doc-dir)) (with-open-file (s doc-file :direction :output :if-exists :supersede) (let ((*standard-output* s)) (dolist (source-file source-files) (spit-documentation-for-file source-file)) (format t "~3&## Dependency Documentations") (format t "~2&### File Dependencies~2%") (escape-markdown-before-output (xref:print-file-dependencies)) (format t "~2&### Call Dependencies~2%") (format t "~2&#### Function/Macro Calls~2%") (escape-markdown-before-output (xref:display-database :callers)) (format t "~2&#### Variable Readers~2%") (escape-markdown-before-output (xref:display-database :readers)) (format t "~2&#### Variable Setters~2%") (escape-markdown-before-output (xref:display-database :setters))))) ) (defmacro build-documentation (for file-type files in source-dir save at doc-dir) `(progn (setq xref:*handle-package-forms* '(lisp::in-package)) (create-xrefdb-for-source ,source-dir ,file-type) (save-docs-for-source ,source-dir ,file-type ,doc-dir))) (defun escape-line-markdown (line) "Escapes the Markdown format characters if present in LINE" (when (stringp line) (setq line-chars (mapcan #'(lambda (x) (case x ((#\* #\_ #\# #\` #\!) (list #\\ x)) (otherwise (list x)))) (coerce line 'list))) (coerce line-chars 'string)))
5,377
Common Lisp
.lisp
100
44.6
100
0.634239
foss-santanu/code-tools
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
49ed7b4b0c54b70661b0e21bec9136cad32dc15c0090b7c037fd398142cf899f
29,163
[ -1 ]
29,164
xref-patterns-for-macl.lisp
foss-santanu_code-tools/xref/xref-patterns-for-macl.lisp
;;; Thu Nov 15 21:50:05 1990 by Mark Kantrowitz <[email protected]> ;;; xref-patterns-for-macl.lisp ;;; **************************************************************** ;;; XREF Patterns for MACL ObjectLisp Functions ******************** ;;; **************************************************************** ;;; ;;; Written by Rodney Daughtrey, BCS AI Center, Huntsville, AL ;;; <[email protected]>. Please also send bug reports to ;;; <[email protected]>. ;;; ;;; This file contains XREF patterns defined for use with ObjectLisp ;;; functions in Macintosh Allegro Common Lisp (MACL). They have not ;;; been tested extensively, so there may be bugs. If you find any ;;; bugs, please send them to [email protected]. ;;; ;;; To Do: ;;; define patterns for other MACL-specific functions (in-package "XREF") (define-pattern-substitution keyword-value-pairs (:star symbol form)) (define-caller-pattern defobject (symbol (:star symbol)) :macl) (define-caller-pattern oneof (form keyword-value-pairs) :macl) (define-caller-pattern kindof (:star symbol) :macl) (define-caller-pattern remake-object (form (:optional form)) :macl) (define-caller-pattern exist (keyword-value-pairs) :macl) (define-caller-pattern init-list-default ((keyword-value-pairs) symbol form keyword-value-pairs) :macl) (define-caller-pattern ask (:plus form) :macl) (define-caller-pattern talkto (:optional form) :macl) (define-caller-pattern defobfun ((name form) lambda-list (:star (:or documentation-string declaration)) (:star form)) :macl) (define-caller-pattern fset (form form) :macl) (define-caller-pattern fset-globally (form form) :macl) (define-caller-pattern nfunction (symbol ((:eq LAMBDA) ((:star symbol)) (:star form))) :macl) (define-caller-pattern have (form form) :macl) (define-caller-pattern fhave (form fn) :macl) (define-caller-pattern makunbound-all (form) :macl) (define-caller-pattern fmakunbound-all (form) :macl) (define-caller-pattern ownp (form) :macl) (define-caller-pattern fownp (form) :macl) (define-caller-pattern bound-anywhere-p (form) :macl) (define-caller-pattern fbound-anywhere-p (form) :macl) (define-caller-pattern where (form) :macl) (define-caller-pattern fwhere (form) :macl) (define-caller-pattern self :macl) (define-caller-pattern objectp (form) :macl) (define-caller-pattern inherit-from-p (form form) :macl) (define-caller-pattern object-parents (form) :macl) (define-caller-pattern object-ancestors (form) :macl) (define-caller-pattern print-self (:optional form) :macl) (define-caller-pattern object-license (form) :macl) (define-caller-pattern license-to-object (form) :macl) (define-caller-pattern next-license-to-object (form) :macl) (define-caller-pattern highest-license-number :macl) (define-caller-pattern license-to-object (form) :macl) (define-caller-pattern do-all-objects ((symbol form) (:star form)) :macl) (define-caller-pattern do-object-variables ((variable form form) (:star form)) :macl) (define-caller-pattern do-object-functions ((variable form form) (:star form)) :macl)
3,142
Common Lisp
.lisp
82
35.841463
71
0.700033
foss-santanu/code-tools
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
aef89be7fe97ca7901fd7b1e162f6b24daf1b5834e957482c9b986e7e461889f
29,164
[ -1 ]
29,165
xref-test.lisp
foss-santanu_code-tools/xref/xref-test.lisp
;;; Mon Jan 21 15:43:39 1991 by Mark Kantrowitz <[email protected]> ;;; xref-test.lisp ;;; **************************************************************** ;;; Test Source File for XREF ************************************** ;;; **************************************************************** ;;; ;;; This file contains source code to be used to test XREF. ;;; ;;; Evaluating the following commented out code should produce the ;;; listed output. ;;; #| <cl> (xref:xref-file "xref-test.lisp") Cross-referencing file XRef/xref-test.lisp. ...... 6 forms processed. <cl> (xref:print-caller-trees) Rooted calling trees: TOP-LEVEL FROB FROB-ITEM APPEND-FROBS BARF FROWZ PROCESS-KEYS SNARF-ITEM PROCESS-KEY SYMBOL-NAME-KEY NODE-POSITION FROWZ PROCESS-KEYS SNARF-ITEM PROCESS-KEY SYMBOL-NAME-KEY NODE-POSITION NIL <cl> (xref:print-caller-trees :compact t) Rooted calling trees: TOP-LEVEL FROB FROB-ITEM APPEND-FROBS BARF FROWZ FROWZ PROCESS-KEYS SNARF-ITEM PROCESS-KEY SYMBOL-NAME-KEY NODE-POSITION NIL <cl> (xref:list-callers 'frowz) (BARF TOP-LEVEL) T <cl> (xref:list-users 'items) NIL NIL (FROWZ BARF FROB) |# ;;; ******************************** ;;; Test Source Program ************ ;;; ******************************** (defun top-level () "Top level function with null lambda list." (let* ((input (read)) (key (car input))) (declare (special key)) (case key (quit (return (values (frob (rest input)) 'quit))) (otherwise (cond ((member key '(foo bar baz)) (barf key (rest input))) (t (frowz (rest input) :key key))))))) (defun frob (items) "Here we test mapcar." (mapcar #'frob-item items)) (defun frob-item (item) "Here we test apply." (apply #'append-frobs item)) (defun barf (key &optional items) "Optional args test." (cons key (frowz items))) (defun frowz (items &key key) "Keyword args test." (dolist (item items) (let ((frowz (if (eq key 'quit) (intern (format nil "FOO~A" (round (+ (length (process-keys items)) 10))) 'keyword) (snarf-item item)))) (when (string-equal frowz (process-key key)) (setf (node-position key) 12) (return frowz))))) (defun process-key (key) (funcall #'symbol-name-key key)) ;;; *EOF*
2,393
Common Lisp
.lisp
98
20.693878
76
0.575678
foss-santanu/code-tools
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
d31f656f463ba36743dc665ddf6088c117d2b9ef52677b077a3148e75940b3b9
29,165
[ 216987 ]
29,166
code-docs.asd
foss-santanu_code-tools/code-docs/code-docs.asd
;; ASDF system definition file for CODE-DOCS ;; so that XREF can be loaded with ql:quickload (defpackage #:code-docs-sys (:use :cl :asdf)) (in-package :code-docs-sys) (defsystem #:code-docs :serial t :description "Documentation generator for a Lisp codebase" :author "Santanu Chakrabarti <[email protected]>" :version "0.1" :license "GPL" :depends-on (:xref :user-man) :components ((:file "documentation-builder")) )
449
Common Lisp
.asd
14
29.642857
63
0.732102
foss-santanu/code-tools
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
dfdfcbfda832975af8a768e2563b2a884f8fce7d41773ec4038248869788c9b6
29,166
[ -1 ]
29,167
user-man.asd
foss-santanu_code-tools/user_man/user-man.asd
;; ASDF system definition file for USER-MAN ;; so that XREF can be loaded with ql:quickload (defpackage #:user-man-sys (:use :cl :asdf)) (in-package :user-man-sys) (defsystem #:user-man :serial t :components ((:file "user-manual")))
241
Common Lisp
.asd
8
28.125
47
0.714286
foss-santanu/code-tools
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
4be22eabf7f25996bdffcf6198a9dc12e777ed228563082484dd3cce1fe09db0
29,167
[ -1 ]
29,168
xref.asd
foss-santanu_code-tools/xref/xref.asd
;; ASDF system definition file for XREF ;; so that XREF can be loaded with ql:quickload (defpackage #:xref-asd (:use :cl :asdf)) (in-package :xref-asd) (defsystem #:xref :serial t :components ((:file "xref") (:file "xref-patterns-for-macl")))
267
Common Lisp
.asd
9
26
49
0.666667
foss-santanu/code-tools
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
5257e90d6136134dc4e38a2c9c0584e83b4f14bacb9f5b77d9455d16cb534062
29,168
[ -1 ]
29,171
user_manual.md
foss-santanu_code-tools/user_manual.md
## Rudimentary Documentation for XREF.LISP *Containing Directory /host/santanu/programming/Lisp/code-tools/xref/* ### API Documentation #### LOOKUP (symbol environment) [FUNCTION] --- #### CAR-EQ (list item) [FUNCTION] --- #### \*FILE-CALLERS-DATABASE\* ((make-hash-table :test #'equal)) [VARIABLE] > > Contains name and list of file callers (files which call) for that > name. --- #### \*CALLERS-DATABASE\* ((make-hash-table :test #'equal)) [VARIABLE] > > Contains name and list of callers (function invocation) for that > name. --- #### \*READERS-DATABASE\* ((make-hash-table :test #'equal)) [VARIABLE] > > Contains name and list of readers (variable use) for that name. --- #### \*SETTERS-DATABASE\* ((make-hash-table :test #'equal)) [VARIABLE] > > Contains name and list of setters (variable mutation) for that name. --- #### \*CALLEES-DATABASE\* ((make-hash-table :test #'equal)) [VARIABLE] > > Contains name and list of functions and variables it calls. --- #### CALLERS-LIST (name &optional (database :callers)) [FUNCTION] --- #### (SETF CALLERS-LIST) (caller) [SETF MAPPING] --- #### LIST-CALLERS (symbol) [FUNCTION] > > Lists all functions which call SYMBOL as a function (function > invocation). --- #### LIST-READERS (symbol) [FUNCTION] > > Lists all functions which refer to SYMBOL as a variable > (variable reference). --- #### LIST-SETTERS (symbol) [FUNCTION] > > Lists all functions which bind/set SYMBOL as a variable > (variable mutation). --- #### LIST-USERS (symbol) [FUNCTION] > > Lists all functions which use SYMBOL as a variable or function. --- #### WHO-CALLS (symbol &optional how) [FUNCTION] > > Lists callers of symbol. HOW may be :function, :reader, :setter, > or :variable. --- #### WHAT-FILES-CALL (symbol) [FUNCTION] > > Lists names of files that contain uses of SYMBOL > as a function, variable, or constant. --- #### LIST-CALLEES (symbol) [FUNCTION] > > Lists names of functions and variables called by SYMBOL. --- #### \*SOURCE-FILE\* ((make-hash-table :test #'equal)) [VARIABLE] > > Contains function name and source file for that name. --- #### SOURCE-FILE (symbol) [FUNCTION] > > Lists the names of files in which SYMBOL is defined/used. --- #### (SETF SOURCE-FILE) (value) [SETF MAPPING] --- #### CLEAR-TABLES () [FUNCTION] --- #### \*PATTERN-CALLER-TYPE\* ((make-hash-table :test #'equal)) [VARIABLE] --- #### PATTERN-CALLER-TYPE (name) [FUNCTION] --- #### (SETF PATTERN-CALLER-TYPE) (value) [SETF MAPPING] --- #### \*PATTERN-SUBSTITUTION-TABLE\* ((make-hash-table :test #'equal)) [VARIABLE] > > Stores general patterns for function destructuring. --- #### LOOKUP-PATTERN-SUBSTITUTION (name) [FUNCTION] --- #### DEFINE-PATTERN-SUBSTITUTION (name pattern) [MACRO] > > Defines NAME to be equivalent to the specified pattern. Useful for > making patterns more readable. For example, the LAMBDA-LIST is > defined as a pattern substitution, making the definition of the > DEFUN caller-pattern simpler. --- #### \*CALLER-PATTERN-TABLE\* ((make-hash-table :test #'equal)) [VARIABLE] > > Stores patterns for function destructuring. --- #### LOOKUP-CALLER-PATTERN (name) [FUNCTION] --- #### DEFINE-CALLER-PATTERN (name pattern &optional caller-type) [MACRO] > > Defines NAME as a function/macro call with argument structure > described by PATTERN. CALLER-TYPE, if specified, assigns a type to > the pattern, which may be used to exclude references to NAME while > viewing the database. For example, all the Common Lisp definitions > have a caller-type of :lisp or :lisp2, so that you can exclude > references to common lisp functions from the calling tree. --- #### DEFINE-VARIABLE-PATTERN (name &optional caller-type) [MACRO] > > Defines NAME as a variable reference of type CALLER-TYPE. This is > mainly used to establish the caller-type of the variable. --- #### DEFINE-CALLER-PATTERN-SYNONYMS (source destinations) [MACRO] > > For defining function caller pattern syntax synonyms. For each name > in DESTINATIONS, defines its pattern as a copy of the definition > of SOURCE. Allows a large number of identical patterns to be defined > simultaneously. Must occur after the SOURCE has been defined. --- #### CLEAR-PATTERNS () [FUNCTION] --- #### \*LAST-FORM\* (nil) [VARIABLE] > > The last form read from the file. Useful for figuring out what went > wrong when xref-file drops into the debugger. --- #### \*XREF-VERBOSE\* (t) [VARIABLE] > > When T, xref-file(s) prints out the names of the files it looks at, > progress dots, and the number of forms read. --- #### XREF-FILES (&rest files) [FUNCTION] > > Grovels over the lisp code located in source file FILES, using > xref-file. --- #### \*HANDLE-PACKAGE-FORMS\* (nil) [VARIABLE] > > When non-NIL, and XREF-FILE sees a package-setting form like > IN-PACKAGE, sets the current package to the specified package by > evaluating the form. When done with the file, xref-file resets the > package to its original value. In some of the displaying functions, > when this variable is non-NIL one may specify that all symbols from a > particular set of packages be ignored. This is only useful if the > files use different packages with conflicting names. --- #### \*NORMAL-READTABLE\* ((copy-readtable nil)) [VARIABLE] > > Normal, unadulterated CL readtable. --- #### XREF-FILE (filename &optional (clear-tables t) (verbose *xref-verbose*)) [FUNCTION] > > Cross references the function and variable calls in FILENAME by > walking over the source code located in the file. Defaults type of > filename to ".lisp". Chomps on the code using record-callers and > record-callers*. If CLEAR-TABLES is T (the default), it clears the > callers database before processing the file. Specify CLEAR-TABLES as > nil to append to the database. If VERBOSE is T (the default), prints > out the name of the file, one progress dot for each form processed, > and the total number of forms. --- #### \*HANDLE-FUNCTION-FORMS\* (t) [VARIABLE] > > When T, XREF-FILE tries to be smart about forms which occur in > a function position, such as lambdas and arbitrary Lisp forms. > If so, it recursively calls record-callers with pattern 'FORM. > If the form is a lambda, makes the caller a caller of > :unnamed-lambda. --- #### \*HANDLE-MACRO-FORMS\* (t) [VARIABLE] > > When T, if the file was loaded before being processed by XREF, and > the car of a form is a macro, it notes that the parent calls the > macro, and then calls macroexpand-1 on the form. --- #### \*CALLEES-DATABASE-INCLUDES-VARIABLES\* (nil) [VARIABLE] --- #### RECORD-CALLERS (filename form &optional pattern parent (environment nil) funcall) [FUNCTION] > > RECORD-CALLERS is the main routine used to walk down the code. It > matches the PATTERN against the FORM, possibly adding statements to > the database. PARENT is the name defined by the current outermost > definition; it is the caller of the forms in the body (e.g., FORM). > ENVIRONMENT is used to keep track of the scoping of variables. > FUNCALL deals with the type of variable assignment and hence how the > environment should be modified. RECORD-CALLERS handles atomic > patterns and simple list-structure patterns. For complex > list-structure pattern destructuring, it calls RECORD-CALLERS*. --- #### RECORD-CALLERS\* (filename form pattern parent environment &optional continuation in-optionals in-keywords) [FUNCTION] > > RECORD-CALLERS* handles complex list-structure patterns, such as > ordered lists of subpatterns, patterns involving :star, :plus, > &optional, &key, &rest, and so on. CONTINUATION is a stack of > unprocessed patterns, IN-OPTIONALS and IN-KEYWORDS are > corresponding stacks which determine whether &rest or &key has been > seen yet in the current pattern. --- #### \*TYPES-TO-IGNORE\* ('(:lisp :lisp2)) [VARIABLE] > > Default set of caller types (as specified in the patterns) to ignore > in the database handling functions. :lisp is CLtL 1st edition, > :lisp2 is additional patterns from CLtL 2nd edition. --- #### DISPLAY-DATABASE (&optional (database :callers) (types-to-ignore *types-to-ignore*)) [FUNCTION] > > Prints out the name of each symbol and all its callers. Specify > database :callers (the default) to get function call references, > :fill to the get files in which the symbol is called, :readers to get > variable references, and :setters to get variable binding and > assignments. Ignores functions of types listed in types-to-ignore. --- #### WRITE-CALLERS-DATABASE-TO-FILE (filename) [FUNCTION] > > Saves the contents of the current callers database to a file. This > file can be loaded to restore the previous contents of the > database. (For large systems it can take a long time to crunch > through the code, so this can save some time.) --- #### INVERT-HASH-TABLE (table &optional (types-to-ignore *types-to-ignore*)) [FUNCTION] > > Makes a copy of the hash table in which (name value*) pairs > are inverted to (value name*) pairs. --- #### DETERMINE-FILE-DEPENDENCIES ( &optional (database *callers-database*)) [FUNCTION] > > Makes a hash table of file dependencies for the references listed in > DATABASE. This function may be useful for automatically resolving > file references for automatic creation of a system definition > (defsystem). --- #### PRINT-FILE-DEPENDENCIES ( &optional (database *callers-database*)) [FUNCTION] > > Prints a list of file dependencies for the references listed in > DATABASE. This function may be useful for automatically computing > file loading constraints for a system definition tool. --- #### \*LAST-CALLER-TREE\* (nil) [VARIABLE] --- #### \*DEFAULT-GRAPHING-MODE\* (:call-graph) [VARIABLE] > > Specifies whether we graph up or down. If :call-graph, the children > of a node are the functions it calls. If :caller-graph, the > children of a node are the functions that call it. --- #### GATHER-TREE (parents &optional already-seen (mode *default-graphing-mode*) (types-to-ignore *types-to-ignore*) compact) [FUNCTION] > > Extends the tree, copying it into list structure, until it repeats > a reference (hits a cycle). --- #### FIND-ROOTS-AND-CYCLES (&optional (mode *default-graphing-mode*) (types-to-ignore *types-to-ignore*)) [FUNCTION] > > Returns a list of uncalled callers (roots) and called callers > (potential cycles). --- #### MAKE-CALLER-TREE (&optional (mode *default-graphing-mode*) (types-to-ignore *types-to-ignore*) compact) [FUNCTION] > > Outputs list structure of a tree which roughly represents the > possibly cyclical structure of the caller database. > If mode is :call-graph, the children of a node are the functions > it calls. If mode is :caller-graph, the children of a node are the > functions that call it. > If compact is T, tries to eliminate the already-seen nodes, so > that the graph for a node is printed at most once. Otherwise it will > duplicate the node's tree (except for cycles). This is usefull > because the call tree is actually a directed graph, so we can either > duplicate references or display only the first one. --- #### \*INDENT-AMOUNT\* (3) [VARIABLE] > > Number of spaces to indent successive levels in PRINT-INDENTED-TREE. --- #### PRINT-INDENTED-TREE (trees &optional (indent 0)) [FUNCTION] > > Simple code to print out a list-structure tree (such as those created > by make-caller-tree) as indented text. --- #### PRINT-CALLER-TREES (&key (mode *default-graphing-mode*) (types-to-ignore *types-to-ignore*) compact root-nodes) [FUNCTION] > > Prints the calling trees (which may actually be a full graph and not > necessarily a DAG) as indented text trees using > PRINT-INDENTED-TREE. MODE is :call-graph for trees where the children > of a node are the functions called by the node, or :caller-graph for > trees where the children of a node are the functions the node calls. > TYPES-TO-IGNORE is a list of funcall types (as specified in the > patterns) to ignore in printing out the database. For example, > '(:lisp) would ignore all calls to common lisp functions. COMPACT is > a flag to tell the program to try to compact the trees a bit by not > printing trees if they have already been seen. ROOT-NODES is a list > of root nodes of trees to display. If ROOT-NODES is nil, tries to > find all root nodes in the database. --- ## Rudimentary Documentation for XREF-TEST.LISP *Containing Directory /host/santanu/programming/Lisp/code-tools/xref/* ### API Documentation #### TOP-LEVEL () [FUNCTION] > > Top level function with null lambda list. --- #### FROB (items) [FUNCTION] > > Here we test mapcar. --- #### FROB-ITEM (item) [FUNCTION] > > Here we test apply. --- #### BARF (key &optional items) [FUNCTION] > > Optional args test. --- #### FROWZ (items &key key) [FUNCTION] > > Keyword args test. --- #### PROCESS-KEY (key) [FUNCTION] --- ## Rudimentary Documentation for XREF-PATTERNS-FOR-MACL.LISP *Containing Directory /host/santanu/programming/Lisp/code-tools/xref/* ### API Documentation ## Rudimentary Documentation for USER-MANUAL.LISP *Containing Directory /host/santanu/programming/Lisp/code-tools/user_man/* ### API Documentation #### \*USERMAN-VERSION\* ("2.0 20-oct-94") [PARAMETER] > > Current verison number/date for User-Manual. --- #### USERMAN-COPYRIGHT (&optional (stream *standard-output*)) [FUNCTION] > > Prints a User Manual copyright notice and header upon startup. --- #### EXTRACT-DOCUMENTATION (body) [MACRO] --- #### ATOM-OR-CAR (list-or-atom) [FUNCTION] --- #### \*DOCUMENTATION-HANDLERS\* ((make-hash-table :test #'equal)) [VARIABLE] > > Hash table of entries of the form (handler description), > where definer is the car of the definition form handled (for > example, DEFUN or DEFMACRO), handler is a function which takes the > form as input and value-returns the name, argument-list and > documentation string, and description is a one-word equivalent of > definer (for example, FUNCTION or MACRO). --- #### DEFINE-DOC-HANDLER (definer arglist description &body body) [MACRO] > > Defines a new documentation handler. DEFINER is the car of the > definition form handled (e.g., defun), DESCRIPTION is a one-word > string equivalent of definer (e.g., "function"), and ARGLIST > and BODY together define a function that takes the form as input > and value-returns the name, argument-list, documentation string, > and a list of any qualifiers of the form. --- #### FIND-DOC-HANDLER (definer) [FUNCTION] > > Given the car of a form, finds the appropriate documentation > handler for the form if one exists. --- #### LISTIFY (x) [FUNCTION] --- #### NULL-OR-CDR (l) [FUNCTION] --- #### NULL-OR-CADR (l) [FUNCTION] --- #### \*FAILED-DEFINITION-TYPES\* (nil) [VARIABLE] > > List of definition types that create-user-manual couldn't handle. --- #### CREATE-USER-MANUAL (filename &key (output-format 'text) (output-stream *standard-output*) (purge-latex t)) [FUNCTION] > > Automatically creates a user manual for the functions in a file by > collecting the documentation strings and argument lists of the > functions and formatting the output nicely. Returns a list of the > definition types of the forms it couldn't handle. Output-format > may be either 'TEXT, 'SCRIBE or 'LATEX. In this last case the extra > keyword 'purge-latex' may be specified: if non nil the latex > filter will try to substitute possible dangerous characters like '&', > '\' and '#'. --- #### HANDLE-FORM-OUTPUT (form &optional (output-format 'text) (stream *standard-output*) (purge-latex t)) [FUNCTION] > > This function takes a form as input and outputs its documentation > segment to the output stream. --- #### FIND-KEYWORD (sym) [FUNCTION] --- #### OUTPUT-FRAME-DOCUMENTATION (name type args documentation &optional (stream *standard-output*)) [FUNCTION] > > Prints out the user guide entry for a form in FrameMaker(tm) mode. --- #### OUTPUT-TEXT-DOCUMENTATION (name type args documentation args-tab-pos type-pos &optional (stream *standard-output*)) [FUNCTION] > > Prints out the user guide entry for a form in TEXT mode. --- #### OUTPUT-MARKDOWN-DOCUMENTATION (name type args documentation args-tab-pos type-pos &optional (stream *standard-output*)) [FUNCTION] > > Prints out the user guide entry for a form in MARKDOWN mode. --- #### ESCAPE-NAME-FOR-MARKDOWN (name) [FUNCTION] > > Escapes the Markdown format characters if present in NAME --- #### OUTPUT-SCRIBE-DOCUMENTATION (name type args documentation &optional (stream *standard-output*)) [FUNCTION] > > Prints out the user guide entry for a form in SCRIBE mode. --- #### OUTPUT-LATEX-DOCUMENTATION (name type args documentation &optional (stream *standard-output*) (purge-documentation t)) [FUNCTION] > > Prints out the user guide entry for a form in LaTeX mode. --- #### PURGE-STRING-FOR-LATEX (a-string purge-doc) [FUNCTION] > > Tries to purge a string from characters that are potentially > dangerous for LaTeX. --- #### PREPROCESS-LAMBDA-KEYWORDS (args) [FUNCTION] > > Unused --- #### PREPROCESS-LISP-LATEX-CLASHES (args purge-doc) [FUNCTION] > > This function is used to make the strings for the arguments of the > form digestible for LaTeX, e.g. by removing '#' and '&'. --- #### PREPROCESS-CHARACTER (c) [FUNCTION] > > Low level processing of single characters, when passed as defaults > to optional, key and aux parameters. --- #### PREPROCESS-SPECIALS (list-form purge-doc) [FUNCTION] > > Processing of some 'special' forms. Only 'quote' and 'function' are > treated for the time being. --- #### SPLIT-STRING (string width &optional arglistp filled (trim-whitespace t)) [FUNCTION] > > Splits a string into a list of strings, each of which is shorter > than the specified width. Tries to be intelligent about where to > split the string if it is an argument list. If filled is T, > tries to fill out the strings as much as possible. This function > is used to break up long argument lists nicely, and to break up > wide lines of documentation nicely. --- #### SPLIT-POINT (string max-length &optional arglistp filled) [FUNCTION] > > Finds an appropriate point to break the string at given a target > length. If arglistp is T, tries to find an intelligent position to > break the string. If filled is T, tries to fill out the string as > much as possible. --- #### LAMBDA-LIST-KEYWORD-POSITION (string &optional end trailer-only) [FUNCTION] > > If the previous symbol is a lambda-list keyword, returns > its position. Otherwise returns end. --- #### BALANCED-PARENTHESIS-POSITION (string &optional end) [FUNCTION] > > Finds the position of the left parenthesis which is closest to END > but leaves the prefix of the string with balanced parentheses or > at most 1 unbalanced left parenthesis. --- #### UM-BUILD-SYMBOL (symbol &key (prefix nil prefix-p) (suffix nil suffix-p) (package nil package-p)) [FUNCTION] > > Build a symbol concatenating prefix (if not null), symbol, and suffix > (if not null). The newly generated symbol is interned in package, if > not null, or in the SYMBOL-PACKAGE of symbol, otherwise. --- #### CREATE-MANUALS (files &key (extension '.cl) (output-format 'text)) [FUNCTION] --- #### PARSE-WITH-DELIMITER (line &optional (delim #\newline)) [FUNCTION] > > Breaks LINE into a list of strings, using DELIM as a > breaking point. --- ## Rudimentary Documentation for DOCUMENTATION-BUILDER.LISP *Containing Directory /host/santanu/programming/Lisp/code-tools/code-docs/* ### API Documentation #### SPIT-CALL-TREE-TO-STREAM (source-file) [FUNCTION] > > spit-call-tree-to-stream: outputs XREF caller tree to a stream. > Checks if XREF database for file is already created otherwise > creates it. > Arguments: source-file - full file path as string --- #### CREATE-XREFDB-FOR-SOURCE (source-dir &optional (file-type "lisp")) [FUNCTION] > > create-xrefdb-for-source: creates XREF database for all source files > in SOURCE-DIR. Marks XREF-DBCREATED for the source file to TRUE. > Arguments: source-dir - source directory path in string > file-type - source file extension (default is lisp) --- #### ESCAPE-MARKDOWN-BEFORE-OUTPUT (&rest forms) [MACRO] > > Escapes all the output strings for markdown format characters before > passing them to standard output. FORMS represent valid LISP forms > that produces output to standard output stream. --- #### SAVE-DOCS-FOR-SOURCE (source-dir &optional (file-type "lisp") doc-dir) [FUNCTION] > > save-docs-for-source: saves source documentation in user_manual.md > file. Also assumes that XREF database has been created for files in > SOURCE-DIR. > Arguments: source-dir - soure directory path in string > file-type - source file extension (default is lisp) > doc-dir - directory where user_manual.md is saved > (default is source-dir --- #### BUILD-DOCUMENTATION (for file-type files in source-dir save at doc-dir) [MACRO] --- #### ESCAPE-LINE-MARKDOWN (line) [FUNCTION] > > Escapes the Markdown format characters if present in LINE --- ## Dependency Documentations ### File Dependencies "/host/santanu/programming/Lisp/code-tools/xref/xref-test.lisp" --> ("/host/santanu/programming/Lisp/code-tools/xref/xref-test.lisp") "/host/santanu/programming/Lisp/code-tools/user\_man/user-manual.lisp" --> ("/host/santanu/programming/Lisp/code-tools/user\_man/user-manual.lisp" "/host/santanu/programming/Lisp/code-tools/code-docs/documentation-builder.lisp") "/host/santanu/programming/Lisp/code-tools/code-docs/documentation-builder.lisp" --> ("/host/santanu/programming/Lisp/code-tools/code-docs/documentation-builder.lisp") "/host/santanu/programming/Lisp/code-tools/xref/xref.lisp" --> ("/host/santanu/programming/Lisp/code-tools/xref/xref.lisp" "/host/santanu/programming/Lisp/code-tools/code-docs/documentation-builder.lisp") ### Call Dependencies #### Function/Macro Calls XREF:DISPLAY-DATABASE is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::ESCAPE-LINE-MARKDOWN is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. XREF:PRINT-FILE-DEPENDENCIES is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::ESCAPE-MARKDOWN-BEFORE-OUTPUT is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::SPIT-DOCUMENTATION-FOR-FILE is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. XREF:PRINT-CALLER-TREES is referenced by CODE-DOCS::SPIT-CALL-TREE-TO-STREAM. USER-MAN:CREATE-USER-MANUAL is referenced by CODE-DOCS::SPIT-DOCUMENTATION-FOR-FILE USER-MAN:CREATE-MANUALS. USER-MAN::UM-BUILD-SYMBOL is referenced by USER-MAN:CREATE-MANUALS. USER-MAN::BALANCED-PARENTHESIS-POSITION is referenced by USER-MAN::BALANCED-PARENTHESIS-POSITION USER-MAN::SPLIT-POINT. USER-MAN::LAMBDA-LIST-KEYWORD-POSITION is referenced by USER-MAN::SPLIT-POINT. USER-MAN::SPLIT-POINT is referenced by USER-MAN::SPLIT-STRING. USER-MAN::PARSE-WITH-DELIMITER is referenced by USER-MAN::PARSE-WITH-DELIMITER USER-MAN::SPLIT-STRING. USER-MAN::PREPROCESS-CHARACTER is referenced by USER-MAN::PREPROCESS-LISP-LATEX-CLASHES. USER-MAN::PREPROCESS-SPECIALS is referenced by USER-MAN::PREPROCESS-LISP-LATEX-CLASHES. USER-MAN::PURGE-STRING-FOR-LATEX is referenced by USER-MAN::PREPROCESS-SPECIALS USER-MAN::PREPROCESS-LISP-LATEX-CLASHES USER-MAN::OUTPUT-LATEX-DOCUMENTATION. USER-MAN::PREPROCESS-LISP-LATEX-CLASHES is referenced by USER-MAN::PREPROCESS-SPECIALS USER-MAN::OUTPUT-LATEX-DOCUMENTATION. USER-MAN::ESCAPE-NAME-FOR-MARKDOWN is referenced by USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION. USER-MAN::OUTPUT-LATEX-DOCUMENTATION is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::OUTPUT-SCRIBE-DOCUMENTATION is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::OUTPUT-TEXT-DOCUMENTATION is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::SPLIT-STRING is referenced by USER-MAN::OUTPUT-LATEX-DOCUMENTATION USER-MAN::OUTPUT-SCRIBE-DOCUMENTATION USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION USER-MAN::OUTPUT-TEXT-DOCUMENTATION USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::HANDLER is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::FIND-DOC-HANDLER is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN:HANDLE-FORM-OUTPUT is referenced by USER-MAN:HANDLE-FORM-OUTPUT USER-MAN:CREATE-USER-MANUAL. SYMBOL-NAME-KEY is referenced by PROCESS-KEY. NODE-POSITION is referenced by FROWZ. PROCESS-KEY is referenced by FROWZ. SNARF-ITEM is referenced by FROWZ. PROCESS-KEYS is referenced by FROWZ. APPEND-FROBS is referenced by FROB-ITEM. FROB-ITEM is referenced by FROB. FROWZ is referenced by BARF TOP-LEVEL. BARF is referenced by TOP-LEVEL. FROB is referenced by TOP-LEVEL. XREF:MAKE-CALLER-TREE is referenced by XREF:PRINT-CALLER-TREES. XREF:PRINT-INDENTED-TREE is referenced by XREF:PRINT-CALLER-TREES XREF:PRINT-INDENTED-TREE. XREF::GATHER-TREE is referenced by XREF:PRINT-CALLER-TREES XREF:MAKE-CALLER-TREE. XREF::FIND-ROOTS-AND-CYCLES is referenced by XREF:MAKE-CALLER-TREE. XREF::AMASS-TREE is referenced by XREF::AMASS-TREE. XREF:DETERMINE-FILE-DEPENDENCIES is referenced by XREF:PRINT-FILE-DEPENDENCIES. XREF::PATTERN-CALLER-TYPE is referenced by XREF::FIND-ROOTS-AND-CYCLES XREF::AMASS-TREE XREF::INVERT-HASH-TABLE XREF:DISPLAY-DATABASE. :UNNAMED-LAMBDA is referenced by CODE-DOCS::ESCAPE-LINE-MARKDOWN USER-MAN::PREPROCESS-LISP-LATEX-CLASHES USER-MAN::PREPROCESS-LAMBDA-KEYWORDS USER-MAN::ESCAPE-NAME-FOR-MARKDOWN USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION XREF::FIND-ROOTS-AND-CYCLES XREF:PRINT-FILE-DEPENDENCIES XREF:DETERMINE-FILE-DEPENDENCIES XREF::INVERT-HASH-TABLE XREF:WRITE-CALLERS-DATABASE-TO-FILE XREF:DISPLAY-DATABASE. XREF::CAR-EQ is referenced by XREF::RECORD-CALLERS\*. XREF::RECORD-CALLERS\* is referenced by XREF::RECORD-CALLERS\* XREF::RECORD-CALLERS. XREF::LOOKUP-PATTERN-SUBSTITUTION is referenced by XREF::RECORD-CALLERS. XREF::LOOKUP-CALLER-PATTERN is referenced by XREF::RECORD-CALLERS. XREF::LOOKUP is referenced by XREF::RECORD-CALLERS. XREF::RECORD-CALLERS is referenced by XREF::RECORD-CALLERS\* XREF::RECORD-CALLERS. XREF:SOURCE-FILE is referenced by XREF:DETERMINE-FILE-DEPENDENCIES XREF::RECORD-CALLERS. XREF:CLEAR-TABLES is referenced by CODE-DOCS:CREATE-XREFDB-FOR-SOURCE XREF:XREF-FILE. XREF:XREF-FILE is referenced by CODE-DOCS:CREATE-XREFDB-FOR-SOURCE CODE-DOCS::SPIT-CALL-TREE-TO-STREAM XREF:XREF-FILES. XREF:LIST-SETTERS is referenced by XREF:WHO-CALLS XREF:LIST-USERS. XREF:LIST-READERS is referenced by XREF:WHO-CALLS XREF:LIST-USERS. XREF:LIST-CALLERS is referenced by XREF:WHO-CALLS XREF:LIST-USERS. XREF::CALLERS-LIST is referenced by XREF::RECORD-CALLERS XREF:LIST-CALLEES XREF:WHAT-FILES-CALL XREF:LIST-SETTERS XREF:LIST-READERS XREF:LIST-CALLERS. #### Variable Readers CODE-DOCS::LINE-CHARS is referenced by CODE-DOCS::ESCAPE-LINE-MARKDOWN. CODE-DOCS::ESCAPED-LINE is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::DOC-FILE is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::DIR-PATH is referenced by CODE-DOCS::SPIT-DOCUMENTATION-FOR-FILE. CODE-DOCS::FILE-NAME is referenced by CODE-DOCS::SPIT-DOCUMENTATION-FOR-FILE. CODE-DOCS::SOURCE-FILES is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE CODE-DOCS:CREATE-XREFDB-FOR-SOURCE. CODE-DOCS::STRING-CALL-TREE is referenced by CODE-DOCS::SPIT-CALL-TREE-TO-STREAM. USER-MAN::IN is referenced by USER-MAN:CREATE-MANUALS. USER-MAN::FILE is referenced by USER-MAN:CREATE-MANUALS. USER-MAN::FOR is referenced by USER-MAN:CREATE-MANUALS. USER-MAN::NAME-CHARS is referenced by USER-MAN::ESCAPE-NAME-FOR-MARKDOWN. USER-MAN::P\_ARGS is referenced by USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION. USER-MAN::\*FAILED-DEFINITION-TYPES\* is referenced by USER-MAN:HANDLE-FORM-OUTPUT USER-MAN:CREATE-USER-MANUAL. USER-MAN::\*DOCUMENTATION-HANDLERS\* is referenced by USER-MAN::FIND-DOC-HANDLER. USER-MAN::\*USERMAN-VERSION\* is referenced by USER-MAN::USERMAN-COPYRIGHT. XREF:\*INDENT-AMOUNT\* is referenced by XREF:PRINT-INDENTED-TREE. XREF:\*DEFAULT-GRAPHING-MODE\* is referenced by XREF:PRINT-CALLER-TREES XREF:MAKE-CALLER-TREE XREF::FIND-ROOTS-AND-CYCLES XREF::GATHER-TREE. XREF:\*HANDLE-PACKAGE-FORMS\* is referenced by XREF:DISPLAY-DATABASE. XREF:\*TYPES-TO-IGNORE\* is referenced by XREF:PRINT-CALLER-TREES XREF:MAKE-CALLER-TREE XREF::FIND-ROOTS-AND-CYCLES XREF::GATHER-TREE XREF::INVERT-HASH-TABLE XREF:DISPLAY-DATABASE. XREF:\*HANDLE-MACRO-FORMS\* is referenced by XREF::RECORD-CALLERS. XREF::\*CALLEES-DATABASE-INCLUDES-VARIABLES\* is referenced by XREF::RECORD-CALLERS. XREF:\*HANDLE-FUNCTION-FORMS\* is referenced by XREF::RECORD-CALLERS. XREF::\*NORMAL-READTABLE\* is referenced by XREF:XREF-FILE. XREF:\*XREF-VERBOSE\* is referenced by XREF:XREF-FILE. XREF::\*CALLER-PATTERN-TABLE\* is referenced by XREF:CLEAR-PATTERNS XREF::LOOKUP-CALLER-PATTERN. XREF::\*PATTERN-SUBSTITUTION-TABLE\* is referenced by XREF:CLEAR-PATTERNS XREF::LOOKUP-PATTERN-SUBSTITUTION. XREF::\*PATTERN-CALLER-TYPE\* is referenced by XREF:CLEAR-PATTERNS XREF::PATTERN-CALLER-TYPE. XREF::\*SOURCE-FILE\* is referenced by XREF:WRITE-CALLERS-DATABASE-TO-FILE XREF:CLEAR-TABLES XREF:SOURCE-FILE. XREF::\*SETTERS-DATABASE\* is referenced by XREF:WRITE-CALLERS-DATABASE-TO-FILE XREF:DISPLAY-DATABASE XREF:CLEAR-TABLES XREF::CALLERS-LIST. XREF::\*READERS-DATABASE\* is referenced by XREF:WRITE-CALLERS-DATABASE-TO-FILE XREF:DISPLAY-DATABASE XREF:CLEAR-TABLES XREF::CALLERS-LIST. XREF::\*CALLERS-DATABASE\* is referenced by XREF::FIND-ROOTS-AND-CYCLES XREF::GATHER-TREE XREF:PRINT-FILE-DEPENDENCIES XREF:DETERMINE-FILE-DEPENDENCIES XREF:WRITE-CALLERS-DATABASE-TO-FILE XREF:DISPLAY-DATABASE XREF:CLEAR-TABLES XREF::CALLERS-LIST. XREF::\*CALLEES-DATABASE\* is referenced by XREF::FIND-ROOTS-AND-CYCLES XREF::GATHER-TREE XREF:WRITE-CALLERS-DATABASE-TO-FILE XREF:CLEAR-TABLES XREF::CALLERS-LIST. XREF::\*FILE-CALLERS-DATABASE\* is referenced by XREF:WRITE-CALLERS-DATABASE-TO-FILE XREF:DISPLAY-DATABASE XREF:CLEAR-TABLES XREF::CALLERS-LIST. #### Variable Setters CODE-DOCS::X is referenced by CODE-DOCS::ESCAPE-LINE-MARKDOWN. CODE-DOCS::LINE-CHARS is referenced by CODE-DOCS::ESCAPE-LINE-MARKDOWN. CODE-DOCS::AT is referenced by CODE-DOCS:BUILD-DOCUMENTATION. CODE-DOCS::SAVE is referenced by CODE-DOCS:BUILD-DOCUMENTATION. CODE-DOCS::IN is referenced by CODE-DOCS:BUILD-DOCUMENTATION. CODE-DOCS::FILES is referenced by CODE-DOCS:BUILD-DOCUMENTATION. CODE-DOCS::FOR is referenced by CODE-DOCS:BUILD-DOCUMENTATION. CODE-DOCS::ESCAPED-LINE is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::LINE is referenced by CODE-DOCS::ESCAPE-LINE-MARKDOWN CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::FORMS-OUTPUT is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::S is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::DOC-FILE is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::DOC-DIR is referenced by CODE-DOCS:BUILD-DOCUMENTATION CODE-DOCS:SAVE-DOCS-FOR-SOURCE. CODE-DOCS::DIR-PATH is referenced by CODE-DOCS::SPIT-DOCUMENTATION-FOR-FILE. CODE-DOCS::FILE-NAME is referenced by CODE-DOCS::SPIT-DOCUMENTATION-FOR-FILE. CODE-DOCS::FORMS is referenced by CODE-DOCS::ESCAPE-MARKDOWN-BEFORE-OUTPUT. CODE-DOCS::SOURCE-FILES is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE CODE-DOCS:CREATE-XREFDB-FOR-SOURCE. CODE-DOCS::FILE-TYPE is referenced by CODE-DOCS:BUILD-DOCUMENTATION CODE-DOCS:SAVE-DOCS-FOR-SOURCE CODE-DOCS:CREATE-XREFDB-FOR-SOURCE. CODE-DOCS::SOURCE-DIR is referenced by CODE-DOCS:BUILD-DOCUMENTATION CODE-DOCS:SAVE-DOCS-FOR-SOURCE CODE-DOCS:CREATE-XREFDB-FOR-SOURCE. CODE-DOCS::SOURCE-FILE is referenced by CODE-DOCS:SAVE-DOCS-FOR-SOURCE CODE-DOCS::SPIT-DOCUMENTATION-FOR-FILE CODE-DOCS:CREATE-XREFDB-FOR-SOURCE CODE-DOCS::SPIT-CALL-TREE-TO-STREAM. USER-MAN::DELIM is referenced by USER-MAN::PARSE-WITH-DELIMITER. USER-MAN::LINE is referenced by USER-MAN::PARSE-WITH-DELIMITER. USER-MAN::EXTENSION is referenced by USER-MAN:CREATE-MANUALS. USER-MAN::FILES is referenced by USER-MAN:CREATE-MANUALS. USER-MAN::NEWNAME is referenced by USER-MAN::UM-BUILD-SYMBOL. USER-MAN::PACKAGE-P is referenced by USER-MAN::UM-BUILD-SYMBOL. USER-MAN::SUFFIX-P is referenced by USER-MAN::UM-BUILD-SYMBOL. USER-MAN::SUFFIX is referenced by USER-MAN::UM-BUILD-SYMBOL. USER-MAN::PREFIX-P is referenced by USER-MAN::UM-BUILD-SYMBOL. USER-MAN::PREFIX is referenced by USER-MAN::UM-BUILD-SYMBOL. USER-MAN::RIGHTMOST-LEFT-PAREN is referenced by USER-MAN::BALANCED-PARENTHESIS-POSITION. USER-MAN::LEFTMOST-RIGHT-PAREN is referenced by USER-MAN::BALANCED-PARENTHESIS-POSITION. USER-MAN::LEFTMOST-LEFT-PAREN is referenced by USER-MAN::BALANCED-PARENTHESIS-POSITION. USER-MAN::IMBALANCE is referenced by USER-MAN::BALANCED-PARENTHESIS-POSITION. USER-MAN::NUM-RIGHT is referenced by USER-MAN::BALANCED-PARENTHESIS-POSITION. USER-MAN::NUM-LEFT is referenced by USER-MAN::BALANCED-PARENTHESIS-POSITION. USER-MAN::RIGHTMOST-SPACE is referenced by USER-MAN::LAMBDA-LIST-KEYWORD-POSITION. USER-MAN::AMPERSAND is referenced by USER-MAN::LAMBDA-LIST-KEYWORD-POSITION. USER-MAN::TRAILER-ONLY is referenced by USER-MAN::LAMBDA-LIST-KEYWORD-POSITION. USER-MAN::END is referenced by USER-MAN::BALANCED-PARENTHESIS-POSITION USER-MAN::LAMBDA-LIST-KEYWORD-POSITION. USER-MAN::PAREN is referenced by USER-MAN::SPLIT-POINT. USER-MAN::POS is referenced by USER-MAN::PARSE-WITH-DELIMITER USER-MAN::SPLIT-POINT. USER-MAN::SPACE-POS is referenced by USER-MAN::SPLIT-POINT. USER-MAN::MAX-LENGTH is referenced by USER-MAN::SPLIT-POINT. USER-MAN::S is referenced by USER-MAN::SPLIT-STRING. USER-MAN::STRING-LIST is referenced by USER-MAN::SPLIT-STRING. USER-MAN::TRIM-WHITESPACE is referenced by USER-MAN::SPLIT-STRING. USER-MAN::FILLED is referenced by USER-MAN::SPLIT-POINT USER-MAN::SPLIT-STRING. USER-MAN::ARGLISTP is referenced by USER-MAN::SPLIT-POINT USER-MAN::SPLIT-STRING. USER-MAN::LIST-FORM is referenced by USER-MAN::PREPROCESS-SPECIALS. USER-MAN::C is referenced by USER-MAN::PREPROCESS-CHARACTER USER-MAN::PURGE-STRING-FOR-LATEX. USER-MAN::EOS is referenced by USER-MAN::PURGE-STRING-FOR-LATEX. USER-MAN::RESULT is referenced by USER-MAN::SPLIT-STRING USER-MAN::PURGE-STRING-FOR-LATEX. USER-MAN::A-STR is referenced by USER-MAN::PURGE-STRING-FOR-LATEX. USER-MAN::PURGE-DOC is referenced by USER-MAN::PREPROCESS-SPECIALS USER-MAN::PREPROCESS-LISP-LATEX-CLASHES USER-MAN::PURGE-STRING-FOR-LATEX. USER-MAN::A-STRING is referenced by USER-MAN::PURGE-STRING-FOR-LATEX. USER-MAN::PURGE-DOCUMENTATION is referenced by USER-MAN::OUTPUT-LATEX-DOCUMENTATION. USER-MAN::NAME-CHARS is referenced by USER-MAN::ESCAPE-NAME-FOR-MARKDOWN. USER-MAN::P\_ARGS is referenced by USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION. USER-MAN::ARGS-TAB-POS is referenced by USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION USER-MAN::OUTPUT-TEXT-DOCUMENTATION. USER-MAN::ARG is referenced by USER-MAN::PREPROCESS-LISP-LATEX-CLASHES USER-MAN::PREPROCESS-LAMBDA-KEYWORDS USER-MAN::OUTPUT-SCRIBE-DOCUMENTATION USER-MAN::OUTPUT-TEXT-DOCUMENTATION USER-MAN::OUTPUT-FRAME-DOCUMENTATION. USER-MAN::FIRST-&OPTIONAL-P is referenced by USER-MAN::OUTPUT-FRAME-DOCUMENTATION. USER-MAN::FIRST-&KEY-P is referenced by USER-MAN::OUTPUT-FRAME-DOCUMENTATION. USER-MAN::FIRST-&AUX-P is referenced by USER-MAN::OUTPUT-FRAME-DOCUMENTATION. USER-MAN::&OPTIONAL-P is referenced by USER-MAN::OUTPUT-FRAME-DOCUMENTATION. USER-MAN::&AUX-P is referenced by USER-MAN::OUTPUT-FRAME-DOCUMENTATION. USER-MAN::&KEY-P is referenced by USER-MAN::OUTPUT-FRAME-DOCUMENTATION. USER-MAN::&REST-P is referenced by USER-MAN::OUTPUT-FRAME-DOCUMENTATION. USER-MAN::SYM is referenced by USER-MAN::FIND-KEYWORD. USER-MAN::F is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::WIDTH is referenced by USER-MAN::SPLIT-STRING USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::ARGS-LIST-FORM is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::TYPE-POS is referenced by USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION USER-MAN::OUTPUT-TEXT-DOCUMENTATION USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::NAME-LENGTH is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::QUALIFIERS is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::ARGS is referenced by USER-MAN::PREPROCESS-LISP-LATEX-CLASHES USER-MAN::PREPROCESS-LAMBDA-KEYWORDS USER-MAN::OUTPUT-LATEX-DOCUMENTATION USER-MAN::OUTPUT-SCRIBE-DOCUMENTATION USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION USER-MAN::OUTPUT-TEXT-DOCUMENTATION USER-MAN::OUTPUT-FRAME-DOCUMENTATION USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::NAME is referenced by USER-MAN::OUTPUT-LATEX-DOCUMENTATION USER-MAN::OUTPUT-SCRIBE-DOCUMENTATION USER-MAN::ESCAPE-NAME-FOR-MARKDOWN USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION USER-MAN::OUTPUT-TEXT-DOCUMENTATION USER-MAN::OUTPUT-FRAME-DOCUMENTATION USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::HANDLER is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::HANDLER-ENTRY is referenced by USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::KEY is referenced by USER-MAN::OUTPUT-FRAME-DOCUMENTATION USER-MAN:HANDLE-FORM-OUTPUT. USER-MAN::FORM is referenced by USER-MAN:HANDLE-FORM-OUTPUT USER-MAN:CREATE-USER-MANUAL. USER-MAN::EOF is referenced by USER-MAN:CREATE-USER-MANUAL. USER-MAN::\*FAILED-DEFINITION-TYPES\* is referenced by USER-MAN:CREATE-USER-MANUAL. USER-MAN::PURGE-LATEX is referenced by USER-MAN:HANDLE-FORM-OUTPUT USER-MAN:CREATE-USER-MANUAL. USER-MAN::OUTPUT-STREAM is referenced by USER-MAN:CREATE-USER-MANUAL. USER-MAN::OUTPUT-FORMAT is referenced by USER-MAN:CREATE-MANUALS USER-MAN:HANDLE-FORM-OUTPUT USER-MAN:CREATE-USER-MANUAL. USER-MAN::FILENAME is referenced by USER-MAN:CREATE-USER-MANUAL. USER-MAN::L is referenced by USER-MAN::NULL-OR-CADR USER-MAN::NULL-OR-CDR. USER-MAN::X is referenced by USER-MAN::ESCAPE-NAME-FOR-MARKDOWN USER-MAN::OUTPUT-MARKDOWN-DOCUMENTATION USER-MAN::LISTIFY. USER-MAN::DESCRIPTION is referenced by USER-MAN:DEFINE-DOC-HANDLER. USER-MAN::ARGLIST is referenced by USER-MAN:DEFINE-DOC-HANDLER. USER-MAN::DEFINER is referenced by USER-MAN::FIND-DOC-HANDLER USER-MAN:DEFINE-DOC-HANDLER. USER-MAN::LIST-OR-ATOM is referenced by USER-MAN::ATOM-OR-CAR. USER-MAN::BODY is referenced by USER-MAN::EXTRACT-DOCUMENTATION. FROWZ is referenced by FROWZ. ITEM is referenced by FROWZ FROB-ITEM. ITEMS is referenced by FROWZ BARF FROB. KEY is referenced by PROCESS-KEY FROWZ BARF TOP-LEVEL. INPUT is referenced by TOP-LEVEL. XREF::CYCLES is referenced by XREF:PRINT-CALLER-TREES. XREF::ROOTED is referenced by XREF:PRINT-CALLER-TREES. XREF::ROOT-NODES is referenced by XREF:PRINT-CALLER-TREES. XREF::TREE is referenced by XREF:PRINT-INDENTED-TREE. XREF::INDENT is referenced by XREF:PRINT-INDENTED-TREE. XREF::MORE-TREES is referenced by XREF:MAKE-CALLER-TREE. XREF:\*LAST-CALLER-TREE\* is referenced by XREF:MAKE-CALLER-TREE. XREF::TREES is referenced by XREF:PRINT-INDENTED-TREE XREF:MAKE-CALLER-TREE. XREF::OTHER-DATABASE is referenced by XREF::FIND-ROOTS-AND-CYCLES. XREF::CALLED-CALLERS is referenced by XREF:MAKE-CALLER-TREE XREF::FIND-ROOTS-AND-CYCLES. XREF::UNCALLED-CALLERS is referenced by XREF:MAKE-CALLER-TREE XREF::FIND-ROOTS-AND-CYCLES. XREF::THIS-ITEM is referenced by XREF::AMASS-TREE. XREF::RESULT is referenced by XREF::AMASS-TREE. XREF::\*ALREADY-SEEN\* is referenced by XREF::GATHER-TREE. XREF::COMPACT is referenced by XREF:PRINT-CALLER-TREES XREF:MAKE-CALLER-TREE XREF::GATHER-TREE. XREF::MODE is referenced by XREF:PRINT-CALLER-TREES XREF:MAKE-CALLER-TREE XREF::FIND-ROOTS-AND-CYCLES XREF::GATHER-TREE. XREF::ALREADY-SEEN is referenced by XREF:MAKE-CALLER-TREE XREF::AMASS-TREE XREF::GATHER-TREE. XREF::PARENTS is referenced by XREF::AMASS-TREE XREF::GATHER-TREE. XREF::S is referenced by XREF:DETERMINE-FILE-DEPENDENCIES. XREF::VALUE-FILE is referenced by XREF:DETERMINE-FILE-DEPENDENCIES. XREF::KEY-FILE is referenced by XREF:DETERMINE-FILE-DEPENDENCIES. XREF::FILE-REF-HT is referenced by XREF:DETERMINE-FILE-DEPENDENCIES. XREF::VALUE is referenced by XREF::FIND-ROOTS-AND-CYCLES XREF:PRINT-FILE-DEPENDENCIES XREF:DETERMINE-FILE-DEPENDENCIES XREF::INVERT-HASH-TABLE. XREF::KEY is referenced by XREF:PRINT-FILE-DEPENDENCIES XREF:DETERMINE-FILE-DEPENDENCIES XREF::INVERT-HASH-TABLE. XREF::TARGET is referenced by XREF::INVERT-HASH-TABLE. XREF::TABLE is referenced by XREF::INVERT-HASH-TABLE. XREF::Y is referenced by XREF:WRITE-CALLERS-DATABASE-TO-FILE. XREF::X is referenced by XREF:WRITE-CALLERS-DATABASE-TO-FILE. XREF::CALLERS is referenced by XREF:DISPLAY-DATABASE. XREF::TYPES-TO-IGNORE is referenced by XREF:PRINT-CALLER-TREES XREF:MAKE-CALLER-TREE XREF::FIND-ROOTS-AND-CYCLES XREF::GATHER-TREE XREF::INVERT-HASH-TABLE XREF:DISPLAY-DATABASE. XREF::PAR is referenced by XREF::RECORD-CALLERS\*. XREF::PATTERN-ELT is referenced by XREF::RECORD-CALLERS\*. XREF::IN-KEYWORDS is referenced by XREF::RECORD-CALLERS\*. XREF::IN-OPTIONALS is referenced by XREF::RECORD-CALLERS\*. XREF::CONTINUATION is referenced by XREF::RECORD-CALLERS\*. XREF::ENV is referenced by XREF::RECORD-CALLERS\* XREF::RECORD-CALLERS. XREF::P is referenced by XREF::RECORD-CALLERS. XREF::D is referenced by XREF:DETERMINE-FILE-DEPENDENCIES XREF::RECORD-CALLERS. XREF::PROCESSED is referenced by XREF::RECORD-CALLERS\* XREF::RECORD-CALLERS. XREF::SUBPAT is referenced by XREF::RECORD-CALLERS. XREF::NEW-PATTERN is referenced by XREF::RECORD-CALLERS. XREF::PARENT is referenced by XREF::AMASS-TREE XREF::RECORD-CALLERS\* XREF::RECORD-CALLERS. XREF::FORM is referenced by XREF::RECORD-CALLERS\* XREF::RECORD-CALLERS XREF:XREF-FILE. XREF::OLD-PACKAGE is referenced by XREF:XREF-FILE. XREF::VERBOSE is referenced by XREF:XREF-FILE. XREF:CLEAR-TABLES is referenced by XREF:XREF-FILE. XREF::FILENAME is referenced by XREF:WRITE-CALLERS-DATABASE-TO-FILE XREF::RECORD-CALLERS\* XREF::RECORD-CALLERS XREF:XREF-FILE. XREF::FILE is referenced by XREF:XREF-FILES. XREF::FILES is referenced by XREF:XREF-FILES. XREF::DESTINATIONS is referenced by XREF:DEFINE-CALLER-PATTERN-SYNONYMS. XREF::SOURCE is referenced by XREF:DEFINE-CALLER-PATTERN-SYNONYMS. XREF::CALLER-TYPE is referenced by XREF:DEFINE-VARIABLE-PATTERN XREF:DEFINE-CALLER-PATTERN. XREF::PATTERN is referenced by XREF::RECORD-CALLERS\* XREF::RECORD-CALLERS XREF:DEFINE-CALLER-PATTERN XREF:DEFINE-PATTERN-SUBSTITUTION. XREF::HOW is referenced by XREF:WHO-CALLS. XREF::DATABASE is referenced by XREF::FIND-ROOTS-AND-CYCLES XREF::GATHER-TREE XREF:PRINT-FILE-DEPENDENCIES XREF:DETERMINE-FILE-DEPENDENCIES XREF:DISPLAY-DATABASE XREF::CALLERS-LIST. XREF::NAME is referenced by XREF::FIND-ROOTS-AND-CYCLES XREF:DISPLAY-DATABASE XREF:DEFINE-VARIABLE-PATTERN XREF:DEFINE-CALLER-PATTERN XREF::LOOKUP-CALLER-PATTERN XREF:DEFINE-PATTERN-SUBSTITUTION XREF::LOOKUP-PATTERN-SUBSTITUTION XREF::PATTERN-CALLER-TYPE XREF::CALLERS-LIST. XREF::ITEM is referenced by XREF::CAR-EQ. XREF::FRAME is referenced by XREF::LOOKUP. XREF::ENVIRONMENT is referenced by XREF::RECORD-CALLERS\* XREF::RECORD-CALLERS XREF::LOOKUP.
46,604
Common Lisp
.l
779
57.58665
389
0.710083
foss-santanu/code-tools
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
938032ede714d1bbe9d975d3c17ad4843c6bcde6d97cab7658a61f304aafa4e4
29,171
[ -1 ]
29,173
user-manual.ps
foss-santanu_code-tools/user_man/user-manual.ps
%! PS-Adobe-2.0 %%Creator: dvips by Radical Eye Software %%Title: zut.dvi %%Pages: 4 -1 %%BoundingBox: 0 0 612 792 %%EndComments %%BeginDocument: texc.pro /TeXDict 200 dict def TeXDict begin /bdf{bind def}def /@rigin{72 Resolution div dup neg scale translate}bdf /@letter{Resolution dup -10 mul @rigin}bdf /@landscape{[0 1 -1 0 0 0]concat Resolution dup @rigin}bdf /@a4{Resolution dup -10.6929133858 mul @rigin}bdf /@legal{Resolution dup -13 mul @rigin}bdf /@manualfeed{statusdict /manualfeed true put}bdf /@copies{/#copies exch def} bdf /@FontMatrix[1 0 0 -1 0 0]def /@FontBBox[0 0 0 0]def /dmystr(ZZf@@@)def /newname{dmystr cvn}bdf /df{/fontname exch def dmystr 2 fontname cvx(@@@@)cvs putinterval newname 7 dict def newname load begin /FontType 3 def /FontMatrix @FontMatrix def /FontBBox @FontBBox def /BitMaps 256 array def /BuildChar{ CharBuilder}def /Encoding IdentityEncoding def end fontname{/foo setfont}2 array copy cvx def fontname load 0 dmystr 6 string copy cvn cvx put}bdf /dfe{ newname dup load definefont setfont}bdf /ch-image{ch-data 0 get}bdf /ch-width{ ch-data 1 get}bdf /ch-height{ch-data 2 get}bdf /ch-xoff{ch-data 3 get}bdf /ch-yoff{ch-data 4 get}bdf /ch-dx{ch-data 5 get}bdf /CharBuilder{save 3 1 roll exch /BitMaps get exch get /ch-data exch def ch-data null ne{ch-dx 0 ch-xoff ch-yoff neg ch-xoff ch-width add ch-height ch-yoff sub setcachedevice ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-height ch-yoff sub .1 add]/id ch-image def /rw ch-width 7 add 8 idiv string def /rc 0 def /gp 0 def /cp 0 def{rc 0 ne{rc 1 sub /rc exch def rw}{G}ifelse}imagemask}if restore}bdf /G{{ id gp get /gp gp 1 add def dup 18 mod exch 18 idiv pl exch get exec}loop}bdf /adv{cp add /cp exch def}bdf /chg{rw cp id gp 4 index getinterval putinterval dup gp add /gp exch def adv}bdf /nd{/cp 0 def rw exit}bdf /lsh{rw cp 2 copy get dup 0 eq{pop 1}{dup 255 eq{pop 254}{dup dup add 255 and exch 1 and or} ifelse}ifelse put 1 adv}bdf /rsh{rw cp 2 copy get dup 0 eq{pop 128}{dup 255 eq {pop 127}{dup 2 idiv exch 128 and or}ifelse}ifelse put 1 adv}bdf /clr{rw cp 2 index string putinterval adv}bdf /set{rw cp fillstr 0 4 index getinterval putinterval adv}bdf /fillstr 18 string 0 1 17{2 copy 255 put pop}for def /pl[{ adv 1 chg}bind{adv 1 chg nd}bind{1 add chg}bind{1 add chg nd}bind{adv lsh} bind{adv lsh nd}bind{adv rsh}bind{adv rsh nd}bind{1 add adv}bind{/rc exch def nd}bind{1 add set}bind{1 add clr}bind{adv 2 chg}bind{adv 2 chg nd}bind{pop nd} bind]def /dc{/ch-code exch def /ch-data exch def newname load /BitMaps get ch-code ch-data put}bdf /bop{gsave /SaveImage save def 0 0 moveto}bdf /eop{ clear SaveImage restore showpage grestore}bdf /@start{/Resolution exch def /IdentityEncoding 256 array def 0 1 255{IdentityEncoding exch 1 string dup 0 3 index put cvn put}for}bdf /p{show}bdf /RuleMatrix[1 0 0 -1 -.1 -.1]def /BlackDots 8 string def /v{gsave currentpoint translate false RuleMatrix{ BlackDots}imagemask grestore}bdf /a{moveto}bdf /delta 0 def /tail{dup /delta exch def 0 rmoveto}bdf /b{exch show tail}bdf /c{show delta 4 sub tail}bdf /d{ show delta 3 sub tail}bdf /e{show delta 2 sub tail}bdf /f{show delta 1 sub tail}bdf /g{show delta 0 rmoveto}bdf /h{show delta 1 add tail}bdf /i{show delta 2 add tail}bdf /j{show delta 3 add tail}bdf /k{show delta 4 add tail} bdf /l{show -4 0 rmoveto}bdf /m{show -3 0 rmoveto}bdf /n{show -2 0 rmoveto} bdf /o{show -1 0 rmoveto}bdf /q{show 1 0 rmoveto}bdf /r{show 2 0 rmoveto}bdf /s{show 3 0 rmoveto}bdf /t{show 4 0 rmoveto}bdf /w{0 rmoveto}bdf /x{0 exch rmoveto}bdf /y{3 2 roll show moveto}bdf /bos{/section save def}bdf /eos{clear section restore}bdf end %%EndDocument TeXDict begin 300 @start /fa df[<12C0A27E1260A212701230A212381218A2121C120CA2 120E1206A212077EA213801201A313C01200A213E01360A213701330A213381318A2131C130CA2 130E1306A213071303A2>16 45 3 11 23]110 dc dfe /fb df[<133FEBE0C0EA01C0380381E0 EA0701A290C7FCA6B512E0EA0700B2387FC3FE>23 32 0 0 25]12 dc[<EA7038EAF87CEAFC7E A2EA743AEA0402A3EA0804A2EA1008A2EA2010EA4020>15 14 2 -18 23]34 dc[<010313C0A3 EB070101061380A4EB0E03010C1300A4EB1C07EB1806007FB512FCB612FE3900300C00A3EB701C EB6018A4B612FE6C14FC3901C07000EB8060A4000313E0495AA4EA070100065BA3>31 41 3 9 38]35 dc[<137813841201EA03021207A45BA25BA26C5A9038A00FFC9038C003E090388001C039 01C00080EC0100EA03E000041302EA08F03818700438307808EA70386D5AEAF01EEB0E206D5A90 3803C0081270D8780113103938067030391C1838603907E00F80>30 34 2 1 35]38 dc[<1270 12F812FCA212741204A31208A21210A212201240>6 14 4 -18 13]39 dc[<132013401380EA01 00120212065AA25AA25AA312701260A312E0AC1260A312701230A37EA27EA27E12027EEA008013 401320>11 46 3 12 18]40 dc[<7E12407E7E7E120C7EA27EA2EA0180A313C01200A313E0AC13 C0A312011380A3EA0300A21206A25A12085A5A5A5A>11 46 3 12 18]41 dc[<127012F812FCA2 12741204A31208A21210A212201240>6 14 4 9 13]44 dc[<EAFFC0A2>10 2 1 -9 15]45 dc[ <127012F8A31270>5 5 4 0 13]46 dc[<EA01801203120F12F31203B3A6EA07C0EAFFFE>15 30 4 0 23]49 dc[<EA03F0EA0C1CEA100E487E00401380128000F013C0EAF803A3EA200712001480 A2EB0F00130E5B5B5B13605B485A48C7FC000613405A5A00101380EA3FFF5AB5FC>18 30 2 0 23]50 dc[<EA03F0EA0C1CEA100EEA200F007813801307A2EA380F12001400A2130E5B5BEA03F0 EA003C130E130FEB0780A214C0122012F8A300F013801240EB0F00EA200EEA1C3CEA03F0>18 31 2 1 23]51 dc[<1306A2130EA2131E132EA2134E138EA2EA010E1202A212041208A212101220A2 124012C0B512F038000E00A7EBFFE0>20 30 1 0 23]52 dc[<127012F8A312701200AA127012 F8A31270>5 20 4 0 13]58 dc[<5B497EA3497EA3EB09E0A3EB10F0A3EB2078A3497EA3497EA2 EBFFFE3801000FA30002EB0780A348EB03C0120E001FEB07E039FFC03FFE>31 32 1 0 34]65 dc[<B512E0380F80380007131E141F801580A515005C141E5CEBFFF0EB803C80801580140715C0 A51580140F15005C000F133CB512F0>26 31 2 0 32]66 dc[<90380FC04090387030C03801C0 093803800538070003000E1301001E1300121C123C007C1440A2127800F81400A91278007C1440 A2123C121C001E1480120E6CEB0100380380026C6C5A38007038EB0FC0>26 33 3 1 33]67 dc[ <B512E0380F803C00077F1407EC038015C0EC01E0A215F01400A215F8A915F0A3EC01E0A2EC03 C01580EC0700140E000F133CB512E0>29 31 2 0 35]68 dc[<B6FC380F800F00071303A28015 801400A314801500A3138113FF13811380A4EC0020A31540A315C0A2EC0180000F130FB6FC>27 31 2 0 31]69 dc[<B6FC380F800F00071303A28015801400A4EC8000A4138113FF13811380A4 91C7FCA8487EEAFFFE>25 31 2 0 30]70 dc[<90380FE02090387818609038E004E038038002 38070001481300001E1460A25A1520127C127800F81400A7EC7FFCEC03E000781301127C123CA2 7EA27E7E380380023900E00460903878182090380FE000>30 33 3 1 36]71 dc[<39FFF8FFF8 390F800F8000071400AC90B5FCEB800FAE000F148039FFF8FFF8>29 31 2 0 34]72 dc[<EAFF FCEA0FC0EA0780B3A9EA0FC0EAFFFC>14 31 1 0 16]73 dc[<EAFFFEEA0FC06C5AB21402A414 061404A2140C141C000F137CB512FC>23 31 2 0 28]76 dc[<B46CEB1FF8000F158000071500 D805C0132FA3D804E0134FA20170138FA3903838010FA3EB1C02A3EB0E04A3EB0708A3EB0390A2 EB01E0A3380E00C0001FEC1F803AFFE0C1FFF8>37 31 2 0 42]77 dc[<39FF803FF83907C007 C0EC03803905E00100A2EA04F01378A2133CA2131E130FA2EB0781A2EB03C1EB01E1A2EB00F1A2 1479143DA2141FA28080A2000E7F121F38FFE001>29 31 2 0 34]78 dc[<EB1F80EBF0F03801 C0383807801E48487E000E7F001E148048EB03C0A2007C14E000781301A200F814F0A9007814E0 007C1303A2003C14C0A26CEB0780000E1400000F5B3807801E3801C0383800F0F0EB1F80>28 33 3 1 35]79 dc[<B512E0380F80780007131C141E801580A61500141E141C1478EBFFE00180C7FC AD487EEAFFFC>25 31 2 0 31]80 dc[<B57E380F80F0000713788080A2141FA4141EA25C5C5C EBFF80EB81C0EB80E08014701478A3147CA31504147E143E390FC01E0839FFFC0F10C7EA03E0> 30 32 2 1 33]82 dc[<3807E080EA0C19EA1007EA3003EA6001A212E01300A36C1300A2127812 7FEA3FF0EA1FFC6C7EEA03FF38001F801307EB03C0A213011280A400C01380130300E01300EAF0 06EACE0CEA81F8>18 33 3 1 25]83 dc[<007FB512E038780F010060EB006000401420A200C0 143000801410A400001400B3497E3807FFFE>28 31 2 0 33]84 dc[<39FFFC3FF8390FC007C0 3907800380EC0100B3A300031302A2EA01C05C6C6C5AEB7018EB3820EB0FC0>29 32 2 1 34] 85 dc[<397FF83FF8390FE00FC03907C00700000313026C6C5AEBF00C00001308EB7810137CEB 3C20EB3E40131E6D5AA213076D7E497E1305EB09F0EB18F8EB1078EB207CEB603CEB401EEB801F 00017F9038000780000214C000071303391F8007E039FFE01FFE>31 31 1 0 34]88 dc[<39FF F003FF391F8000F8000F1460000714407F6C6C138012019038F0010000005BEBF802EB7C04133C EB3E08131EEB1F10EB0FB0EB07A014C01303AB1307EB7FFE>32 31 1 0 34]89 dc[<12FEA212 C0B3B3A512FEA2>7 45 4 11 13]91 dc[<12FEA21206B3B3A512FEA2>7 45 1 11 13]93 dc[< EA1FE0EA3030EA7818131CEA300E1200A313FEEA078EEA1E0E1238127800F01310A3131E127838 386720380F83C0>20 20 2 0 23]97 dc[<120E12FE120EAA133EEBC380380F01C0EB00E0120E 1470A21478A61470A214E0120F380D01C0380CC300EA083E>21 32 1 0 25]98 dc[<EA03F8EA 0E0CEA1C1E1238130CEA7000A212F0A61270A2EA3801A2EA1C02EA0E0CEA03F0>16 20 2 0 20] 99 dc[<EB0380133F1303AAEA03E3EA061BEA1C07EA3803A21270A212F0A61270A21238130712 1CEA0E1B3803E3F8>21 32 2 0 25]100 dc[<EA03F0EA0E1C487E487EA21270EB038012F0A2B5 FC00F0C7FCA31270A26C13801218380C0100EA0706EA01F8>17 20 1 0 20]101 dc[<137C13C6 EA018F1203EA07061300A7EAFFF0EA0700B2EA7FF0>16 32 0 0 14]102 dc[<14E03803E330EA 0E3CEA1C1C38380E00EA780FA5EA380E6C5AEA1E38EA33E00020C7FCA21230A2EA3FFE381FFF80 6C13C0383001E038600070481330A4006013606C13C0381C03803803FC00>20 31 1 10 23] 103 dc[<120E12FE120EAA133E1343EB8180380F01C0A2120EAE38FFE7FC>22 32 1 0 25]104 dc[<121C121E123E121E121CC7FCA6120E127E120EB1EAFFC0>10 31 0 0 12]105 dc[<120E12 FE120EAAEB0FF0EB03C0140013025B5B5B1330137013F8EA0F38EA0E1C131E130E7F1480130314 C014E038FFCFF8>21 32 1 0 24]107 dc[<120E12FE120EB3ABEAFFE0>11 32 0 0 12]108 dc [<390E1F01F039FE618618390E81C81C390F00F00EA2000E13E0AE3AFFE7FE7FE0>35 20 1 0 38]109 dc[<EA0E3EEAFE43380E8180380F01C0A2120EAE38FFE7FC>22 20 1 0 25]110 dc[< EA01F8EA070E381C0380383801C0A2387000E0A200F013F0A6007013E0A2383801C0A2381C0380 38070E00EA01F8>20 20 1 0 23]111 dc[<EA0E3E38FEC380380F01C0EB00E0120E14F0147014 78A6147014F014E0EA0F0114C0380EC300133E90C7FCA8EAFFE0>21 29 1 9 25]112 dc[<3803 E080EA0619EA1C05EA3C07EA38031278127012F0A61270127812381307EA1C0BEA0E13EA03E3EA 0003A8EB3FF8>21 29 2 9 24]113 dc[<EA0E78EAFE8CEA0F1EA2130CEA0E00AEEAFFE0>15 20 1 0 18]114 dc[<EA1F90EA3070EA4030EAC010A3EAE0001278EA7F80EA3FE0EA0FF0EA0070EA 80381318A212C0A2EAE030EAD060EA8F80>13 20 2 0 18]115 dc[<1202A31206A2120EA2123E EAFFF8EA0E00AB1308A5EA06101203EA01E0>13 28 1 0 18]116 dc[<380E01C0EAFE1FEA0E01 AE13031206EA030D3801F1FC>22 20 1 0 25]117 dc[<38FF83F8381E01E0381C00C06C1380A3 38070100A2EA0382A3EA01C4A213ECEA00E8A21370A31320>21 20 1 0 24]118 dc[<39FF9FE1 FC393C078070391C030060EC8020000E1440A214C0D807071380130414E039038861001471EBC8 733801D032143A3800F03CEBE01CA2EB6018EB4008>30 20 1 0 33]119 dc[<387FC3FC380F01 E0000713C0148038038100EA01C2EA00E413EC13781338133C137C134E1387EA01073803038038 0201C0000613E0121E38FF07FE>23 20 0 0 24]120 dc[<38FF83F8381E01E0381C00C06C1380 A338070100A2EA0382A3EA01C4A213ECEA00E8A21370A31320A25BA3EAF080A200F1C7FC126212 3C>21 29 1 9 24]121 dc dfe /fc df[<EC3FE0ECE010903801803801031378140049133015 00A3130EA390B512E0EB0E0090381C01C0A4EC03801338A3EC0700A213701510EC0E20A313E0EC 0640EC038091C7FC5B1201A2EA3180127948C8FC1262123C>29 41 -2 9 26]12 dc[<EC0C06EC 1C0EEC180CEC381CEC3018A2EC7038EC6030ECE070ECC060010113E0EC80C0EB0381EC0180A200 1FB512FE4814FF39001C0E00EB180CA2EB381CEB3018A2EB7038EB6030B612FC6C14F8390381C0 00EB0180A2EA0703000690C7FCEA0E07EA0C06EA1C0EEA180CEA381CEA3018EA7038EA6030A2> 32 41 5 9 37]35 dc[<120E121F123FA2121D12011202A21204A212081210122012C0>8 14 9 -18 14]39 dc[<130113021304130813101320136013C0EA0180A2EA03005A1206120E120C121C 12181238A212301270A21260A212E0A25AAD12401260A212207EA27E>16 46 7 12 19]40 dc[< 13107F7F130613021303A37F1480A71303A31400A35BA21306A2130E130CA2131C131813381330 1370136013E05B485A90C7FC5A12065A5A5A5A1280>17 46 0 12 19]41 dc[<1330A31320A238 3861C0381C6380380E4E00EA0358EA01E0A2EA06B0EA1C9CEA718EEAE1870001C7FCA25AA3>18 20 8 -14 23]42 dc[<EA7FF0EAFFE0127F>12 3 3 -8 16]45 dc[<1207120F121FA2120E1200 AA127012F8A212F012E0>8 20 5 0 14]58 dc[<14021406A2140E141EA2143F142F144FA2148F EB010FA21302A21304130C13081310A201201380EB3FFFEB400713C01380EA0100A21202A21206 001E130F39FF807FF8>29 32 2 0 34]65 dc[<48B512C039001E00F015781538153C5BA44913 78A215F0EC01E09038F007809038FFFE009038F00F80EC03C03801E00115E0A3EA03C0A315C038 078003EC0780EC0F00141E380F0078B512E0>30 31 3 0 32]66 dc[<ECFE0290380781869038 1C004C49133C136049131C00011418485A48C7FC5A001E1410A2481400A25AA45AA415801270A2 EC01007E140200185B6C13186C1320380381C0D800FEC7FC>31 33 6 1 33]67 dc[<48B51280 39001E00E015701538151C5B150EA35BA449131EA44848133CA3157848481370A215E0EC01C0EA 0780EC0380EC0E005C380F0070B512C0>31 31 3 0 34]68 dc[<48B512FE39001E001C150C15 04A25BA490387808081500A21418495AEBFFF0EBF030A23801E020A3EC001048481320A21540A2 48481380140115001407380F001FB512FE>31 31 3 0 31]69 dc[<48B512FC39001E00381518 1508A25BA4491310EC0800A3495A1430EBFFF0EBF0303801E020A44848C7FCA4485AA4120FEAFF F8>30 31 3 0 30]70 dc[<3A01FFF3FFE03A001F003E00011E133CA3495BA4495BA449485A90 B5FCEBF001A24848485AA44848485AA4484848C7FCA4000F5B39FFF1FFE0>35 31 3 0 34]72 dc[<3801FFF038001F00131EA35BA45BA45BA4485AA4485AA4485AA4120FEAFFF8>20 31 3 0 18]73 dc[<3801FFF8D8001FC7FC131EA35BA45BA45BA4485AA315803903C00100A25C14023807 8006A25C141C380F0078B512F8>25 31 3 0 29]76 dc[<D801FEEC7FC0D8001EECFC005E0117 EB0178A20127EB02F01504A215080147EB09E015111521A20187495AEB83801583A23A01038107 801482A2148400024AC7FC14881490A2390401E01EA214C0000C1380001C143E3AFF8103FFC0> 42 31 3 0 41]77 dc[<48B4EB7FE0D8001FEB0F001504EB1780A201275BEB23C0A3903841E010 A214F0134001805B1478A348486C5AA3141E00025CA2140FA24891C7FC80A2120C001C1302EAFF 80>35 31 3 0 34]78 dc[<EB01FCEB070790381C01C090383000E001E0136048481370485A00 07143890C7FC120E121E121C123CA2481478A44814F0A215E0140115C0140300701480EC070000 785B0038131E5C6C13706C5B38078380D801FCC7FC>29 33 6 1 35]79 dc[<48B5FC39001E03 C0EC00E0157015785BA44913F0A2EC01E015C09038F00700141EEBFFF0EBF03848487E141E140E 140F3803C01EA448485A1508A21510000F131C39FFF00C20C7EA07C0>29 32 3 1 33]82 dc[< 000FB512F0391E0780E00018142012101220EB0F0012601240A2D8801E134000001400A35BA45B A45BA4485AA41203B5FC>28 31 8 0 33]84 dc[<397FFC1FF83907C003C09038800100A3380F 0002A4001E5BA4485BA4485BA4485BA35CA200705B49C7FCEA3002EA3804EA0C18EA07E0>29 32 9 1 34]85 dc[<39FFF007FC390F8000E090C712C01580EC0100A214025CA26D5A12075C5CA25C A25C0181C7FCA213C2120313C413C8A213D0A213E05BA25B120190C8FC>30 32 9 1 34]86 dc[ <EBF180380389C038070780EA0E03121C123C383807001278A3EAF00EA31420EB1C40A2EA703C 135C38308C80380F0700>19 20 4 0 23]97 dc[<EA0780123FEA0700A4120EA45AA213F0EA1D 0CEA3A0E123CEA380FA21270A4EAE01EA3131C133C1338EA607013E0EA31C0EA1F00>16 32 5 0 21]98 dc[<137EEA01C138030080EA0E07121E001C1300EA3C0248C7FCA35AA5EA70011302EA30 04EA1838EA07C0>17 20 4 0 21]99 dc[<1478EB03F8EB0070A414E0A4EB01C0A213F1EA0389 38070780EA0E03121C123C383807001278A3EAF00EA31420EB1C40A2EA703C135C38308C80380F 0700>21 32 4 0 23]100 dc[<137CEA01C2EA0701120E121C123CEA3802EA780CEA7BF0EA7C00 12F0A4127013011302EA3804EA1838EA07C0>16 20 4 0 21]101 dc[<1478EB019CEB033CA2EB 07181400A2130EA53801FFE038001C00A45BA55BA65BA45B1201A25B1231007BC7FC12F3126612 3C>22 41 -2 9 14]102 dc[<EB3C60EBE2703801C1E0EA0380EA07005A380E01C0121EA3383C 0380A4EB0700A2EA1C0F1317EA0C2EEA03CEEA000EA25BA21230EA7838485AEA60E0EA3F80>20 29 2 9 21]103 dc[<EA01E0120FEA01C0A4485AA448C7FCA2131E1363380E8180380F01C0120E A2381C0380A438380700A3EB0E1000701320130C131CEB0C4000E013C038600700>20 32 3 0 23]104 dc[<13C0EA01E0A213C0C7FCA7120E12331223EA4380130012471287120EA35AA3EA38 40138012301270EA31001233121C>11 31 4 0 14]105 dc[<EA01E0120FEA01C0A4485AA448C7 FCA2EB03C0EB0420380E08E013111321EB40C0381C8000001DC7FC121EEA1FC0EA38E01370A2EB 384038707080A3EB310012E0EA601E>19 32 3 0 21]107 dc[<EA03C0121FEA0380A4EA0700A4 120EA45AA45AA45AA3127112E2A412641238>10 32 4 0 12]108 dc[<391C0F80F0392630C318 394740640C903880680EEB0070A2008E495A120EA34848485AA3ED70803A3803807100156115E1 15623970070066D830031338>33 20 4 0 37]109 dc[<381C0F80382630C0384740601380EB00 70A2008E13E0120EA3381C01C0A3EB03840038138814081307EB031000701330383001C0>22 20 4 0 26]110 dc[<137CEA01C338030180000E13C0121E001C13E0123C1278A338F003C0A3EB07 801400EA700F130EEA3018EA1870EA07C0>19 20 4 0 23]111 dc[<3801C1E038026218380474 1C1378EB701EA2EA08E01200A33801C03CA3143838038078147014E0EBC1C038072380EB1E0090 C7FCA2120EA45AA2EAFFC0>23 29 0 9 23]112 dc[<EBF040380388C038070580EA0E03121C12 3C383807001278A3EAF00EA45BA2EA703C135CEA30B8EA0F381200A25BA45BA2EA0FFE>18 29 4 9 21]113 dc[<EA1C1EEA26613847838013871307EB0300008EC7FC120EA35AA45AA45A1230> 17 20 4 0 19]114 dc[<13FCEA0302EA0601EA0C03130713061300EA0F8013F0EA07F8EA03FC EA003E130E1270EAF00CA2EAE008EA4010EA2060EA1F80>16 20 3 0 19]115 dc[<EA018013C0 EA0380A4EA0700A2EAFFF0EA0700120EA45AA45AA31320EA7040A21380A2EA3100121E>12 28 4 0 15]116 dc[<000E13C0003313E0382301C0EA43811301124738870380120EA3381C0700A314 10EB0E201218A2EA1C1E380C26403807C380>20 20 4 0 24]117 dc[<000EEBC1C0003313E339 2301C3E0384381C1EB01C0004714603987038040120EA3391C070080A3EC0100A2EB0602130F00 0C5B380E13083803E1F0>27 20 4 0 30]119 dc[<38038380380CC440381068E013711220EB70 C03840E0001200A3485AA314403863808012F3EB810012E5EA84C6EA7878>19 20 3 0 21]120 dc[<000E13C0003313E0382301C0EA43811301124738870380120EA3381C0700A4130E1218A2EA 1C1EEA0C3CEA07DCEA001CA25B12F05BEAE060485AEA4380003EC7FC>19 29 4 9 22]121 dc dfe /fd df[<14F013F8120112033807800090C7FC5AA738FFF8F0A3EA0F00B1>20 33 0 0 24] 12 dc[<137C13FE487E3803C7801387EB83C012071303A21383EB8780138F91C7FC139ED803BC 138001F813E0EBF00101E013C01207380FF003001E1480383CF807D878781300EB7C0F38F03E0E EB1F1E5CEB0FF86C6C5A387803E0397C0FF830003FB512F0381FFE3F3907F00FC0>28 34 2 1 34]38 dc[<EA018013C01380A2EAC183EAE187EAF99FEA7DBEEA1FF8EA07E0A2EA1FF8EA7DBEEA F99FEAE187EAC183EA0180A213C01380>16 20 3 -14 23]42 dc[<EAFFC0A3>10 3 1 -9 15] 45 dc[<EA07E0EA3FF8EA7FFCEA701EEA401FEA000FA3133FEA07FF121FEA7E0F12F812F0A3EA F83FEA7FFFEA3FEFEA1F8F>16 20 2 0 22]97 dc[<12F0ACEAF1F0EAF7FCB47EEAFC3EEAF80F 12F0EB0780A7EB0F00A26C5AEAFC3EEAFFFCEAF7F8EAF1E0>17 32 3 0 23]98 dc[<EA03F0EA 0FFCEA1FFEEA3E0EEA3C02EA7800A25AA61278A2EA3C01EA3E0FEA1FFFEA0FFEEA03F0>16 20 2 0 20]99 dc[<EB0780ACEA07C7EA0FF7EA1FFFEA3E1FEA7C07127812F812F0A71278130FEA3E1F EA1FFFEA0FF7EA07C7>17 32 2 0 23]100 dc[<EA03F0EA0FFC487EEA3E1FEA3C071278387003 80B5FCA300F0C7FCA3127012786C5AEA3E076CB4FCEA07FEEA01F8>17 20 1 0 20]101 dc[<13 7EEA01FE1203EA078013005AA7EAFFF0A3EA0F00B1>15 32 0 0 14]102 dc[<3803E0F0EA0FFF 5A383E3E00EA3C1E487EA5EA3C1EEA3E3EEA1FFC485AEA33E00030C7FC1238EA3FFEEBFF806C13 C04813E0387803F0EAF000A3EAF801387E07E0383FFFC0000F1300EA03FC>20 30 1 10 23] 103 dc[<12F0ACEAF1F8EAF3FCEAF7FEEAFC1FEAF80FA212F0AE>16 32 3 0 23]104 dc[<12F0 A41200A812F0B3A2>4 32 3 0 11]105 dc[<12F0AC131F131E5B5B5BEAF1E0EAF3C0EAF780B4 7EA27FEAF9F012F8487E137CA27F131E131FEB0F80>17 32 3 0 22]107 dc[<12F0B3AE>4 32 3 0 11]108 dc[<39F0FC07E039F3FE1FF039F7FF3FF839FE0FF07C39F807C03CA200F01380AE> 30 20 3 0 37]109 dc[<EAF1F8EAF3FCEAF7FEEAFC1FEAF80FA212F0AE>16 20 3 0 23]110 dc[<EA01F8EA07FE381FFF80383F0FC0EA3C03387801E0A238F000F0A6387801E0A2383C03C0EA 3F0F381FFF803807FE00EA01F8>20 20 1 0 23]111 dc[<EAF1F0EAF7FCB47EEAFC3E487E487E 14801307A6EB0F00A26C5AEAFC3EEAFFFCEAF7F8EAF1E000F0C7FCA9>17 29 3 9 23]112 dc[< EAF0E012F312F7EAFF0012FCA25AA25AAC>11 20 3 0 16]114 dc[<EA07F0EA1FFC123FEA780C 1300A3127CEA3FC0EA1FF0EA0FF81203EA007C133CA212C0EAF07CEAFFF8EA7FF0EA0FC0>14 20 1 0 17]115 dc[<121EA6EAFFF0A3EA1E00AD1320EA1FF0120FEA07C0>12 26 1 0 16]116 dc[ <EAF00FAF131F133FB5FCEA7FEFEA3F0F>16 20 3 0 23]117 dc[<38F003C0A2007813801307 A2383C0F00A3EA1E0E131EA2EA0E1CEA0F3CA2EA0738A3EA03B013F06C5A>18 20 1 0 21]118 dc[<D8F01F13F01480131B0078EB81E0133B14C11339393C31C3C0137114E3D81C701380EA1E60 14E713E0000EEB770013C0A2000613760007133E1380>28 20 1 0 31]119 dc[<387801E0387C 03C0383E0780381E0F00120FEA079EEA03FC5B12016C5A12017F487EEA079EEA0F0F120E381E07 80383C03C0387801E000F813F0>20 20 0 0 21]120 dc[<38F003C0A238780780A2127C383C0F 00A2121E131E120EEA0F1CA2EA073C1338EA03B8A213B0120113F06C5AA2485AA3485A1207007F C7FC127E127C>18 29 1 9 21]121 dc dfe /fe df[<1230127812FCA212781230>6 6 10 0 26]46 dc[<133E48B4FC4813803807C3C0EA0F01381E0EE0EA3C3FEA387F387071F013E0A238E1 C070A83870E0E0A2EB71C0EA387F383C3F80381E0E00380F00703807C1F03803FFE06C13C03800 3F00>20 30 2 0 26]64 dc[<EA1FF0EA3FFC487EEA780FEA300738000380A2137FEA07FF121F EA3F83EA7803127012E0A3EA7007EA780F383FFFFCEA1FFDEA07F0>22 21 3 0 26]97 dc[<12 FEA3120EA6133EEBFF80000F13E0EBC1F0EB8070EB0038120E141CA7000F13381478EB80F0EBC1 E0EBFFC0000E138038063E00>22 30 1 0 26]98 dc[<EBFF80000313C0000F13E0EA1F01383C 00C04813001270A25AA51270A2007813707E381F01F0380FFFE0000313C03800FE00>20 21 3 0 26]99 dc[<EB1FC0A31301A6EA01F1EA07FDEA0FFFEA1E0FEA3C07EA7803EA700112E0A7EA7003 A2EA3807EA3E0F381FFFFCEA07FDEA01F1>22 30 2 0 26]100 dc[<EA01F8EA07FF481380381E 07C0EA3C01387800E01270481370A2B512F0A300E0C7FC1270A2007813707E381F01F0380FFFE0 000313C03800FE00>20 21 3 0 26]101 dc[<387CE0E038FFFBF8EA7FFF381F1F1CEA1E1EA2EA 1C1CAC387F1F1F39FF9F9F80397F1F1F00>25 21 0 0 26]109 dc[<EAFE3EEBFF80B512C0EA0F C1EB80E01300120EAC38FFE3FEA3>23 21 1 0 26]110 dc[<EA01F0EA07FCEA1FFF383E0F80EA 3C07387803C0EA700138E000E0A6EAF001007013C0EA7803383C0780EA3E0F381FFF00EA07FCEA 01F0>19 21 3 0 26]111 dc[<EAFE3EEBFF80B512E0380FC1F0EB8070EB0038120E141CA7000F 13381478EB80F0EBC1E0EBFFC0000E1380EB3E0090C7FCA8EAFFE0A3>22 32 1 11 26]112 dc[ <38FF83F0EB8FF8EBBFFC3803FC3CEBF018EBE0005BA25BAAB5FC14801400>22 21 2 0 26] 114 dc[<38FE0FE0A3EA0E00AD1301EA0F033807FFFE7EEA00FC>23 21 1 0 26]117 dc[<387F C7F8EBCFFCEBC7F8380703C038038780EBC700EA01EEEA00FE137C13781338137C13EE120113C7 38038380000713C01301387FC7FC00FF13FE007F13FC>23 21 1 0 26]120 dc[<387FC7FC00FF 13FE007F13FC380E00E0120FEA070114C013811203EB8380EA01C3A2EBC700EA00E7A213E61366 136E133CA41338A2137813701230EA78E01279EA7FC06C5A001EC7FC>23 32 1 11 26]121 dc dfe /ff df[<127012F812FCA212741204A41208A21210A212201240>6 15 4 10 14]44 dc[< 1340EA01C0120712FF12F91201B3A8EA7FFFA2>16 33 4 0 25]49 dc[<EA01F8EA0FFE381C0F 80383003C01238007C13E01301A2EA3C031218000013C014801307EB0E005BEA03F8EA000EEB07 80EB03C014E0130114F0A21230127812FCA214E0EAF803004013C038200780381C0F00EA0FFEEA 03F8>20 34 2 1 25]51 dc[<00181340381E0380EA1FFF140013FCEA13F00010C7FCA613FCEA 130638140380EA1801001013C0C712E0A214F0A3127012F8A314E0EAC001004013C0EA60030030 1380381C0F00EA0FFEEA03F0>20 34 2 1 25]53 dc[<EA01F8EA07FEEA0E0F381C0380123838 7801C0127014E0EAF000A214F0A5127013011238EA1802120CEA060CEA01F0C712E0A2130114C0 1238387C0380A238780700EA300E133CEA1FF8EA07E0>20 34 2 1 25]57 dc[<497EA3497EA3 EB05E0A3EB08F0A3EB1078A3497EA2EB603EEB401EA2EBC01F497E90B5FC481480EB0007A20002 EB03C0A348EB01E0A2120C001E14F039FFC01FFFA2>32 35 2 0 37]65 dc[<903807F0089038 3FFC18EBFC063901F001383903C000F84848137848C71238121E15185AA2007C1408A2127800F8 1400A81278007C1408A2123CA26C1410A26C14206C7E6C6C13403901F001803900FC0700EB3FFC EB07F0>29 36 3 1 36]67 dc[<EAFFFCA2EA0780B3ACEAFFFCA2>14 34 2 0 18]73 dc[<3807 FFF0A238000F00B3A51230127812FCA2130EEAF81EEA401C6C5AEA1870EA07C0>20 35 2 1 26] 74 dc[<EAFFFEA2EA0780B31540A415C0A21580140114031407141FB6FCA2>26 34 2 0 31]76 dc[<B46C903801FF80A20007EDF000D805C01302A2D804E01304A301701308A26D1310A36D1320 A36D1340A26D1380A39038038100A3EB01C2A2EB00E4A31478A2001F1330D8FFE090381FFF80A2 >41 34 2 0 46]77 dc[<39FF8007FF13C00007EB00F8D805E01320EA04F0A21378137C133C7F A27FEB0780A2EB03C0EB01E0A2EB00F014F81478143CA2141E140FA2EC07A0EC03E0A21401A214 00001F1460EAFFE01520>32 34 2 0 37]78 dc[<B512E014FC3807801FEC07806E7E81140181 A45D14035D4AC7FC143EEBFFF0EB80388080140F8081A481A3164015E0140326FFFC0113809138 00F100C8123E>34 35 2 1 37]82 dc[<3803F810380FFE30EA1E07383801F0EA700014704813 30A21410A36C1300A2127C127FEA3FF0EA1FFE380FFF80000313C038003FE0EB03F01300147014 7814387EA46C133014706C136000F813E038CF03C038C7FF00EA80FE>21 36 3 1 28]83 dc[< 39FFFC07FFA239078000F81520B3A5000314407FA2000114803800E0019038700300EB3C0EEB1F F8EB03F0>32 35 2 1 37]85 dc[<D8FFF8EB7FC0A2D80F80EB1E006C6C1318000314107F0001 5C6D13600000144001785B137CD93C01C7FCEB3E03EB1E026D5A1484EB078814D8EB03D014E013 01ACEB3FFFA2>34 34 1 0 37]89 dc[<EA1FF0EA381CEA7C061307EB038012381200A2137FEA 07C3EA1E03123C1278A200F01384A31307EA780B383C11C8380FE0F0>22 21 2 0 25]97 dc[< 120E12FEA2121E120EAAEB1F80EB60E0EB8030380F0038000E131C141E140E140FA7140E141E14 1C000F1338380C8070EB60E038081F80>24 35 1 0 28]98 dc[<EA01FEEA0707380C0F80121C 1238387807000070C7FC12F0A712700078134012386C1380380C0100EA0706EA01F8>18 21 2 0 22]99 dc[<EA01FCEA0707380C0380381C01C01238387800E0127012F0B5FC00F0C7FCA5127000 78132012386C13406C138038070300EA00FC>19 21 1 0 22]101 dc[<133E13E33801C780EA03 8F130F3807070090C7FCA8EAFFF8A20007C7FCB1EA7FF8A2>17 35 0 0 15]102 dc[<120E12FE A2121E120EAAEB1F80EB60E0EB8070380F0038A2120EAE39FFE3FF80A2>25 35 1 0 28]104 dc [<121C123EA3121CC7FCA8120E12FEA2121E120EAFEAFFC0A2>10 34 1 0 14]105 dc[<120E12 FEA2121E120EAAEB03FCA2EB01E01480EB02005B5B5B133813F8EA0F1CEA0E1E130E7F1480EB03 C0130114E014F038FFE3FEA2>23 35 1 0 26]107 dc[<120E12FEA2121E120EB3ABEAFFE0A2> 11 35 1 0 14]108 dc[<390E1FC07F3AFE60E183809039807201C03A1F003C00E07E000E1338 AE3AFFE3FF8FFEA2>39 21 1 0 42]109 dc[<380E1F8038FE60E0EB8070381F00387E120EAE39 FFE3FF80A2>25 21 1 0 28]110 dc[<13FC38070380380E01C0381C00E0481370007813780070 133800F0133CA70070133800781378003813706C13E0380E01C0380703803800FC00>22 21 1 0 25]111 dc[<EA0E1EEAFE63EB8780121E380F030090C7FC120EADEAFFF0A2>17 21 1 0 20] 114 dc[<EA0FC4EA303CEA600C12C01304A212E0EAF000EA7F80EA3FF0EA0FF8EA00FC131EEA80 0E130612C0A21304EAE00CEAD818EA87E0>15 21 2 0 20]115 dc[<1202A51206A3120E121EEA 3FF812FFEA0E00AA1304A6EA07081203EA01F0>14 31 1 0 19]116 dc[<000E133838FE03F8A2 381E0078000E1338AC1478A26C13BC3903833F80EA00FC>25 21 1 0 28]117 dc[<38FFC1FEA2 381E0070000E1320A26C1340A238038080A33801C100A2EA00E2A31374A21338A31310>23 21 1 0 26]118 dc[<3AFF8FF87F80A23A1E01C01E00D80E00130CECE00813010007EB601014709038 0230303903823820A23901C41840141CA23900E80C80140EA2D97007C7FCA3EB2002>33 21 1 0 36]119 dc[<38FFC1FEA2381E0070000E1320A26C1340A238038080A33801C100A2EA00E2A313 74A21338A31310A25BA3EAF840A25B12B90063C7FC123E>23 31 1 10 26]121 dc dfe /fg df [<007FB512F0B612F8A36C14F0>29 5 4 -19 38]45 dc[<3803FF80000F13F0487F487FEB00FE 143F001EEB0F80000C80C71207A314FF133F48B5FC12074813C7381FF007EA3F80EA7E005A5AA4 6C130F007E131F383F80FF6CB6FC6C01FB13806C13F1C601801300>33 31 4 0 38]97 dc[<EB 1FE0EB7FFC48487E487F3907F03F80390FC00FC0391F8003E0D83F0013F0003E13015A15F800FC 13005AB6FCA315F000F8C8FCA27E127C127E003E1470003F14F8381F8001390FE003F03807F80F 6CB512E06C14C06C6C1300EB0FF8>29 31 4 0 38]101 dc[<EA7FFFB57EA27EEA000FB3B2007F B512F0B612F8A26C14F0>29 44 4 0 38]108 dc[<397E1F01F039FF7F87F89038FFCFFC6CEBFF FED80FF1131E9038C1FC1F01C07FEB80F8A3EB00F0B13A7FE1FE1FE03AFFF3FF3FF0A23A7FE1FE 1FE0>36 31 0 0 38]109 dc[<387FC0FFD8FFE37F01E77FD87FEF7F3903FF83F0EBFE01496C7E 5B5BA25BB13A7FFF07FFC0B5008F13E0A26C010713C0>35 31 1 0 38]110 dc[<397FF803FC39 FFFC1FFE4A7E007F90B5128039007DFE1FEB7FF09138E00F00ECC0064AC7FC91C8FCA2137EA313 7CAD007FB5FCB67EA26C91C7FC>33 31 2 0 38]114 dc[<EBFFE30007EBFF80121F5A387F807F 387C001F48130F5AA2EC070000FC90C7FCEA7F80EA3FFE381FFFF06C13FC00017F38001FFF9038 007F80EC0FC00070EB03E000F81301A27EA26C13036CEB07C09038C03F8090B512005C00F35B38 607FE0>27 31 5 0 38]115 dc[<397FC01FF0486C487EA2007F131F00031300B31401A2EBF007 3801F81F90B612C06C15E0EB7FFC90390FF07FC0>35 31 1 0 38]117 dc dfe /fh df[<1430 1478A314FCA2497E14BEA2EB031FA39038060F80A2010E7FEB0C07A2496C7EA201387FEB3001A2 496C7EEB7FFFA29038C0007CA20001147E49133EA200038090C7FC481580487E486CEB3FC0B46C EBFFFCA2>38 37 2 0 44]97 dc dfe /fi df[<B712FEA23903FC00016C48EB003E828282A282 A4EE0180A3153093C7FCA41570A2EC01F090B5FCA2EBF801EC0070A21530A31760A292C7FC17C0 A41601A217801603A21607160F163F486C903801FF00B8FCA2>43 49 3 0 49]69 dc[<B512FC A2D803FEC8FCEA01F8B3AA160CA41618A41638A21678A216F8ED01F01507486C133FB7FCA2>38 49 3 0 45]76 dc[<007FB712F0A29039001FE007007C90380FC0010078150000701670006016 30A200E01638A2481618A6C71500B3ACEC3FF0013FB512F0A2>45 49 3 0 52]84 dc[<3B7FFF F007FFFCA20003D9800013C0C690C76CC7FC49143C017F14386D6C133016706D6C5B010F5CECE0 016D6C485A010391C8FC6E5A903801FC0E0100130CECFE1CEC7F38EC3F3015F06E5A6E5A816E7E 14034A7E4A7E140CEC1CFEEC387FEC303F02707F4A6C7EECC00F01018049486C7EEC0003498001 0E6D7E010C1300011C8049147F133001706E7E01F06E7ED803F8143FD80FFCEC7FF0B5D88003B5 1280A2>49 49 2 0 54]88 dc[<EB01F8EB0FFEEB1F0F90387C1F80EBF83F13F012019038E01F 000003130E91C7FCAAB512E0A2D803E0C7FCB3A8487EB512C0A2>25 50 1 0 22]102 dc[<EB0F E0EB7FFC3801F01F3903C0078039078003C0390F0001E0001EEB00F0003E14F8A248147CA300FC 147EA8007C147C007E14FC003E14F8A26CEB01F06C14E039078003C03903C007803901F01F0038 007FFCEB0FE0>31 31 2 0 36]111 dc[<3903E03F8039FFE1FFF09038E781F83907EE007ED803 F87F497F49EB0F8016C0150716E0A2150316F0A716E01507A216C0150F6DEB1F8016006D133E01 EC5B9038E781F89038E1FFE0D9E07FC7FC91C8FCAB487EB57EA2>36 45 1 14 40]112 dc[<38 07C0FC38FFC1FEEBC30F3907C61F80EA03CC13C89038D80F0001D0C7FCA213F05BB2487EB512C0 A2>25 31 1 0 28]114 dc[<1360A413E0A31201A21203A2120F121FB512F8A23803E000B0140C A714083801F018A23800F870EB7FE0EB1F80>22 44 1 0 28]116 dc[<D803E0133E00FFEB0FFE A20007EB007E0003143EB3157EA215BE000113019038F0033E3900F80E3FD93FFC13F8EB0FF0> 37 31 1 0 40]117 dc dfe end %%EndProlog %%BeginSetup %%Feature: *Resolution 300 TeXDict begin @letter %%EndSetup %%Page: 4 1 bop 224 307 a fd(p)o(rep)o(ro)q(cess-lamb)q(da-k)o(eyw)o(o)o(rds)47 b fc(ar) n(gs)778 b fb([)p fc(FUNCTION)7 b fb(])338 389 y(Un)o(used)224 506 y fd(p)o (rep)o(ro)q(cess-lisp-latex-clashes)49 b fc(ar)n(gs)16 b(pur)n(ge-do)n(c)585 b fb([)p fc(FUNCTION)7 b fb(])338 588 y(This)21 b(function)g(is)g(used)h(to)d (mak)o(e)h(the)h(strings)g(for)f(the)g(argumen)o(ts)g(of)g(the)h(form)338 644 y(digestible)c(for)e(LaT)l(eX,)g(e.g.)k(b)o(y)c(remo)o(ving)g('#')g(and)g('&'\ .)224 762 y fd(p)o(rep)o(ro)q(cess-cha)o(racter)47 b fc(c)987 b fb([)p fc(FUN\ CTION)7 b fb(])338 843 y(Lo)o(w)20 b(lev)o(el)h(pro)q(cessing)g(of)f(single)h (c)o(haracters,)g(when)f(passed)h(as)f(defaults)g(to)g(op-)338 900 y(tional,) 15 b(k)o(ey)g(and)h(aux)f(parameters.)224 1017 y fd(p)o(rep)o(ro)q(cess-sp)q (ecials)48 b fc(list-form)17 b(pur)n(ge-do)n(c)666 b fb([)p fc(FUNCTION)7 b fb (])338 1099 y(Pro)q(cessing)17 b(of)f(some)g('sp)q(ecial')h(forms.)22 b(Only) c('quote')d(and)i('function')f(are)g(treated)338 1155 y(for)e(the)i(time)f (b)q(eing.)224 1273 y fd(split-string)47 b fc(string)16 b(width)h fd(&optiona\ l)g fc(ar)n(glistp)f(\014l)r(le)n(d)f(\(trim-whitesp)n(ac)n(e)h(t\))92 b fb ([)p fc(FUNCTION)7 b fb(])338 1354 y(Splits)13 b(a)e(string)g(in)o(to)g(a)h (list)g(of)f(strings,)g(eac)o(h)h(of)f(whic)o(h)h(is)g(shorter)f(than)g(the)h (sp)q(eci\014ed)338 1411 y(width.)38 b(T)l(ries)22 b(to)f(b)q(e)h(in)o(tellig\ en)o(t)h(ab)q(out)e(where)g(to)g(split)h(the)g(string)f(if)h(it)f(is)h(an)338 1467 y(argumen)o(t)14 b(list.)21 b(If)16 b(\014lled)h(is)f(T,)f(tries)g(to)g (\014ll)i(out)e(the)g(strings)g(as)g(m)o(uc)o(h)h(as)e(p)q(ossible.)338 1524 y (This)k(function)g(is)f(used)h(to)e(break)h(up)h(long)g(argumen)o(t)e(lists)i (nicely)l(,)h(and)e(to)g(break)338 1580 y(up)e(wide)i(lines)f(of)f(do)q(cumen) o(tation)h(nicely)l(.)224 1698 y fd(split-p)q(oint)48 b fc(string)16 b(max-le\ ngth)g fd(&optional)h fc(ar)n(glistp)f(\014l)r(le)n(d)382 b fb([)p fc(FUNCTIO\ N)7 b fb(])338 1779 y(Finds)17 b(an)f(appropriate)h(p)q(oin)o(t)g(to)e(break) i(the)f(string)h(at)e(giv)o(en)i(a)f(target)f(length.)25 b(If)338 1836 y(argl\ istp)14 b(is)g(T,)f(tries)g(to)g(\014nd)h(an)g(in)o(telligen)o(t)h(p)q(ositio\ n)g(to)e(break)g(the)h(string.)19 b(If)14 b(\014lled)338 1892 y(is)i(T,)e(tri\ es)h(to)g(\014ll)i(out)e(the)g(string)g(as)g(m)o(uc)o(h)g(as)g(p)q(ossible.) 224 2010 y fd(lamb)q(da-list-k)o(eyw)o(o)o(rd-p)q(osition)47 b fc(string)16 b fd(&optional)h fc(end)f(tr)n(ailer-only)212 b fb([)p fc(FUNCTION)7 b fb(])338 2091 y(If)16 b(the)h(previous)g(sym)o(b)q(ol)f(is)h(a)f(lam)o(b)q(da-list)i (k)o(eyw)o(ord,)d(returns)h(its)g(p)q(osition.)24 b(Oth-)338 2148 y(erwise)16 b(returns)f(end.)224 2265 y fd(balanced-pa)o(renthes)q(is-p)r(osition)49 b fc (string)15 b fd(&optional)i fc(end)436 b fb([)p fc(FUNCTION)7 b fb(])338 2347 y(Finds)14 b(the)g(p)q(osition)g(of)g(the)f(left)h(paren)o(thesis)g(whic)o (h)h(is)f(closest)g(to)f(END)g(but)h(lea)o(v)o(es)338 2403 y(the)i(pre\014x)g (of)f(the)h(string)f(with)h(balanced)h(paren)o(theses)f(or)f(at)g(most)g(1)g (un)o(balanced)338 2460 y(left)g(paren)o(thesis.)224 2577 y fd(pa)o(rse-with-\ delimiter)46 b fc(line)16 b fd(&optional)h fc(\(delim)f(#)p fa(n)p fc(new)r (line\))354 b fb([)p fc(FUNCTION)7 b fb(])338 2659 y(Breaks)15 b(LINE)h(in)o (to)f(a)g(list)h(of)f(strings,)f(using)i(DELIM)g(as)e(a)h(breaking)h(p)q(oin) o(t.)1072 2817 y(4)p eop %%Page: 3 2 bop 224 307 a fd(defclass)47 b fc(form)1062 b fb([)p fc(DOC-HANDLER)r fb(]) 338 400 y(Do)q(cumen)o(tation)15 b(handler)h(for)f(classs.)224 520 y fd(*fail\ ed-de\014nition-t)o(yp)q(es)q(*)48 b fc(nil)901 b fb([)p fc(V)-5 b(ARIABLE)5 b fb(])338 614 y(List)16 b(of)e(de\014nition)j(t)o(yp)q(es)f(that)e(create-user\ -man)o(ual)i(couldn't)f(handle.)224 733 y fd(create-user-manual)47 b fc(\014l\ ename)38 b fd(&k)o(ey)i fc(\(output-format)i('text\))d(\(output-)629 790 y (str)n(e)n(am)15 b(*standar)n(d-output*\))j(\(pur)n(ge-latex)f(t\))1662 733 y fb([)p fc(FUNCTION)7 b fb(])338 874 y(Automatically)15 b(creates)f(a)g(user)g (man)o(ual)h(for)f(the)g(functions)h(in)g(a)f(\014le)i(b)o(y)e(collecting)338 930 y(the)i(do)q(cumen)o(tation)g(strings)g(and)g(argumen)o(t)g(lists)g(of)g (the)g(functions)h(and)f(format-)338 987 y(ting)f(the)h(output)f(nicely)l(.) 23 b(Returns)15 b(a)g(list)i(of)e(the)g(de\014nition)i(t)o(yp)q(es)f(of)f(the) g(forms)g(it)338 1043 y(couldn't)k(handle.)31 b(Output-format)18 b(ma)o(y)g (b)q(e)h(either)g('TEXT,)e('SCRIBE)j(or)e('LA-)338 1100 y(TEX.)d(In)i(this)g (last)f(case)g(the)g(extra)f(k)o(eyw)o(ord)h('purge-latex')f(ma)o(y)h(b)q(e)h (sp)q(eci\014ed:)23 b(if)338 1156 y(non)17 b(nil)i(the)e(latex)h(\014lter)g (will)h(try)d(to)h(substitute)h(p)q(ossible)h(dangerous)e(c)o(haracters)338 1213 y(lik)o(e)f('&',)f(')p fa(n)p fb(')f(and)h('#'.)224 1332 y fd(handle-fo) o(rm-output)47 b fc(form)37 b fd(&optional)f fc(\(output-format)i('text\))e (\(str)n(e)n(am)636 1389 y(*standar)n(d-output*\))18 b(\(pur)n(ge-latex)f(t\)) 1662 1332 y fb([)p fc(FUNCTION)7 b fb(])338 1473 y(This)14 b(function)g(tak)o (es)f(a)g(form)g(as)g(input)i(and)e(outputs)h(its)f(do)q(cumen)o(tation)h(seg\ men)o(t)338 1529 y(to)g(the)i(output)f(stream.)224 1649 y fd(output-text-d)q (o)q(cu)q(mentation)49 b fc(name)24 b(typ)n(e)g(ar)n(gs)f(do)n(cumentation)i (ar)n(gs-tab-)783 1706 y(p)n(os)14 b(typ)n(e-p)n(os)g fd(&optional)i fc(\(str) n(e)n(am)e(*standar)n(d-)783 1762 y(output*\))1662 1649 y fb([)p fc(FUNCTION) 7 b fb(])338 1846 y(Prin)o(ts)15 b(out)g(the)g(user)g(guide)i(en)o(try)d(for) h(a)g(form)f(in)i(TEXT)f(mo)q(de.)224 1966 y fd(output-scrib)q(e-d)q(o)q(cu)q (mentation)49 b fc(name)34 b(typ)n(e)g(ar)n(gs)g(do)n(cumentation)g fd(&op-) 818 2022 y(tional)16 b fc(\(str)n(e)n(am)f(*standar)n(d-output*\))1662 1966 y fb([)p fc(FUNCTION)7 b fb(])338 2106 y(Prin)o(ts)15 b(out)g(the)g(user)g(guid\ e)i(en)o(try)d(for)h(a)g(form)f(in)i(SCRIBE)h(mo)q(de.)224 2226 y fd(output-l\ atex-do)q(cu)q(mentation)49 b fc(name)39 b(typ)n(e)g(ar)n(gs)f(do)n(cumentati\ on)h fd(&op-)799 2283 y(tional)12 b fc(\(str)n(e)n(am)f(*standar)n(d-output*\ \))i(\(pur)n(ge-)799 2339 y(do)n(cumentation)j(t\))1662 2226 y fb([)p fc(FUNC\ TION)7 b fb(])338 2423 y(Prin)o(ts)15 b(out)g(the)g(user)g(guide)i(en)o(try)d (for)h(a)g(form)f(in)i(LaT)l(eX)g(mo)q(de.)224 2543 y fd(purge-string-fo)o (r-latex)46 b fc(a-string)16 b(pur)n(ge-do)n(c)638 b fb([)p fc(FUNCTION)7 b fb (])338 2636 y(T)l(ries)19 b(to)e(purge)i(a)f(string)g(from)g(c)o(haracters)f (that)h(are)g(p)q(oten)o(tially)h(dangerous)f(for)338 2692 y(LaT)l(eX.)1072 2817 y(3)p eop %%Page: 2 3 bop 224 307 a fd(de\014ne-do)q(c-han)q(dler)48 b fc(form)859 b fb([)p fc(DOC\ -HANDLER)r fb(])338 396 y(Do)q(cumen)o(tation)15 b(handler)h(for)f(do)q(c-han\ dlers.)224 515 y fd(defva)o(r)45 b fc(form)1093 b fb([)p fc(DOC-HANDLER)r fb (])338 604 y(Do)q(cumen)o(tation)15 b(handler)h(for)f(v)m(ariables.)224 723 y fd(defconstant)48 b fc(form)988 b fb([)p fc(DOC-HANDLER)r fb(])338 812 y(Do)q (cumen)o(tation)15 b(handler)h(for)f(constan)o(ts.)224 931 y fd(defpa)o(ramet\ er)45 b fc(form)960 b fb([)p fc(DOC-HANDLER)r fb(])338 1020 y(Do)q(cumen)o (tation)15 b(handler)h(for)f(parameters.)224 1139 y fd(defun)47 b fc(form) 1103 b fb([)p fc(DOC-HANDLER)r fb(])338 1228 y(Do)q(cumen)o(tation)15 b(handl\ er)h(for)f(functions.)224 1347 y fd(defmacro)45 b fc(form)1033 b fb([)p fc (DOC-HANDLER)r fb(])338 1436 y(Do)q(cumen)o(tation)15 b(handler)h(for)f(macro\ s.)224 1555 y fd(defstruct)48 b fc(form)1040 b fb([)p fc(DOC-HANDLER)r fb(]) 338 1644 y(Do)q(cumen)o(tation)15 b(handler)h(for)f(structures.)224 1763 y fd (de\014ne-condition)49 b fc(form)906 b fb([)p fc(DOC-HANDLER)r fb(])338 1852 y (Do)q(cumen)o(tation)15 b(handler)h(for)f(conditions.)224 1971 y fd(deft)o (yp)q(e)47 b fc(form)1069 b fb([)p fc(DOC-HANDLER)r fb(])338 2060 y(Do)q(cume\ n)o(tation)15 b(handler)h(for)f(t)o(yp)q(es.)224 2179 y fd(defsetf)47 b fc (form)1082 b fb([)p fc(DOC-HANDLER)r fb(])338 2268 y(Do)q(cumen)o(tation)15 b (handler)h(for)f(setf)g(mappings.)224 2387 y fd(defmetho)q(d)47 b fc(form) 1006 b fb([)p fc(DOC-HANDLER)r fb(])338 2476 y(Do)q(cumen)o(tation)15 b(handl\ er)h(for)f(metho)q(ds.)224 2595 y fd(defgeneric)46 b fc(form)1017 b fb([)p fc (DOC-HANDLER)r fb(])338 2684 y(Do)q(cumen)o(tation)15 b(handler)h(for)f(gener\ ic)h(functions.)1072 2817 y(2)p eop %%Page: 1 4 bop 599 489 a fi(L)618 480 y fh(a)651 489 y fi(T)691 511 y(E)731 489 y(X)24 b (output)f(for)h fg(user-manual)894 645 y ff(Marco)15 b(An)o(toniotti)938 703 y (Rob)q(otics)i(Lab)609 761 y(Couran)o(t)e(Institute)i(for)f(Mathematical)g (Science)856 819 y(New)h(Y)l(ork)g(Univ)o(ersit)o(y)791 877 y fe(marcoxa@robo\ cop.nyu.e)q(du)910 1002 y ff(Jan)o(uary)e(5,)i(1993)224 1176 y fd(extract-do) q(cumentation)48 b fc(b)n(o)n(dy)957 b fb([)p fc(MA)o(CR)o(O)t fb(])224 1390 y fd(atom-o)o(r-ca)o(r)43 b fc(list-or-atom)940 b fb([)p fc(FUNCTION)7 b fb(]) 224 1604 y fd(*do)q(cumentation-handlers*)48 b fc(\(make-hash-table)17 b(:tes\ t)f(#'e)n(qual\))286 b fb([)p fc(V)-5 b(ARIABLE)5 b fb(])338 1698 y(Hash)14 b (table)i(of)e(en)o(tries)h(of)f(the)h(form)f(\(handler)h(description\),)h(whe\ re)f(de\014ner)h(is)f(the)338 1754 y(car)f(of)g(the)g(de\014nition)j(form)c (handled)j(\(for)e(example,)h(DEFUN)f(or)f(DEFMA)o(CR)o(O\),)338 1811 y(handl\ er)19 b(is)f(a)f(function)i(whic)o(h)g(tak)o(es)e(the)h(form)f(as)g(input)i (and)f(v)m(alue-returns)h(the)338 1867 y(name,)i(argumen)o(t-list)g(and)g(do) q(cumen)o(tation)f(string,)i(and)e(description)i(is)f(a)g(one-)338 1924 y(w)o (ord)14 b(equiv)m(alen)o(t)j(of)e(de\014ner)h(\(for)e(example,)i(FUNCTION)g (or)e(MA)o(CR)o(O\).)224 2044 y fd(de\014ne-do)q(c-han)q(dler)48 b fc(de\014n\ er)16 b(ar)n(glist)f(description)h fd(&b)q(o)q(dy)i fc(b)n(o)n(dy)372 b fb ([)p fc(MA)o(CR)o(O)t fb(])338 2138 y(De\014nes)12 b(a)g(new)g(do)q(cumen)o (tation)h(handler.)20 b(DEFINER)12 b(is)g(the)h(car)e(of)h(the)g(de\014nition) 338 2194 y(form)i(handled)i(\(e.g.,)d(defun\),)i(DESCRIPTION)h(is)g(a)e(one-w) o(ord)g(string)h(equiv)m(alen)o(t)338 2251 y(of)k(de\014ner)h(\(e.g.,)f("func\ tion"\),)h(and)f(AR)o(GLIST)h(and)g(BOD)o(Y)f(together)g(de\014ne)h(a)338 2307 y(function)12 b(that)f(tak)o(es)f(the)h(form)g(as)g(input)h(and)g(v)m(alue-re\ turns)g(the)g(name,)g(argumen)o(t-)338 2363 y(list,)j(do)q(cumen)o(tation)h (string,)f(and)g(a)g(list)h(of)f(an)o(y)g(quali\014ers)h(of)f(the)g(form.)224 2484 y fd(\014nd-do)q(c-hand)q(ler)48 b fc(de\014ner)948 b fb([)p fc(FUNCTION) 7 b fb(])338 2577 y(Giv)o(en)19 b(the)f(car)g(of)g(a)g(form,)g(\014nds)h(the) f(appropriate)g(do)q(cumen)o(tation)h(handler)g(for)338 2634 y(the)c(form)g (if)g(one)h(exists.)1072 2817 y(1)p eop %%Trailer end %%EOF
39,490
Common Lisp
.l
525
74.207619
78
0.843783
foss-santanu/code-tools
0
0
0
GPL-2.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
36f7690c59bddb82e22b0bbb88b0aba5aeef9449c65246256057758706a267c8
29,173
[ -1 ]
29,190
example-schema.lisp
mpemer_delta-base/example-schema.lisp
((:create-table mkt ((id :type integer) (symbol :type text) (desc :type (or s-sql:db-null text)))) (:create-table bs_ass_val ((id :type integer) (bs_id :type integer) (name :type text) (value :type numeric))) (:create-table bs ((id :type integer) (instr_id :type integer) (date :type date) (period :type smallint))) (:create-table bs_lia_val ((id :type integer) (bs_id :type integer) (name :type text) (value :type numeric))) (:create-table instr ((id :type integer) (mkt_id :type integer) (ticker :type text) (name :type (or s-sql:db-null text)) (ipo_year :type (or s-sql:db-null smallint)) (sector :type (or s-sql:db-null text)) (industry :type (or s-sql:db-null text)) (fy_month :type smallint))) (:create-table istmt ((id :type integer) (instr_id :type integer) (date :type date) (period :type smallint))) (:create-table is_val ((id :type integer) (istmt_id :type integer) (name :type text) (value :type numeric))) (:create-table cf ((id :type integer) (instr_id :type integer) (date :type date) (period :type smallint))) (:create-table cf_val ((id :type integer) (cf_id :type integer) (name :type text) (value :type numeric))) (:create-table price ((id :type integer) (instr_id :type integer) (date :type date) (open :type numeric) (high :type numeric) (low :type numeric) (close :type numeric) (volume :type integer) (adj_close :type numeric))))
1,528
Common Lisp
.lisp
58
22.310345
47
0.636301
mpemer/delta-base
0
0
0
GPL-3.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
d1cc86db3d62d925c9eda6290f66b1d7b876458150e8939560565a246e2f5d38
29,190
[ -1 ]
29,191
delta-base.lisp
mpemer_delta-base/delta-base.lisp
;;; -*- Mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (C) by Marcus Pemer <[email protected]> ;;; ;;; This file is part of DELTA-BASE. ;;; ;;; DELTA-BASE is free software: you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation, either version 3 of the License, or ;;; (at your option) any later version. ;;; ;;; DELTA-BASE is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with DELTA-BASE. If not, see <http://www.gnu.org/licenses/>. (in-package :cl) (defpackage :delta-base (:use cl asdf postmodern iterate lisp-unit) (:export #:read-schema #:schema-diff #:delta-base #:delta-base-sql #:make-sql)) (in-package :delta-base) (defprepared tables-stmt "SELECT table_name FROM information_schema.tables WHERE table_schema='public'" :column) (defun table-name (table) (second table)) (defun table-columns (table) (third table)) (defun column-name (column) (sql-symbol (first column))) (defun column-type (column) (third column)) (defun read-tables () (tables-stmt)) (defprepared column-stmt "SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = $1") (defun column-row-name (column) (sql-symbol (first column))) (defun column-row-type (column) (sql-symbol (second column))) (defun column-row-is-nullable (column) (third column)) (defun column-row-is-nullable-p (column) "Return non-nil if a column is nullable" (string-equal (column-row-is-nullable column) "YES")) (defun sql-symbol (symbol-string) "Helper function to make an INTERNed symbol out of input string" (intern (string-upcase symbol-string))) (defun read-columns (table-name) "Read columns from table in database" (column-stmt table-name)) (defun find-table (table schema) "Find a table in a schema" (find-if #'(lambda (tbl) (string-equal (table-name tbl) (table-name table))) schema)) (defun find-column (schema table column) "Find column in a table, in a schema" (let ((table-b (find-table table schema))) (find-if #'(lambda (clmn) (string-equal (column-name clmn) (column-name column))) (table-columns table-b)))) (defun read-schema (&optional db-params) "Query database and return schema definition as an S-SQL expression" (with-connection db-params (iter (for table-name in (read-tables)) (collect (list :create-table (sql-symbol table-name) (iter (for column in (read-columns table-name)) (collect (list (column-name column) :type (if (column-row-is-nullable-p column) (append '(or db-null) (list (column-row-type column))) (column-row-type column)))))))))) (defun concat-sql-strings (list) "A non-recursive function that concatenates a list of sql statement strings with semi-colons and line breaks" (if (listp list) (with-output-to-string (s) (dolist (item list) (if (stringp item) (format s "~a;~%" item)))))) (defun make-sql (schema) "Convert an S-SQL expression to an executable SQL string" (concat-sql-strings (mapcar #'s-sql::sql-compile schema))) (defun make-table-statement (table &key (op :create-table)) "Make CREATE TABLE or DROP TABLE s-sql statement" (cond ((eq op :create-table) (list table)) ((eq op :drop-table) (list (list :drop-table (table-name table)))) (t (error (format nil "Operation ~a not supported" op))))) (defun create-table (table) "Make CREATE-TABLE s-sql statement" (make-table-statement table :op :create-table)) (defun drop-table (table) "Make DROP TABLE s-sql statement" (make-table-statement table :op :drop-table)) (defun make-column-statement (column table &key (op :add-column)) "Make ALTER TABLE statement to manipulate columns" (cond ((or (eq op :add-column) (eq op :alter-column)) (list (append (list :alter-table (table-name table) op (column-name column)) (rest column)))) ((eq op :drop-column) (list (list :alter-table (table-name table) op (column-name column)))) (t (error (format nil "Operation ~a not supported" op))))) (defun alter-column (column table) "Make ALTER COLUMN s-sql statement" (make-column-statement column table :op :alter-column)) (defun add-column (column table) "Make ADD COLUMN s-sql statement" (make-column-statement column table :op :add-column)) (defun drop-column (column table) "Make DROP COLUMN s-sql statement" (make-column-statement column table :op :drop-column)) (defun columns-differ-p (a b) "Return nil if the definitions of column a and b are equal, non-nil otherwise" (not (equal (rest a) (rest b)))) (defun schema-diff (schema-a schema-b) "Create S-SQL statements that represent going from schema-a to schema-b. Both schema-a and schema-b are given as S-SQL forms." (let ((statements ())) (labels ((add-statement (statement) (setf statements (append statements statement)))) ;; find and add statements for any added or altered objects (iter (for table-a in schema-a) (if (find-table table-a schema-b) (iter (for column-a in (table-columns table-a)) (let ((column-b (find-column schema-b table-a column-a))) (if column-b (when (columns-differ-p column-a column-b) (add-statement (alter-column column-a table-a))) (add-statement (add-column column-a table-a))))) (add-statement (create-table table-a)))) ;; find and add statements for any removed objects (iter (for table-b in schema-b) (if (find-table table-b schema-a) (iter (for column-b in (table-columns table-b)) (unless (find-column schema-a table-b column-b) (add-statement (drop-column column-b table-b)))) (add-statement (drop-table table-b)))) ;; return results statements))) (defun delta-base (schema db) "Calculate delta between schema and db, returns results as s-sql statements" (with-connection db (schema-diff schema (read-schema db)))) (defun delta-base-sql (schema db) "Calculate delta between schema and db, returns results as a string of sql statements" (make-sql (delta-base (schema sb)))) (schema-diff '((:create-table bs ((id :type integer) (instr_id :type integer) (date :type date) (period :type smallint)))) '((:create-table bs ((id :type integer) (instr_id :type integer) (period :type smallint)))))
6,761
Common Lisp
.lisp
168
36.059524
111
0.693191
mpemer/delta-base
0
0
0
GPL-3.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
c462e50fcad4524dea9ae8046d8f4bd07021595bec71ddd2f4b438ba692746c3
29,191
[ -1 ]
29,192
bundle.lisp
mpemer_delta-base/bundle.lisp
;;; -*- Mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (C) by Marcus Pemer <[email protected]> ;;; ;;; This file is part of DELTA-BASE. ;;; ;;; DELTA-BASE is free software: you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation, either version 3 of the License, or ;;; (at your option) any later version. ;;; ;;; DELTA-BASE is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with DELTA-BASE. If not, see <http://www.gnu.org/licenses/>. (in-package :cl) (ql:quickload "delta-base") (when (> (lisp-unit::fail (lisp-unit:run-tests :all :delta-base)) 0) (format t "Unit tests were not successful - exiting doing nothing.~%") (sb-ext:exit :code 1)) (ql:quickload "com.dvlsoft.clon") (defpackage :delta-base-bundle (:use cl delta-base com.dvlsoft.clon) (:export #:main)) (in-package :delta-base-bundle) (defparameter *version* "0.0.1") (defsynopsis (:postfix "[FILE-A FILE-B]") (text :contents "Database schema comparison using S-SQL") (group (:header "Options:") (enum :short-name "o" :long-name "op" :enum '(:compare :extract) :description "Operation") (enum :short-name "f" :long-name "format" :enum '(:sql :s-sql) :description "Output Format") (flag :short-name "?" :long-name "help" :description "Print this help and exit.") (stropt :short-name "d" :long-name "database" :description "The database name") (stropt :short-name "h" :long-name "host" :description "Database host") (stropt :short-name "u" :long-name "user" :description "Database user name") (stropt :short-name "p" :long-name "pass" :description "Database user password") (flag :short-name "v" :long-name "version" :description "Print version number and exit."))) (defun print-version () (format t "DELTA-BASE, VERSION ~a Copyright (C) by Marcus Pemer <[email protected]> DELTA-BASE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. DELTA-BASE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with DELTA-BASE. If not, see <http://www.gnu.org/licenses/>. " *version*)) (defun main () (make-context) (when (getopt :long-name "help") (help) (exit :code 0)) (when (getopt :long-name "version") (print-version) (exit :code 0)) (let* ((database (getopt :long-name "database")) (user (getopt :long-name "user")) (pass (getopt :long-name "pass")) (host (getopt :long-name "host")) (db-params (list database user pass host :pooled-p t)) (file-a (first (remainder))) (file-b (second (remainder))) (schema-a (if file-a (with-open-file (file file-a) (read file)) (if (listen) (read) (read-schema db-params)))) (schema-b (if file-b (with-open-file (file file-b) (read file)) (if (first db-params) (read-schema db-params) (read)))) (output (if (string-equal (getopt :long-name "op") "extract") schema-a (schema-diff schema-a schema-b)))) (when output (if (string-equal (getopt :long-name "format") "sql") (format t "~a" (make-sql output)) (progn (print output) (terpri))))) (exit)) (in-package :cl) (sb-ext:save-lisp-and-die "delta-base" :toplevel #'delta-base-bundle:main :executable t)
3,985
Common Lisp
.lisp
100
36.2
88
0.685974
mpemer/delta-base
0
0
0
GPL-3.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
7526c4154391fddf1cc2fa617e25d9358db10d262cdeb3cc924e97424a273495
29,192
[ -1 ]
29,193
test.lisp
mpemer_delta-base/test.lisp
(in-package :delta-base) (define-test schema-diff (assert-equal ;; equal nil (schema-diff '((:CREATE-TABLE MKT ((ID :TYPE INTEGER) (SYMBOL :TYPE TEXT) (DESC :TYPE (OR DB-NULL TEXT))))) '((:CREATE-TABLE MKT ((ID :TYPE INTEGER) (SYMBOL :TYPE TEXT) (DESC :TYPE (OR DB-NULL TEXT))))))) (assert-equal ;; change in column type '((:ALTER-TABLE MKT :ALTER-COLUMN SYMBOL :TYPE TEXT)) (schema-diff '((:CREATE-TABLE MKT ((ID :TYPE INTEGER) (SYMBOL :TYPE TEXT) (DESC :TYPE (OR DB-NULL TEXT))))) '((:CREATE-TABLE MKT ((ID :TYPE INTEGER) (SYMBOL :TYPE INTEGER) (DESC :TYPE (OR DB-NULL TEXT))))))) (assert-equal ;; added column '((:ALTER-TABLE MKT :ADD-COLUMN SYMBOL :TYPE TEXT)) (schema-diff '((:CREATE-TABLE MKT ((ID :TYPE INTEGER) (SYMBOL :TYPE TEXT) (DESC :TYPE (OR DB-NULL TEXT))))) '((:CREATE-TABLE MKT ((ID :TYPE INTEGER) (DESC :TYPE (OR DB-NULL TEXT))))))) (assert-equal ;; dropped column '((:ALTER-TABLE MKT :DROP-COLUMN SYMBOL)) (schema-diff '((:CREATE-TABLE MKT ((ID :TYPE INTEGER) (DESC :TYPE (OR DB-NULL TEXT))))) '((:CREATE-TABLE MKT ((ID :TYPE INTEGER) (SYMBOL :TYPE TEXT) (DESC :TYPE (OR DB-NULL TEXT)))))))) (define-test make-sql (assert-equal "CREATE TABLE mkt (id INTEGER NOT NULL, symbol TEXT NOT NULL, \"desc\" TEXT); " (make-sql '((:CREATE-TABLE MKT ((ID :TYPE INTEGER) (SYMBOL :TYPE TEXT) (DESC :TYPE (OR DB-NULL TEXT)))))))) (in-package :lisp-unit) (setq *print-errors* t *print-summary* t *print-failures* t)
1,576
Common Lisp
.lisp
40
34.575
85
0.622295
mpemer/delta-base
0
0
0
GPL-3.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
c979a0773ad2c88e73cb476988d5d30d136c4c82b16ba377d56d9c9a0123d04f
29,193
[ -1 ]
29,194
delta-base.asd
mpemer_delta-base/delta-base.asd
(in-package :asdf) (defsystem "delta-base" :name "delta-base" :version "0.0.0" :maintainer "Marcus Pemer <[email protected]>" :author "Marcus Pemer <[email protected]>" :description "Delta-base" :long-description "Lisp implementation of database schema delta calculation" :depends-on (:iterate :postmodern :lisp-unit) :components ((:file "test" :depends-on ("delta-base")) (:file "delta-base")))
436
Common Lisp
.asd
13
29.307692
78
0.684086
mpemer/delta-base
0
0
0
GPL-3.0
9/19/2024, 11:37:25 AM (Europe/Amsterdam)
a62d42913f558e947d4fa27a9d6fceeab35685233e7f511f6d70547354a0765f
29,194
[ -1 ]
29,215
main.lisp
KaiQ_search_algorithms/main.lisp
#!/usr/bin/sbcl --script (load "algorithmen.lisp") (format t "OCC: ~A~%" *occ*) (format t "Border: ~A~%" *border*) (format t "Border: ~A~%" *strong-border*) (timing (format t "Schiebe:~%~5TErgebnis: ~A~%~%" (schiebe *alphabet* *such*))) (format t "~%Anzahl = ~A~%" (get-Anzahl)) (timing (format t "Schiebe last-occ:~%~5TErgebnis: ~A~%~%" (schiebe-last-occ *alphabet* *such* *occ*))) (format t "~%Anzahl = ~A~%" (get-Anzahl)) (timing (format t "Morris Pratt Positiv:~%~5TErgebnis: ~A~%~%" (morris-pratt *alphabet* *such* *border*))) (format t "~%Anzahl = ~A~%" (get-Anzahl)) (timing (format t "Knuth Morris Pratt Positiv:~%~5TErgebnis: ~A~%~%" (morris-pratt *alphabet* *such* *strong-border*))) (format t "~%Anzahl = ~A~%" (get-Anzahl))
745
Common Lisp
.lisp
13
55.846154
119
0.629477
KaiQ/search_algorithms
0
0
0
GPL-3.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
90efe7e4ff46049d9402361c202d0e2b65d90323cb1b5f35df177967b7170a38
29,215
[ -1 ]
29,216
algorithmen.lisp
KaiQ_search_algorithms/algorithmen.lisp
(load "lib.lisp") (defun schiebe (alphabet such) (get_map alphabet such)) (defun last-occ (such) (let ((m (length such))) (remove-duplicates (loop for i from 0 to (- m 2) for p = (position (aref such i) such :from-end t :end (- m 1)) collect (list (aref such i) (if (null p) m (- m p 1)))) :test #'equal))) (defparameter *occ* (last-occ *such*)) (defun get-from-occ (occ buchstabe default-ret) (cond ((null occ) default-ret) ((eq buchstabe (car (car occ))) (second (car occ))) (t (get-from-occ (cdr occ) buchstabe default-ret)))) (defun schiebe-last-occ (alphabet such occ) (let ((m (length such))) (get_map alphabet such :next-i (lambda (I J) ;(format t "i= ~A j= ~A~%" I J) ;(format t "buchstabe= ~A~%" (file-access alphabet (+ I (- m 1)))) ;(format t "schiebe um ~A~%" (get-from-occ occ (file-access alphabet (+ I (- m 1))) m)) (+ i (get-from-occ occ (file-access alphabet (+ I (- m 1))) m)) )))) (defun border (such) (let* ((m (length such)) (bord (make-array (+ 1 m) :initial-element -1))) (loop with vart = -1 for j from 1 to m do (loop while (>= vart 0) while (not (eq (aref such vart) (aref such (- j 1)))) do (setf vart (aref bord vart)) ) do (incf vart) do (setf (aref bord j) vart) ) bord ) ) (defun strong-border (such) (let* ((m (length such)) (bord (make-array (+ 1 m) :initial-element -1))) (loop with vart = -1 for j from 1 to m ;for vart = (aref bord (- j 1)) do (loop while (>= vart 0) while (not (eq (aref such vart) (aref such (- j 1)))) do (setf vart (aref bord vart)) ) do (incf vart) do (setf (aref bord j) vart) do (if (or (= j m) (not (eq (aref such vart) (aref such j)))) ;do (if (and (not (= j m)) (not (eq (aref such vart) (aref such j)))) (setf (aref bord j) vart) (setf (aref bord j) (aref bord vart))) ) bord ) ) (defparameter *border* (border *such*)) (defparameter *strong-border* (strong-border *such*)) (defun morris-pratt (alphabet such bord) (get_map alphabet such :next-i (lambda (I J) (+ I (- j (aref bord J)))) :next-j (lambda (I J) (max 0 (- j (- j (aref bord j))))) ))
2,531
Common Lisp
.lisp
75
25.813333
110
0.509202
KaiQ/search_algorithms
0
0
0
GPL-3.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
7de8f82e4ff3209c995e8aeb7d66bec36be83eba7fbd5b6d63f6cb3520308156
29,216
[ -1 ]
29,217
lib.lisp
KaiQ_search_algorithms/lib.lisp
(defparameter *alphabet* "aaaaaaaaaa@@łłµµæſðæðđŋſđħ€¶ŧł←ŧþ€¶đðøħðđ«„↓ſð„↓ſð↓ŋſ↓ðaabbbbbbbbbbbbccccccccccccdddddddddabcabcabababcdabab") (defparameter *such* "abcd") (if (third *posix-argv*) (setf *alphabet* (make-string-input-stream (third *posix-argv*))) (setf *alphabet* *standard-input*)) (if (second *posix-argv*) (setf *such* (second *posix-argv*))) (defmacro timing (&body forms) (let ((real1 (gensym)) (real2 (gensym)) (run1 (gensym)) (run2 (gensym)) (result (gensym))) `(let* ((,real1 (get-internal-real-time)) (,run1 (get-internal-run-time)) (,result (progn ,@forms)) (,run2 (get-internal-run-time)) (,real2 (get-internal-real-time))) (format *debug-io* ";;; Computation took:~%") (format *debug-io* ";;; ~f seconds of real time~%" (/ (- ,real2 ,real1) internal-time-units-per-second)) (format t ";;; ~f seconds of run time~%~%" (/ (- ,run2 ,run1) internal-time-units-per-second)) ,result))) (let ((anzahl 0)) (defun get-anzahl () (let ((anz anzahl)) (setf anzahl 0) anz)) (defun file-access (f-stream pos &optional (seek 0) &key (do-count t)) (let ((ret nil)) (file-position f-stream (+ pos seek)) (if (listen f-stream) (progn (incf anzahl) (setf ret (read-char f-stream)))) ret) ) ) (defun file-access-peek (f-stream pos) (file-position f-stream pos) (listen f-stream) ) (defun file-reset (f-stream) (if (streamp f-stream) (file-position f-stream 0))) (defun get_map (gesamt such &key (next-i (lambda (I J) (+ i 1))) (next-j (lambda (I J) 0))) (let* ((m (length such)) (ret (loop with i = 0 while (file-access-peek gesamt i) with j = 0 do (loop while (< j m) while (eq (aref such j) (file-access gesamt i j)) do (incf j) ) when (= j m) collect i do (setf i (funcall next-i i j)) do (setf j (funcall next-j i j)) ;do (format t "i= ~A j= ~A~%" i j) ) )) (file-reset gesamt) ret ))
2,405
Common Lisp
.lisp
73
23.575342
113
0.519417
KaiQ/search_algorithms
0
0
0
GPL-3.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
ac8604678b7c7f3323d619d2807beffb7d06592ef020187e76a6c403941cbc43
29,217
[ -1 ]
29,236
digest-file.lisp
leongithub_cl-exercise/digest-file.lisp
;;;; cl版本的 sha1 和 md5 校验码,可以在 windows 上用 cl 方便的校验文件 (defun sha1sum (pathname) (digest-sum :sha1 pathname)) (defun md5sum (pathname) (digest-sum :md5 pathname)) (defmacro digest-sum (digest-name pathname) (let ((digester (gensym))) `(let ((,digester (ironclad:make-digest ,digest-name))) (ironclad:byte-array-to-hex-string (ironclad:digest-file ,digester ,pathname)))))
437
Common Lisp
.lisp
10
35.9
59
0.703125
leongithub/cl-exercise
0
0
0
GPL-2.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
f89855878a69676d3c5fdb7f6fe2405cfa613227bf718bcdca090e9eaf3ddadc
29,236
[ -1 ]
29,237
web-spider.lisp
leongithub_cl-exercise/web-spider/web-spider.lisp
;;;; web-spider.lisp ;; 用法: ;; (ql:quickload :web-spider) ;; (in-package :web-spider) ;; (sicp-exercise-*) (in-package #:web-spider) ;;; "web-spider" goes here. Hacks and glory await! ;; 由于搬新家,可能暂时没有网络,所以写个迷你爬虫,把 sicp 的习题爬下来 ;; 当然,这个小程序离真正的爬虫还远,只满足目前的需求 (defparameter *base-path* "/Users/leon/Documents/sicp-exercise/") ;; http://eli.thegreenplace.net/tag/sicp此网址保存习题 (defun sicp-exercise-eli () (let* ((dir-parent (ensure-directories-exist (concatenate 'string *base-path* "eli/"))) (dir-list (cdr (cl-ppcre:split "/" dir-parent))) (body (drakma:http-request "http://eli.thegreenplace.net/tag/sicp"))) (cl-ppcre:do-register-groups (uri) ("<td><a href='(.*)'>.*</a></td>" body) (let ((filespec (make-pathname :directory (cons :absolute dir-list) :name (car (last (cl-ppcre:split "/" uri))) :type "html"))) (unless (probe-file filespec) (spider-to-file uri filespec)))))) ;; http://community.schemewiki.org/?sicp-solutions此网址保存习题 ;; 与sicp-exercise-eli模式好像,应该能抽象出个宏,但又有些不太一样的地方 ;; 留给以后优化 (defun sicp-exercise-solutions () (let* ((dir-parent (ensure-directories-exist (concatenate 'string *base-path* "solutions/"))) (dir-list (cdr (cl-ppcre:split "/" dir-parent))) (body (drakma:http-request "http://community.schemewiki.org/?sicp-solutions")) (base-uri "http://community.schemewiki.org/")) (cl-ppcre:do-register-groups (uri) ("<a href=\"/(\\?sicp-ex-.{3,4})\">sicp-ex-" body) (let ((filespec (make-pathname :directory (cons :absolute dir-list) :name uri :type "html"))) (unless (probe-feile filespec) (spider-to-file (concatenate 'string base-uri uri) filespec)))))) ;; 通过一个url保存到文件名为<title>的html文件中 ;; 这里把http-request的返回值都写出来只是为了清晰而已,完全用nth-value可以只获得body (defun spider-to-file (spider-uri filespec) (multiple-value-bind (body status-code headers uri stream must-close reason-phrase) (drakma:http-request spider-uri) (declare (ignore status-code headers uri stream must-close reason-phrase)) (with-open-file (out filespec :direction :output :if-exists :supersede :external-format :utf-8) (princ body out)))) ;; 根据body中title,生成文件名 ;; 感觉爬虫应该用uri命名比较好,所以暂不用此方法 (defun generation-html-filename (body) (concatenate 'string (svref (nth-value 1 (cl-ppcre:scan-to-strings "<title>(.*)</title>" body)) 0) ".html"))
2,775
Common Lisp
.lisp
63
34.015873
80
0.675352
leongithub/cl-exercise
0
0
0
GPL-2.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
ae4bf87d291f5194f128b21a8dec5bb5b936ac51b86860cb17466b7df9e17509
29,237
[ -1 ]
29,238
web-spider.asd
leongithub_cl-exercise/web-spider/web-spider.asd
;;;; web-spider.asd (asdf:defsystem #:web-spider :description "Describe web-spider here" :author "Your Name <[email protected]>" :license "Specify license here" :depends-on (#:drakma #:cl-ppcre) :serial t :components ((:file "package") (:file "web-spider")))
307
Common Lisp
.asd
10
25.3
45
0.630508
leongithub/cl-exercise
0
0
0
GPL-2.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
ad8c4f69645b51622fd503ae2648affc4050e88d05a228f5c5b3f9483df72783
29,238
[ -1 ]
29,256
initfn.lisp
thinkum_ltp-main/src/test/lsp/initfn.lisp
;; initfn.lisp - prototypes onto portable &env application (in-package #:ltp/common) (defmacro frob-env (&environment env) `(values ,env)) (defun mk-initfunction-lambda (form environment) (multiple-value-bind (vars vals store-vars writer-form reader-form) (get-setf-expansion form environment) (declare (ignore store-vars writer-form)) `(lambda () (let (,@(when vars (mapcar #'list vars vals))) #+NIL ,@(when vars `((declare (ignorable ,@vars)))) ,reader-form)) )) (eval-when () ;; NB: The usage of GET-SETF-EXPANSION in MK-INITFUNCTION-LAMBDA may ;; not be enough to minimize compiler warnings, if an initfunction is ;; compiled in an environment in which any variables referenced in the ;; initfunction are not bound. ;; NB: SYMBOL-VALUE itself does not provide a portable 'environment' param ;; Some functions, "Beyond this," may be implementation-specific, ;; moreover application-specific - e.g if to retrieve the value of a ;; symbol initform from within the environment in which that iniform ;; was originally declared, in evalution -- in precedence to any ;; environment in which any resulting initfunction may be evaluated. (mk-initfunction-lambda '*standard-output* nil) (mk-initfunction-lambda '*standard-output* (frob-env)) (let ((*standard-output* *debug-io*)) (mk-initfunction-lambda '*standard-output* (frob-env))) (let ((frob 12321)) (mk-initfunction-lambda 'frob (frob-env))) (let ((frob (list 1 2))) (mk-initfunction-lambda '(cdr frob) (frob-env))) (let ((frob (list 1 2))) (mk-initfunction-lambda '(cdr assume-bound) (frob-env))) (mk-initfunction-lambda '(cdr assume-bound) (frob-env)) (let ((frob (list 1 2))) (declare (dynamic-extent frob)) ;; no change to the resulting form (mk-initfunction-lambda '(cdr frob) (frob-env))) )
1,905
Common Lisp
.lisp
41
41.634146
76
0.691391
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
eda1a1f48872a308a0b6a926f2daf94ad2cb8ec2a28607d6442bc72bf6872ba7
29,256
[ -1 ]
29,257
with-condition-restart.lisp
thinkum_ltp-main/src/test/lsp/with-condition-restart.lisp
;; with-condition-restart.lisp -- portable condition/restart integration ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/stor/fdef) ;; NB: The following definitions should be available within the Common ;; Lisp package #:ltp/stor/fdef - whether defined there, defined in any ;; system in use by the same. ;; ;; - FINALIZED-CLASS (Type) ;; - UNFINALIZED-CLASS (Condition Type) ;; ;; These definitions are required for evaluation of the source forms, below ;; ;; These definitions may be available via the source system ;; ltp-main:src/main/lsp/base-class/ltp-base-class-fdef.asd ;; -------------------- #+TBD (defmacro with-conditional-restarts ((&rest restart-decls) form &rest handler-decls) ) ;; NB: The following prototype form for ENSURE-CLASS-FINALIZED-P was ;; developed with regards to a short number of concerns: ;; ;; - as with regards to how the FINALIZE restart, provided within the ;; function's definition, may be invoked from the debugger ;; ;; - principally, as with regards to how a restart invoked due to an ;; error condition may access the condition for which the restart was ;; invoked. For interactive purposes, this is accopmlished with a ;; lexically scoped function, below. This approach presents some ;; limitations, however -- such as with regards to how that lexically ;; scoped function is applied for the interactive form of the ;; restart, as below, moreover as with regards to the lexical ;; availabilty of a corresponding "Setter Form," such that -- in a ;; senese -- must be used within a corresponding function defined ;; with HANDLER-BIND, to make the condition available to the restart, ;; as with the following methodology. (defun* %ensure-class-finalized-p (class) ;; ;; NB: This has been approached otherwise, in the initial definition ;; of LTP/STOR/FDEF::ENSURE-CLASS-FINALIZED-P -- in which, an assumption ;; corresponding to that function's present definition has been ;; denoted, in a precautionary manner, in that function's source form. ;; ;; This definition is provided as a prototype form, and may be later ;; adopted in redefinition of LTP/STOR/FDEF::ENSURE-CLASS-FINALIZED-P ;; (declare (type class-designator class) (values class &optional)) (let ((%class (compute-class class)) (*condition*)) (declare (type class %class) (type (or null condition) *condition) (special *condition*)) (labels (#+NIL (set-conndition (c) ;; refer to remarks in the HANDLER-BIND source ;; form, below. This lexically scoped function may ;; not be available for the condition handler ;; function, due to limitations with regards to ;; environments in this program's evaluation. (setq *condition* c)) (get-condition-for-restart () ;; FIXME: Not in itself an interactive I/O form, this ;; function simply serves to facilitate exact matching of ;; (A) a restart to (B) a condition for which the restart ;; was invoked. As such, it's used in lieu of the ;; :INTERACTIVE form for the FINALIZE restart, below. ;; ;; This is, in a sense, a "Hack" provided here for ;; purpose of illustrating the semantics of this ;; programming pattern. ;; ;; Considering that there must be a manner of logical ;; distiniction betweeh (A) HANDLER-BIND and RESTART-BIND ;; forms, in a program, (B) source forms such that may ;; interact, whatsoever directly or indirectly, with the ;; forms per [A], and (C) the call forms representing ;; the interactive debugger, in any implementation ;; environment: Perhaps there may be any other approach ;; possible, logically, towards addressing this concern ;; with regards to accessing the condition for which a ;; restart would be invoked, in the semantic ;; specificatoin of anysingle restart -- as whether ;; invoked interactively from within the debugger or ;; invoked directly in a program call forms. ;; ;; This source form presents, simply, a prototype in a manner ;; of a generalized programming pattern, illustrated ;; about a specific usage case, namely: To check whether ;; a class is finalized and, if it is not, to allow the ;; user to interactively specificy, or to allow any ;; calling program to non-interactively specify that the ;; class should be finalized per default. This, in ;; itself, may not represent a very broad concern for ;; application environments except insofar as an ;; application may require that a class is finalized ;; before any subsequent program forms ;; ;; This prototype, in itself, was produced pursuant ;; towards runtime computation of FTYPE declarations for ;; functional accessors onto slots of finalized ;; classes. ;; ;; In a sense with regards to expected usage cases, this ;; may seem to represents a manner of"IDE Sugar." ;; ;; Ideally, the UNFINALIZED-CLASS condition should not ;; ever be reached in any user installed program. Some ;; concerns as may be entailed of an UNFINALIZED-CLASS ;; condition may not be addressed without regards to the ;; definition of the class for which the condition itself ;; would be signaled. ;; (list *condition*))) (handler-bind ((unfinalized-class (lambda (c) ;; NB: DNW - cf. lexical ;; environments in Common Lisp #+DNW (set-condition c) (setq *condition* c) ))) (restart-case (progn (or (class-finalized-p %class) (error 'unfinalized-class :expecteted-type 'finalized-class :datum %class)) (values %class)) ;; TBD: RESTART-CASE like HANDLER-BIND (??) (finalize (&optional c) :report "Finalize Class" ;; NB: It may seem that the following should be approached in ;; something of a more prototypical manner -- simply to ensure ;; that a condition for which a restart is invoked will be ;; available to the restart's restart function, when that ;; function is invoked, even when that restat is invoked ;; interactively within a debugger. ;; ;; This assumes that when this restart is invoked ;; interactively, a HANDLER-BIND call -- as per the condition ;; type of the condition to be handled, here -- will have set ;; the condition as the binding of the *CONDITION* ;; varaible. Failing that external call, moreover during ;; an interactive invocation of this restart, the identity of ;; the condition for which this FINALIZE restart is invoked ;; may not be unambiguously determined here. ;; :interactive get-condition-for-restart (typecase c (unfinalized-class ;; NB: DNW if the calling procedure is not providing the ;; condition to this restart. ;; ;; Towards a portable definition of this restart, if the ;; restart is reached via any manner external to this ;; function -- vis a vis Common Lisp #'CONTINUE -- it ;; should only be invoked for a suitable condition such ;; that would be provided to the restat, when the restart ;; is invoked. When invoked interactively, the condition ;; may be accessed -- such as here -- from within the ;; calling lexical environment. When invoked directly from ;; a program procedure, the condition should be provided to ;; that procedure -- i.e the analogous FINALIZE restart ;; function would require a single argument, denoting a ;; condition for which it is being invoked, rather than ;; only providing an optional argument such as with ;; CL:CONTINUE ;; ;; Although this may seem like an awkward manner of ;; indirection with regars to the identity of the class to ;; be finalized, it should serve to ensure appropriate ;; matching of the restart to the respective condition - ;; not supporting arbitrary finalization of other classes, ;; per se. ;; ;; NB: For how this restart is defined in a manner ;; principally local to this function's source form, it may ;; not be logically possible for this restart to be invoked ;; other than as a result of the failed CLASS-FINALIZED-P ;; test, above -- unless, per se, any form within the ;; evaluation of that CLASS-FINALIZED-P call would, in ;; itself, endeavor to call to this restart function, ;; assuming that this restart binding would be accessible ;; in that other function's effective lexical environment. ;; ;; As such, this source form in itself may serve to provide ;; an example -- in a sense, a program source template -- ;; towards a semantics for actuation of restarts ;; within the debugger environment -- vis a vis, the ;; arguments provided to a restart, when selected ;; interactively within the debugger or when invoked from ;; within a program, namely for purpose of handling a ;; single error of a known condition type, moreover as ;; with regards to the lexical environment in which the ;; restart is invoked. This is, in a practical sense, ;; intended for purpose of ensuring a manner of logical ;; consistency in program call forms. ;; NB: Besides accessing the condition for which the ;; restart is invoked, this form also acceses the identity ;; of the class for which the initial %ENSURE-CLASS-FINALIZED-P ;; call was invoked - namely, as accessed via the lexical ;; environment in which the restart's effective restart ;; function is assumed to be defined. (let ((%%class (type-error-datum c))) (cond ((eq %%class %class) (finalize-inheritance %class) (values %class)) (t ;; NB: "Odd Catch," but this may be "Logically Reachable" (simple-program-error "Class ~S is not EQ to ~S" %%class %class))))) ;; NB: "Odd Catch," for when C is a condition not created per ;; the ASSERT call, above - Dispatch per type of C (error (error c)) (warning (warning c)) (condition (signal c)) (null (simple-program-error "No condition provided to FINALIZE restart")) (t (simple-program-error "~<Unknown condition ~S~>~ ~< provided to FINALIZE restart~>" c))))))))) ;; (%ensure-class-finalized-p 'string) ;; (%ensure-class-finalized-p (defclass #.(make-symbol "frob") () ())) ;; -------------------- ;; TBD: Declaration of *CONDITION* as a global variable; Portable ;; definition of macro forms and functional forms, for storing and ;; accessing *CONDITION* from within HANDLER-BIND/HANDLER-CASE and ;; corresponding RESTART-BIND/RESTART-CASE forms, in a manner as ;; illustrated in the previous.
12,926
Common Lisp
.lisp
239
42.34728
80
0.598659
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
825fcefd985f2c32139f8a67233fc9fe658ba76e9eae43413466fe3b51bf7383
29,257
[ -1 ]
29,258
acc-package.lisp
thinkum_ltp-main/src/main/lsp/base-class/acc-package.lisp
;; acc-package.lisp - Package Definition for ltp-base-class-acc system ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:cl-user) (defpackage #:ltp/base-class/accessor (:nicknames #:ltp.base-class.accessor) (:use #:ltp/common/mop #:ltp/common #:cl) #+SBCL (:shadowing-import-from ;; FIXME: Port to CMUCL, other implementations using PCL ;; ;; Note remarks with regards to DEFSIGNATURE, in acc-gen.lisp #:sb-pcl #:slot-definition-class) (:export #:write-accessors #:write-accessors-for ))
1,012
Common Lisp
.lisp
26
36.653846
80
0.61687
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
53fcd3b04bdfc8d0fd43e9517ab8db7f3c1ecb4ecae7a31921eca45c6d3ea6a0
29,258
[ -1 ]
29,259
acc-gen.lisp
thinkum_ltp-main/src/main/lsp/base-class/acc-gen.lisp
;; acc-gen.lisp - Accessor Function Definition for ltp-base-class-fdef system ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/base-class/accessor) #+NIL (deftype subtype (name) (labels ((locally-check-one-subtype (spec) (subtypep spec name))) ;; DNW - the type expansion may not be storing the lexical ;; environment in which it was defined `(satisfies locally-check-one-subtype))) ;; (typep '(find-class 'simple-base-string) '(subtype simple-string)) #+TBD (deftype finalized-class (&optional (name t)) ;; The ,NAME spec below DNW except for the class named T. ;; ;; In order to provide a (SATISTFIES SUBTYPE-OF-<TYPE>) predicate ;; for an arbitrary NAME, this DEFTYPE could use a methodology for ;; defininig arbitrary functions for purposes of subtype eval, e.g ;; SUBTYPE-OF-STRING. ;; ;; However, such a methodology could be thought to comprise a manner ;; of a memory leak. `(and class ,name (satisfies class-finalized-p))) ;; (typep (find-class 'string) 'finalized-class) ;; => T ;; (typep (find-class 'simple-base-string) '(finalized-class simple-string)) ;; ^ DNW (deftype finalized-class () `(and class (satisfies class-finalized-p))) (define-condition unfinalized-class (type-error) ;; FIXME - move into a base-class shared system; reuse in LTP singleton () (:default-initargs :expected-type 'finalized-class) (:report (lambda (c s) (format s "~<Not a finalized class:~>~< ~S~>" (type-error-datum c))))) ;; (declaim (inline ensure-class-finalized-p)) (defun* ensure-class-finalized-p (class) ;; FIXME: Move this source definition and the corresponding type and ;; condition class definitions, above, into ltp/common/mop src ;; ;; NB: See also, alternate definition with annotations ;; ltp-main:src/test/lsp/with-condition-restart.lisp ;; (declare (type class-designator class) (values class &optional)) (let ((%class (compute-class class))) (declare (type class %class)) (restart-case (cond ((class-finalized-p %class) (values %class)) (t (error 'unfinalized-class :expecteted-type 'finalized-class :datum %class))) (finalize () ;; ASSUMPTION: That this restart will be invoked only as a ;; result of the failed CLASS-FINALIZED-P condition, denoted ;; above, rather than by any form resulting from CLASS-FINALIZED-P :report "Finalize Class" (finalize-inheritance %class) (values %class))))) ;; (ensure-class-finalized-p 'string) ;; (class-finalized-p (ensure-class-finalized-p (defclass #.(make-symbol "frob") () ()))) ;; should -> T once the FINALIZE restart is invoked ;; NB: An extension onto STANDARD-CLASS may be defined as to ensure that ;; any class is finalized before it may be subsequently used, pursuant ;; of a class' defintion as other than a forward-referenced class. ;; ;; Some extensions onto STANDARD-CLASS moreover may be defined as to ;; require that a class will not be redefined once it is finalized. ;; ;; In such extensions, ENSURE-CLASS-FINALIZED may be -- in effect -- ;; redundant. ;; ;; Regardless, perhaps the following source forms may be applied about ;; non-finalized classes - an error condition, such that this program ;; will endeavor to signal as such. ;; ---------- #| # Remarks - Limitations on Design ## Class Layouts and Slot Value Storage in PCL w/ Multiple Inheritance in CLOS - Juxtapose to class layouts and slot value storage in pcl w/ single inheritance onto CL:DEFSTRUCT - Note also, multiple inheritance in CL:DEFINE-CONDITION * In a practical regard, this may serve to denote a limitation affecting definition of generally defstruct-like accessors onto CLOS, if actuated singularly about direct slot definitions extensionally in MOP. * Theoretically, a program should not assume that the efective slot definition S_E_1 -- by way of slot definition name -- corresponding to a direct slot definition S_D_1 in a class C_1 will have the same effective _layout location_ as an effective slot definition S_E_2 representing the slot described by S_D_1 but in a class C_2, for C_2 defined as a subclass of C_1. To address this concern, In a practical regard, any accessor defined after S_D_1, when applied to an instance of any class not eq to C_1, may dispatch as to make an "Ordinary" call to the MOP function. SLOT-VALUE-USING-CLASS (or any analogous metaobject accessor form, e.g SETF form or SLOT-BOUNDP metaobject accessor form). While perhaps convenient from a perspective of program design, this approach may be believed to be non-optimal for access onto any slot of any subclass of C_1. As such, the accessor may instead produce an error of a subtype of TYPE-ERROR when provided an instance of any class not EQ to the class C_1. (Note that this, in itself, does not serve to provide any limitations towards accessor calls onto dynamically redefined classes, while it may serve to address limitations with regards to class slot layout in subclasses.) * In order to address -- by way of an API limitation -- concerns for slot location accessors, as entailed afyer dynamic redefinition of a class, this source system may subsequently be defined with limitation for applications onto BASE-CLASS, such that a BASE-CLASS may be defined as to not permit class redefinition subsequent of class finalization. * This may be accomplished, in some regards, with a trivial error procedure in a method REINITIALIZE-INSTANCE (BASE-CLASS) * NB: This may entail some updates to the LTP definition of the class SINGLETON, pursuant of refactoring the definition of the classes SINGLETON and PROTOTYPE-CLASS onto BASE-CLASS. In a manner, moreover the LTP SINGLETON class definition may serve to provide an initial usage case for QA about the design and implementation of the slot location accessor subset of functionality, pursuant towards generalized support for a "DEFCLASS like DEFSTRUCT" semantics in definition of LTP BASE-CLASS class metaobjects. In a practical regard, forms using the functions LTP/COMMON/MOP:FINALIZE-REACHABLE -- as within CHANGE-CLASS (FORWARD-REFERENCED-CLASS PROTOTYPE-CLASS) and in SHARED-INITIAIZE :AFTER (SINGLETON T) -- may be considered for subsequent update, after initial testing with regards to the limitation of preventing redefinition of a finalized class for any BASE-CLASS. The definition of ALLOCATE-INSTANCE (SINGLETON) may also be reconsidered, during such refactoring of the design of LTP/COMMON/SINGLETON:SINGLETON and LTP/COMMON/SINGLETON::PROTOTYPE-CLASS classes - both defined under the LTP source system, `ltp-common-singleton` |# ;; ---- ;; ;; General prototypes (FIXME - Redundant) ;; #+TBD (defgeneric compute-accessor-ftype (slotdef class)) #+TBD (defgeneric compute-accessor-lambda (slotdef class)) ;; ^ TBD Interop. w/ LAMBDA*, COMPUTE-ACCESSOR-FTYPE ;; --> COMPUTE-ACCESSOR-DEFUM-EXPANSION #+TBD (defun* compute-direct-accessor-ftypes (class) (declare (type class class) (values list &optional)) (%ensure-class-finalized-p class) ) ;; ---- ;; ;; Some implementation-specific functions ;; ;; FIXME - Pursuant of further development in defportble.lisp ;; provide formal specification of these implementation- ;; specific functions -- and also SLOT-DEFINITION-CLASS, as used ;; in the method ;; WRITE-REFERENCE-EXPRESSION (EFFECTIVE-SLOT-DEFINITION STREAM) ;; ;; ... using DEFSIGNATURE and DEFIMPLEMENTATION expressions, ;; ;; ... with a corresponding warning/error semantics, somehow ;; integrated with ASDF as a build tool, for implementations in ;; which any of the DEFSIGNATURE forms is not provided with an ;; implementation. ;; ;; Furthermore, consider developing a source management utility ;; such that may be used with DEFSIGNATURE/DEFIMPLEMENTATION and ;; this source system, in a complimentary regard. This may or may ;; not entail development of any singular "Emacs Hacks," such as ;; for purposes of IDE support and generalized QA, vis a vis ;; Scrum development philosophy - without, per se, requiring a ;; complete web infrastructure at QA sites, vis a vis ;; Phabricator ;; #+(and SBCL TBD) (defun instance-slot-location (slotd) ;; FIXME-TBD - cf. STANDARD-INSTANCE-ACCESS as implemented in PCL and ;; subsq. in SBCL ;; ;; NB: MOP SLOT-DEFINITION-LOCATION ;; ;; NB: INSTANCE-SLOT-BOUNDP as complimentary to operations using an ;; implementation-specific slot definition location datum ) #+SBCL (defun instance-slot-boundp (slotd instance) ;; utility form, may be applied in ASSERT-SLOT-BOUNDP ;; NB: This prototypr has not, as yet, been accompanied with any ;; comprehensive review of how SLOT-INFO functional members are ;; initialized in a "Built" SBCL, or during SBCL cross-compile. ;; ASSUMPTION: INSTANCE is not a FUNCALLABLE-STANDARD-INSTANCE [FIXME] ;; ;; See also: SBCL SLOT-BOUNDP defun ;; ;; ... although, in this function's definition - which differs to SBCL ;; SLOT-BOUNDP in that this function allways calls the slot-info ;; boundp function ... perhaps this form may be applicable for ;; funcallable instances, if not also for conditions and structure ;; objects, in SBCL [FIXME NEEDS TEST] ;; ASSUMPTION: SLOTD represents a slot definition valid for the class ;; of INSTANCE, throughout the duration of this function's evaluation ;; NB: This was referenced onto the source code of SBCL SLOT-BOUNDP, ;; furthermore referenced onto the object description of the ;; SB-PCL WRAPPER object as such - denoted as a a class signature, ;; below. ;; ;; This may be fairly portable to CMUCL. (let* ((sl-name (slot-definition-name slotd)) (signature (sb-pcl::valid-wrapper-of instance)) (sl-info (sb-pcl::find-slot-cell signature sl-name))) ;; FIXME: This does not err if SL-INFO is null, as it assumes SLOTD ;; will represent a slot defined in the instance's class, throughout ;; the duration of this function's evaluation. (funcall (sb-pcl::slot-info-boundp (cdr sl-info)) instance))) #+(and SBCL NIL) (eval-when () (defclass frob () ((sl-a :initarg :sl-a) (sl-b :allocation :class :initarg :sl-b))) (finalize-reachable (find-class 'frob) nil) (slot-definition-location (find 'sl-b (class-slots (find-class 'frob)) :key #'slot-definition-name :test #'eq)) ;; => <implementation-specific value>, a CONS in SB-PCL (slot-definition-location (find 'sl-a (class-slots (find-class 'frob)) :key #'slot-definition-name :test #'eq)) ;; => <implementation-specific value>, a FIXNUM in SB-PCL ;; NB: Earlier test forms, onto SLOT-INFO and class layout information ;; in SB-PCL (sb-pcl::find-slot-cell (sb-pcl::valid-wrapper-of (find-class 'frob)) 'sl-a) ;; NIL .... (position 'sl-a (sb-pcl::layout-slot-list (sb-pcl::valid-wrapper-of (find-class 'frob))) :key #'slot-definition-name :test #'eq) ;; NIL (describe (sb-pcl::valid-wrapper-of (class-prototype (find-class 'frob)))) ;; NB: CLASS-PROTOTYPE is certainly not the most effective way to find ;; the class' wrapper (sb-pcl::find-slot-cell (sb-pcl::valid-wrapper-of (class-prototype (find-class 'frob))) 'sl-a) ;; => <CONS> with FIXNUM CAR (sb-pcl::find-slot-cell (sb-pcl::valid-wrapper-of (class-prototype (find-class 'frob))) 'sl-b) ;; => <CONS> with NIL CAR (!) / NB: Class allocated slot (funcall (sb-pcl::slot-info-boundp (cdr (sb-pcl::find-slot-cell (sb-pcl::valid-wrapper-of (class-prototype (find-class 'frob))) 'sl-b))) (class-prototype (find-class 'frob))) ;; => NIL (funcall (sb-pcl::slot-info-boundp (cdr (sb-pcl::find-slot-cell (sb-pcl::valid-wrapper-of (class-prototype (find-class 'frob))) 'sl-a))) (class-prototype (find-class 'frob))) ;; => NIL (describe (sb-pcl::slot-info-boundp (cdr (sb-pcl::find-slot-cell (sb-pcl::valid-wrapper-of (class-prototype (find-class 'frob))) 'sl-b)))) ;; -- (instance-slot-boundp (find 'sl-a (class-slots (find-class 'frob)) :test #'eq :key #'slot-definition-name) (class-prototype (find-class 'frob))) ;; => NIL ;; test for a class-alloated slot (instance-slot-boundp (find 'sl-b (class-slots (find-class 'frob)) :test #'eq :key #'slot-definition-name) (class-prototype (find-class 'frob))) ;; => FIXME QUIRKS & NONSENSE (defparameter *frob-1* (make-instance 'frob :sl-a 1 :sl-b 2)) (instance-slot-boundp (find 'sl-a (class-slots (find-class 'frob)) :test #'eq :key #'slot-definition-name) *frob-1*) ;; => T (instance-slot-boundp (find 'sl-b (class-slots (find-class 'frob)) :test #'eq :key #'slot-definition-name) *frob-1*) ;; => T ) ;; ---- ;; ;; Generalized unparser functions ;; ;; NB/Design Documentation: An approach producing "Intrinsic Defun" ;; calls within DEFMACRO may seem preferrable, in some regards, to the ;; generalized "Print Source" approach developed here. ;; ;; This "Print Source" approach -- in effect -- serves to require that ;; at least one of an epehmeral string output stream or effective system ;; source file ;would be created, pursuant to compiling the printed ;; source forms, during any single "Build" in which this system may be ;; used. Of course, the generated source forms may also be directly ;; reviewed, in a manner generally analogous to reviewing the output of ;; MACROEXPAND or MACROEXPAND-1 for a normative macro function call. ;; ;; It might be assumed that if a string output stream is used, any ;; implementation bytecode -- i.e "FASL" information -- such as would be ;; produced during the compilation of the printed source forms, will ;; have been written to a file specified, through any methodology, ;; within the calling lexical environment. Thus, assuming that the ;; source forms have been generated in a manner suitable for any ;; singular manner of systems specification, the FASL forms produced ;; during the compilation could be reused during any later runtime ;; sessions, even if the generated source forms -- e.g if having been ;; written temporarily to any one or more of an ephemeral string output ;; stream -- may not be in themselves immediately available, at that ;; time. ;; ;; This prototype may be accompanied with an extension onto ASDF, for ;; facilitating normal application of this system in extension to any ;; single class definition. Of course, anyone applying this system as ;; such should be assumed to have assumed all responsibilities ;; contingent of distribution of software bytecode and software source ;; code -- pursuant of any formal acceptance of licensing terms, for any ;; software that may be, in effect, extended with such generated source ;; code. In any formal regards, the indemnification clause put forward ;; in this system's licensing terms should be assumed to apply. ;; ;; That being addressed, in hoewver, this system may endeavor to provide ;; some utility forms such that may serve to extend ASDF for source ;; generation in applications of this system. Ideally, such extension ;; should serve to provide some manner of a facility for support of ;; software systems management -- not limited to any matters as may be ;; contingent specifically of evaluatoin of Common Lisp source code, e.g ;; the specification of an IN-PACKAGE form in an output stream, previous ;; to any call to PRINT-READER-FOR onto that output stream. This ;; initiative, itself, may be furthermore continued under the CommonIDE ;; project. ;; TBD: Applciation of *PRINT-READABLY* as a default value for the PKG-P ;; parameter to WRITE-SYMBOL, in this system - in lieu of a definition ;; of any additional globally scoped variable or generalized manner of ;; "Application Flag" singularly for affecting that behavior of this ;; system, per se. (declaim (inline write-symbol write-space)) (defun* write-symbol (s stream &optional pkg-p) ;; NB: If S is a string, it's assumed that any character in S such ;; that may have a particular interpretation in a symbol name, if ;; unescaped, will have already been escaped by the calling procedure. ;; ;; NB: This function will not perform any name mangling, vis a vis ;; character case. ;; ;; NB: This function - in effect, by way of PRIN1 - assumes that any ;; symbol exported when this function is called will also be exported ;; when the symbol name, as was printed to STREAM, is evaluated. ;; (declare (type symbol s) (type stream stream) (values stream &optional)) (let ((*package* (if pkg-p (mk-lf (find-package '#:keyword)) *package*))) ;; FIXME/TBD: When no symbol package, write an #<N>=<SYMBOL> expr ;; and store the symbol for <N> within the current PRINT-ENVIRONMENT (prin1 s stream)) (values stream)) ;; (with-output-to-string (s) (write-symbol 'frob s)) ;; => "FROB" ;; (with-output-to-string (s) (write-symbol 'lambda s t)) ;; => "COMMON-LISP:LAMBDA" ;; (with-output-to-string (s) (write-symbol ':keyword s t)) ;; => ":KEYWORD" ;; (with-output-to-string (s) (write-symbol ':keyword s nil)) ;; => ":KEYWORD" (defun* write-space (stream) (declare (type stream stream) (values stream &optional)) (write-char #\Space stream) (values stream)) (defgeneric write-reference-expression (expr stream) ;; NB: With some exceptions - such as denoted below - these method ;; definitions should not require the printed source forms to be ;; evaluated with any specific source system dependencies, insofar as ;; for the generic Comon Lisp expressions supported herein. ;; TBD ;; - HASH-TABLE (??) ;; - [...] (:method ((expr t) (stream symbol)) (write-reference-expression expr (compute-output-stream stream)) (values stream)) (:method ((expr t) (stream stream)) (warn "~<WRITE-REFERENCE-EXPRESSION dispatching to use MAKE-LOAD-FORM~>~ ~< - Objects of type ~S not yet supported by WRITE-REFERENCE-EXPRESSION:~>~ ~< ~S~>" (class-of expr) expr) (write-reference-expression (make-load-form expr) stream) (values stream)) (:method ((expr symbol) (stream stream)) ;; FIXME: Use a *PRINT-SYMBOL-PACKAGE* clause ;; - e.g '(and (not #:CL) (not #:keyword)) [default] (write-symbol expr stream *print-readably*) (values stream)) (:method ((expr package) (stream stream)) ;; NB: Writing the package identity -- assumed constant -- not any ;; form defining the package (write-char #\# stream) (write-char #\. stream) (write-reference-expression `(find-package ,(package-name expr)) stream) (values stream)) (:method ((expr cons) (stream stream)) (write-char #\( stream) ;; FIXME/TBD cf. *PRINT-CIRCLE* (do-cons (subexpr rest expr (values)) (write-reference-expression subexpr stream) (when rest (write-space stream) ;; NB If REST is not a CONS, DO-CONS will not have bound it as SUBEXPR. ;; So, that's handled here - after which, DO-CONS will return. (unless (consp rest) (write-char #\. stream) (write-space stream) (write-reference-expression rest stream)))) (write-char #\) stream) (values stream)) (:method ((expr class) (stream stream)) ;; Assumption: STREAM will be read with a readtable in which the ;; dispatching reader macro expression "#." is bound to a form ;; analogous that specified in CLtL2/CLHS (write-char #\# stream) (write-char #\. stream) (write-reference-expression `(find-class (quote ,(class-name expr))) stream) (values stream)) (:method ((expr effective-slot-definition) (stream stream)) ;; Assumption: The source forms will be evaluated within the same ;; Common Lisp implementation as in which the source forms were ;; printed. Thus, *PRINT-READABLY* will be expressly bound to T ;; here, such as to ensure that the symbol package for each symbol ;; in the implementation's MOP implementation will be printed as per ;; the package of that symbol's availability in the calling Lisp ;; environment. (write-char #\# stream) (write-char #\. stream) (let ((*print-readably* t)) (write-reference-expression `(find (quote ,(slot-definition-name expr)) ;; FIXME : MOP may not ensure that a slot definition is in ;; effect doubly linked, to and from its defining class. (class-slots ,(slot-definition-class expr)) :test #'eq :key #'slot-definition-name) stream)) (values stream)) (:method ((expr function) (stream stream)) (multiple-value-bind (lambda-expr closure-p name) (function-lambda-expression (compute-function expr)) (declare (ignore closure-p)) ;; NB ;; NB: use PRIN1 for named functions, ;; Use WRITE-REFERENCE-EXPRESSION for anonymous lambda functions ;; for which the defining lambda forms are available, ;; and err for anonymous lambda functions with no "stored forms" (labels ((write-func-macro () (write-char #\# stream) (write-char #\' stream))) (cond ((and name (when (consp name) (not (eq (car name) 'lambda)))) (write-func-macro) (write-reference-expression name stream)) (lambda-expr (write-func-macro) (write-reference-expression lambda-expr stream)) (t (simple-program-error "~<Cannot write anonymous lambda function absent of ~ stored definition forms:~>~< ~S~>" expr))) (values stream)))) (:method ((expr character) (stream stream)) ;; NB Ass'umption: The output stream has been initialized with an ;; external format such that will serve to support a character ;; encoding sufficient to represent every character and string ;; provided to WRITE-REFERENCE-EXPRESSION (princ expr stream) (values stream)) (:method ((expr number) (stream stream)) (prin1 expr stream) (values stream)) (:method ((expr simple-array) (stream stream)) (prin1 expr stream) (values stream)) (:method ((expr array) (stream stream)) (multiple-value-bind (displ displ-off-t) (array-displacement expr) #-NIL (declare (ignore displ-off-t)) ;; NB Refer to FIXME/TBD annotation, below (when displ (simple-program-error "Displaced arrays not yet supported")) (let ((fp (when (array-has-fill-pointer-p expr) (fill-pointer expr))) (adj (adjustable-array-p expr)) (dim (array-dimensions expr)) (typ (array-element-type expr)) ;; NB: This generalized method may be fairly ;; resource-intensive when printing a "large array" (simple-contents (unless displ (coerce expr 'simple-array)))) ;; NB: This application of "#." reader macro syntax, in a ;; manner, may be said to to represent a specialized case of ;; *PRINT-READABLY* := T (write-char #\# stream) (write-char #\. stream) (write-reference-expression `(make-array (quote ,dim) ,@(when fp `(:fill-pointer ,fp)) ,@(when adj `(:adjustable ,adj)) :element-type (quote ,typ) ,@(cond (displ ;; FIXME/TBD: Portable object ;; references - specification and ;; dereferencing - in this ;; generalized PRINT-EXPR ;; application ;; ;; NB *PRINT-CIRCLE* and #<N> syntax #+NIL `(:displaced-to ,displ :displaced-index-offset ,displ-off-t)) (t `(:initial-contents ,simple-contents)))) stream))) (values stream)) ) #+NIL (eval-when () ;; FIXME: Do not use *PRINT-READABLY* in WRITE-SYMBOL ;; ;; Instead use a globally scoped variable, *PRINT-SYMBOL-PACKAGE* ;; ;; e.g syntax and default value: ;; (NOT (OR #:CL #:KEYWORD)) ;; ;; ... indicating -- in a manner of a logical expression of a syntax ;; generally analogous to a subset of DEFTYPE derived type ;; expressions --, a pattern for matching against each ;; symbol-package that should be printed by WRITE-SYMBOL ;; NB: Consider using a similar semantics with a printer flag named, ;; unambiguously, *PRINT-READER-MACRO-SHARPSIGN-DOT* but specialized ;; for expressions representing type designators rather than, per se ;; package designators ... in some manner specifically for handling of ;; the "#." printing in WRITE-REFERENCE-EXPRESSION ;; ;; e.g default value (OR PACKAGE CLASS EFFECTIVE-SLOT-DEFINITION) ;; -- Test function printing - via arbitrary defun source forms ;; test for global function objects w/o package name printing for symbols (let ((*print-readably* nil)) (with-output-to-string (s) (write-reference-expression `(defun frob () (funcall #.(function list) 1 2 3)) s))) ;; test for global function objects w/ package name printing for symbols (let ((*print-readably* t)) (with-output-to-string (s) (write-reference-expression `(defun frob () (funcall #.(function list) 1 2 3)) s))) ;; test for anonymous lambda objects (let ((*print-readably* nil)) (with-output-to-string (s) (write-reference-expression `(defun frob () (funcall #.(lambda* (&rest thunk) (apply #'list thunk)) 1 2 3)) s))) ) ;; ---- ;; FIXME - the name element, "Accessor," while it may be suitable in a ;; generalized regard, is too generic for denoting one of either a slot ;; value writer or slot value reader. (defgeneric compute-reader-name (slot class) (:method ((slot standard-effective-slot-definition) (class standard-class)) ;; Default method e.g for any class for which it would not be ;; assumed that any analogy to a DEFSTRUCT :CONC-NAME would be ;; available. (let ((sl-name (slot-definition-name slot)) (typ-name (class-name class))) (concatenate 'simple-string (symbol-name typ-name) "-" (symbol-name sl-name))))) (defgeneric compute-reader-function-type (slot class) (:method ((slot standard-effective-slot-definition) (class standard-class)) `(function (,(class-name class)) (values ,(slot-definition-type slot) &optional)))) (defgeneric compute-reader-lambda (slot class) #+SBCL (:method ((slot standard-effective-slot-definition) (class standard-class)) (let ((typname (class-name class))) (with-symbols (cls obj) `(lambda (,obj) (declare (type ,typname ,obj)) ;; FIXME: standard objects typically cannot be printed readably. ;; ;; NB: Symbols can be bound within the lexical environment ;; in which the corresponding DEFUN form will be evaluated ;; ;; FIXME/TD: Bind *CLASS* and for each slot, *SLOT* in the ;; lexical environment in which this lambda form's body will ;; be evaluated, in the source forms produced from ;; PRINT-READER-FOR (??) ;; *OR* use reader macros in the printed representation ;; e.g #.(find-class (quote <class-name>)) ;; #.(find-slot (quote <slot-name>) (quote <class-name>)) (let ((,cls ,class #+NIL (load-time-value (find-class (quote ,typname)) t))) (declare (dynamic-extent ,cls)) (cond ((eq (class-of ,obj) ,cls) (assert-slot-boundp ,the-readable-slot ,obj) (standard-instance-access ,obj ,FIXME-TBD)) (t (slot-value-using-class ,cls ,obj ,slot))))))))) (defgeneric compute-reader-documentation (slot class) (:method ((slot standard-effective-slot-definition) (class standard-class)) (format nil "Machine-Generated Reader for the ~A slot value of an ~A object" (slot-definition-name slot) (class-name class)))) (defgeneric print-reader-for (slot class stream) ;; NB - This protocol needs to dispatch for each slot value writer ;; and slot value reader, by default - without preventing that any ;; extending class may specify that a slot value writer would not be ;; written, or - per se - that any accessors would be "Skipped" for ;; any single slot in a single, defined class. ;; ;; NB: If an effective method - in effect - "Skips" a slot definition, ;; the effective method should return NIL. Otherwise, the effective ;; method should return a stream. (:method ((slot standard-effective-slot-definition) (class standard-class) (stream stream)) (let ((name (compute-reader-name slot class)) ;; TBD: Lambda-Printer protocol (lform (compute-reader-lambda slot class)) (docstr (compute-reader-documentation slot class))) ;; NB: This function does not, at present, perform any "Pretty ;; Printed" indenting for printed source forms ;; write ftype decl (write-reference-expression `(declaim (ftype ,(compute-reader-function-type slot class) name)) stream) ;; write defun expr (write-char #\( stream) (write-symbol (quote defun) stream t) (write-space stream) (write-symbol name stream t) (write-space stream) ;; (destructuring-bind (lsym args &body lform-body) lform (declare (ignore lsym)) (write-reference-expression args stream) (when docstr (print docstr stream)) (dolist (expr lform-body) (write-reference-expression expr stream) (terpri stream))) ;; (write-char #\) stream) ;; NB: The method should call something like TERPRI itself, ;; thus in something of an analogy to PRINT (terpri stream) ))) (defun* write-accessors (class stream) (declare (type class-designator class) (type stream-designator stream) (values stream &optional)) ;; TBD: Folding DEFUN calls into method forms, rather than expanding ;; to DEFUN source forms within a macroexpansion ;; Topic: Applying functional forms within a macroexpansion, using ;; MACROLET in the direct macroexpansion, such as to produce an ;; effective macroexpansion derived per values returned by those ;; functional forms. ;; ;; Alternate approach: "Indirect Eval," by way of source file ;; generation with functional procedures defined in Common Lisp source ;; code - towards a methodology for definition and appliation of ;; generalized source templates, in a manner after both CL:DEFMACRO ;; and CL:DEFCLASS. NB: This approach may serve to permit for review ;; of generalized "Template expansion" source files, without per se ;; MACROEXPAND-1 or MACROEXPAND -- whether or not it may clearly serve ;; to alleviate any concerns with regards to lexical bindings in the ;; compiler environment and lexical bindings in the macroexpansion ;; environment, as in applications of CL:DEFMACRO. This approach could ;; perhaps be anyhow influenced with considerations after definitions ;; in the SWIG system. (let ((%class (ensure-class-finalized-p class)) (%stream (compute-output-stream stream))) (declare (type class %class) (type stream %stream)) (terpri stream) ;; (write-char #\( stream) ;; (princ 'progn stream) ;; TBD: One of: ;; A) Write forms for lexical definition of *CLASS*. ;; B) Within each "Accessor printout", print a form such as ;; #.(find-class (quote <class-name>)) ;; .. to ensure generally static reference to the defining class, ;; within the generated accessor definitoins. (dolist (sl (class-slots %class)) (declare (type effective-slot-definition sl)) ;; FIXME - Similar to static class reference, ensure static slot ;; reference in each reader, writer form -- assuming that the ;; defining class will not be destructively redfined, subsequent ;; of these generalized "Print" calls. ;; NB: Each of these reader, writer printer forms should also ;; print an FTYPE declaration to the stream. (print-reader-for sl class stream) (print-writer-for sl class stream)) ;; (write-char #\) stream) ;; (terpri stream) (values %stream)))
34,361
Common Lisp
.lisp
742
39.854447
89
0.662267
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
7b7298d09418fef79941d85f76372b7c769dce2d5ca20e7eb587993cedf45466
29,259
[ -1 ]
29,260
defsys-ex.lisp
thinkum_ltp-main/src/main/lsp/common/defsys-ex.lisp
;; defsys-ex.lisp ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage #:info.metacommunity.cltl.defsys (:nicknames #:defsys) (:use #:asdf #:cl))) (in-package #:defsys) ;; NB: AIC-SYS; CBSE; FRAMEWORKS ;; A few thoughts towards an alternate DEFSYSTEM macro, DEFSYS ;; ;; * Dependency paths ;; ;; * "Opaque system" and "Component tree" views of an ASDF system ;; as with regards to system dependencies ;; ;; * Example for a "Component tree" view: Garnet Gadgets ;; * Garnet Gadgets may be as represented by their definitive ;; KR schema and by their definitions as defined in ;; correlated source files ;; ;; * The Garnet-Gadgets system defines an abstract container ;; for Garnet Gadgets source files ;; ;; * An application may depend, directly, on only a subset ;; of the full set of Garnet Gadgets ;; ;; * An embedded application "Should not" be required to ;; load the entire Garnet Gadget system, for utilizing ;; only a small number of Garnet Gadgets, directly ;; ;; * Defining a more CLOS-centric protocol for system definition ;; ;; * ASDF:DEFSYSTEM is a macro with a specific syntax ;; and specific behaviors, some of which may not be ;; expected by system developers ;; ;; * e.g. ASDF DEFSYSTEM [ASDF 3.1.3.8] effectively ;; overrides some extensions onto component pathname handling ;; ;; * Case in point: ;; SHARED-INITIALIZE :AROUND GARNET-SYSTEMS:CURSOR T ;; &REST INITARGS &KEY &ALLOW-OTHER-KEYS ;; ;; * {refer to source code} ;; ;; * Observation: One of an "only way" for the _CURSOR pathname ;; defaulting_ to be exactly implemented is by way ;; of "hacking" the INITARGS in SHARED-INITIALIZE ;; :AROUND, before CALL-NEXT-METHOD ;; ;; * Every procedure implemented in the macroexpansion of ;; ASDF:DEFSYSTEM may alternately be implemented within ;; a method specialized onto a generic function, in defining ;; an exacting object system protocol for system definition ;; ;; * IDE integration ;; ;; * Concept: IDE-supported interaction with functional testing ;; frameworks ;; ;; * Example: jUnit support in the Eclipse IDE ;; ;; * Concept: Extending onto the hypothetical CORBA for ;; Remote Common Lisp framework, with extensions for ;; defining test suites, etc, and their relations to ;; specific source code resources, in IDL and otherwise ;; ;; * Concept: IDE-driven controls for advancing a codebase from ;; "testing" to "release" ;; ;; * Sidebar: The Eclipse Mylyn framework and 'QA' ;; ;; * Prerequisite: A consistent concept of an IDE in Common Lisp ;; ;; * Related concept: The SWANK protocol ;; ;; * Possibly related concept: CORBA ;; ;; * A set of IDL interface definitions may be ;; defined around the SWANK protocol, as for ;; purpose of defining a CORBA interface ;; for program interaction with a Common Lisp ;; implementation via an Object Request Broker ;; (ORB) ;; ;; * Possibly related concept: The Dandelion plugin ;; for the Eclipse IDE ;; ;; * Dandelion may provide a helpful baseline for ;; an extension implementing the same Lisp ORB ;; Interaction model, in the Eclipse IDE ;; ;; * Whereas Dandelion is a plugin for the Eclipse ;; IDE, the Eclipse IDE itself would serve to ;; provide a reference framework, in addressing ;; questions such as: How to define an IDL ;; interface by which a Common Lisp editing ;; platform -- if not a formal, Common Lisp ;; application debugger (FOSS) for "production ;; applications" [!!] -- may be able to "Browse the ;; source location" of the definition of a ;; function, class, or other Common Lisp object ;; defined in an exacting source file? ;; ;; * Towards that effect: If the source file is ;; available on the same network as the ;; connecting debugger application, the source ;; file may be represented -- via the ;; respective IDL implementation -- with a URL ;; denoting the source file's location. ;; ;; * The Eclipse IDE offers a "remote servers" ;; framework, such that could be extended onto, ;; in facilitating the remote access for Common ;; Lisp application debugging. ;; ;; * "This project", then, may present an ;; opportunity towards extending Dandelion for ;; integrating the Eclipse IDE with Common Lisp ;; debuggers, in any Common Lisp implementation ;; that has a reference interface already defined ;; in SLIME/Swank. (Of course, it would also require ;; an implementation of the IDL interface ;; definitions within the respective Common Lisp ;; implementation - towards which effect, the ;; SLIME/SWANK source code would likewise serve as a ;; reference, then leaving a simple question of how ;; best to define an interface to an object request ;; broker, in Common Lisp?) ;; ;; * Additional concern: Authentication via CORBA ;; ;; * Additional concern: Integration with ;; Kerberos and SSH ;; ;; * Possible approach: FFI onto The ACE ORB ;; ;; * Another possible approach: FFI onto ;; JacORB -- possibly an ideal approach, ;; from the perspective of developing a ;; combined systems platform in Java and ;; Common Lisp, although FFI onto Java may ;; not be feasible by all approaches, in ;; all Common Lisp implementations ;; (referencing: concerns about interrupt ;; handling in SBCL, such that effectively ;; interferes CL+J in SBCL) ;; ;; * Another possible approach: Update and ;; extend CLORB ;; ;; * May be ideal, as with regards to ;; limiting Common Lisp applications' ;; dependencies onto an external JVM ;; ;; * May seem like an arduous task, ;; superficially, compared to an idea ;; of "implementing FFI" onto an ;; existing ORB implementation such that ;; supports both of "IIOP over SSH" and ;; Kerberos authentication, already, ;; namely JacORB. Of course, that may ;; also serve to require FFI interfaces ;; onto a Kerberos implementation and ;; OpenSSL. ;; ;; * In a sense of "Software reusability" ;; beyond specific programming language ;; platforms, the "Use FFI" idea may be ;; ideal. ;; ;; * Possibly related concept (in a far reach) : ;; Mobile/embedded computing, desktop virtualization ;; architectures, and CORBA ;; ;; * XLIB protocol as a reference framework, in ;; context with the X Window System ;; ;; * DXPC as an extensional X Window System protocol ;; ;; * NoMachine's NX architecture - a combination of ;; open source (e.g nxcodec) and proprietary ;; (e.g. commercial support) components ;; ;; * Citrix Receiver and Xen ;; ;; * Sidebar: Xen and Microkernel architectures ;; ;; * Possibly related concept (in a further reach) : ;; Realtime CORBA as a protocol for inter-application ;; communications within an embedded computing ;; platform ;; * May be developed to prototype, on an Android ;; platform and/or other ARM architectures ;; e.g. Samsung Chromebook w/ Crouton or CruBuntu ;;; * [Sidebar] RESOURCE-SYSTEM (defclass resource (component) ()) (defclass resource-file (resource static-file) ()) (defclass resource-module (resource module) () (:default-initargs :default-component-class 'resource)) (defclass resource-system (resource system) ()) (defmethod source-file-type ((component resource) system) (values nil)) ;;; * ... #| [Sidebar] Initial prototype for a URI format for dependency specifiers format: urn:x-dep:<app>:<app-specific-part> for <app> ::= maven Context: ABCL / CL+J / FOIL / ... The <app-specific-part> must constitute a for <app> ::= ivy Context: ABCL / CL+J / FOIL / ... (Specification TBD) (TO DO: Study Ivy documentation) for <app> ::= deb Context: Host OS packaging system (Debian) <app-specific-part> must be (TO DO) of a format to identify, at minimum, a Debian package -- optionally, with a dependency range specifier (c.f Debian packaging system 'control' files) and a distribution-specific architecture specifier (TO DO: reference the standard distribution specifiers for Debian and Ubuntu distros, here) e.g urn:x-dep:deb:sbcl:[1.1.14]:[1.2.3] denotes 'sbcl' package, host architecture, 1.1.4 <= version <= 1.2.3 urn:x-dep:deb:sbcl:1.1.14:1.2.3:ia32 denotes 'sbcl' package, 'ia32' architecture, 1.1.4 < version < 1.2.3 urn:x-dep:deb:sbcl:1.2.3::amd64 denotes 'sbcl' package, 'amd64' architecture, version = 1.2.3 TO DO: Make reference to {that effective standard for version specifier strings} and define behaviors for version string sort order, in "this protocol" for <app> ::= ASDF Context: Common Lisp systems (typically, Common Lisp software code) <app-specific-part> would denote .... ? Thoughts: 0. Generic instance: <app-specific-part> would denote a 'path' to an ASDF component, e.g. "urn:x-dep:asdf:clim-gtkairo:Backends/gtkairo;ffi" 1. Concern: Verbosity of dependency specifiers within a context of ASDF system definitions Inevitable sidebar: Integrating a Maven repository into ASDF or, extending ASDF::*SOURCE-REGISTRY* onto Apache Maven 1. Using ASDF to load a system definition directly from an HTTP server? * Concern: Checksums 2. Using ASDF to unbundle and load a system definition provided within a Maven archive (ZIP format) => ! * Would require a corresponding specification for a method for including ASDF system definitions within Maven archives (TBD) * Advantage: "This approach" would serve to extend of the Maven resource distribution architecture (alternately Apache Ivy), likewise extending of Maven's support for HTTP authentication, resource repository selection, resource bundle [JAR and POM] checksums, "and so on" |# (defgeneric dependency-object (dependency)) (defgeneric dependency-subject (dependency)) (defclass dependency () ;; an instance of this class effectively serves as a predicate in an ;; expression - for SYSTEM A, COMPONENT B, AND DEPENDENCY D ;; ;; {A D B} ;; ;; denoting: ;; COMPONENT (subject) 'A' ;; depends on OBJECT 'B' ;; by way of DEPENDENCY D ;; ((object ;; the object of the dependency - conventionally a component ;; designator, a "must exist" feature type designator, or a module ;; type feature designator :initarg :object :accessor dependency-object) (subject ;; i.e. the component that depends on the specified OBJECT :initarg :subject :accessor dependency-subject ))) (defclass versioned-dependency () ;; In some terms - as perhaps may be reminiscent of the Web Ontology ;; Language [OWL] - a VERSIONED-DEPENDENCY effectively ;; provides an annotation to a DEPENDENCY D ;; ;; {A D B} ;; ;; ...in specifying one or both of "minimum version" and a "maximum ;; version" required for the component B in dependency D, such that ;; the version specifiers would be interpreted in a context relevant ;; for the effective type of the object B ;; ;; For purpose of convenience in this application, a semantics ;; extending of ASDF is applied instead of a semantics extending of ;; the Resource Description Framework [RDF] for dependency version ;; annotation ()) ;;;; Dependency classes for dependency specifiers normative in ASDF, ;;; referencing the ASDF manual (defclass component-dependency (dependency) ((object :type string))) (defclass versioned-component-dependency (versioned-dependency component-dependency) ()) (defclass feature-dependency (dependency) ((object :type symbol :accessor dependency-feature))) (defclass module-dependency (feature-dependency) ;; for ASDF :REQUIRE dependency specifiers ()) ;;;; Additional dependency types (TBD) (defclass file (dependency) ()) (defclass executable-file (file) ;; for specifying dependencies onto shell commands ()) (defclass host-package (dependency) ;; for specifying dependencies onto a host packaging system ;; e.g. ;; Debian packaging ;; e.g. dpkg-query -f '${db:status-abbrev}${binary:package} ${version}\n' -W pngcrush ;; ....expecting only one package entry listed ; ;; Cygwin (e.g. "cygcheck -c pngcrush") ;; ()) (defclass debian-package (host-package) ()) (defclass yum-package (host) ()) (defclass cygwin-package (host-package) ()) ;; To Do: HOST-PACKAGE subclass for Gentoo? (defgeneric ensure-dependency (name body) (:method ((name (eql :path)) (body cons)) ;; evaluate BODY as a path to a component's subcomponent ) (:method ((name string) (body null)) ;; evaluate NAME as a system name ) #+TO-DO (:method ((name iri) (body null)) ;; load a "remote" system definition denoted at the URI <IRI> ;; ;; Prerequisites: ;; 1. IRI handling protocol for application ;; suggestion: Similar to the KDE KIO framework, ;; dispatch on IRI scheme ;; concern: Semantics and application of a resource proxy ;; framework for the underlying Lisp implementation ;; 2. Implementation of IRI handling protocol ;; for all supported IRI ;; ;; FIXME after nr. 2: Rename IRI specializer to e.g. HTTP-URI ) (:method ((name (eql :os-package)) body) ;; initialize as an instance of a subclass of HOST-PACKAGE ;; specific to the host OS ;; ;; TO DO: Protocol for determining the identity of the host OS ;; FIRST: `uname -o' if available ;; if "GNU/Linux" case: then also (e.g) 'lsb_release -a' ;; if 'Cygwin' case: ??? ;; ;; NOTE: A dependency onto a Debian package may be denoted ;; with a architecture specifier , explicitly: ;; e.g amd64 or ia32 ;; or else the architecture defaults to that of ... a ;; distribution-specific architecture designator extending of ;; `uname -m' (unofficial) .e.g ;; x86_64 [kernel machine type] =i.e.=> amd64 [host OS architecture] ) ;; next are for compat with ASDF:DEFSYSTEM ;; cf. ASDF/PARSE-DEFSYSTEM::PARSE-DEPENDENCY-DEF ;; (:method ((name (eql :feature) body)) ;; Nb. Semantically similar to a :REQUIRE dependency ;; Intialize as FEATURE-DEPENCENCY ) (:method ((name (eql :require) body)) ;; initialize as MODULE-DEPENDENCY ) (:method ((name (eql :version)) body) ; Nb. initialize as VERSIONED-COMPONENT-DEPENDENCY )) (defun parse-dependency-speciifer (spec) (etypecase spec (cons (destructuring-bind (name &rest args) spec (ensure-dependency name arts))) (t (ensure-dependency (coerce-name spec) nil)))) #+NIL (defsys #:a :components ((utils:resource "a.1"))) #+NIL (defsys #:b :depends-on ((:path "a" "a.1"))) #+NIL (defsystem #:c :pathname #.*default-pathname-defaults* :components ((resource "c.1") (resource "c.2" :depends-on ("c.1")))) ;; (describe (find-component* "c.2" "c")) ;; ^ note the asdf::sideway-dependencies slot ;; see also: ;; ASDF:COMPONENT-SIDEWAY-DEPENDENCIES ;; ASDF:SIDEWAY-OPERATION ;; ASDF:PREPARE-OP ;; Local Variables: ;; ispell-buffer-session-localwords: ("ABCL" "CLORB" "CLOS" "CORBA" "Checksums" "Citrix" "CruBuntu" "Cygwin" "DEFSYSTEM" "DEPENCENCY" "DXPC" "FFI" "FIXME" "FOSS" "IDL" "IIOP" "INITARGS" "Intialize" "JVM" "JacORB" "KDE" "KIO" "Kerberos" "Microkernel" "Mylyn" "NX" "NoMachine's" "OpenSSL" "RDF" "Realtime" "SBCL" "SIDEWAY" "TBD" "URI" "XLIB" "Xen" "accessor" "amd" "args" "asdf" "centric" "checksums" "codebase" "compat" "cygcheck" "cygwin" "debian" "defclass" "defgeneric" "defmethod" "defpackage" "defsys" "defsystem" "defun" "dep" "designator" "destructuring" "distros" "dpkg" "eql" "etypecase" "eval" "ffi" "ia" "initarg" "initargs" "iri" "jUnit" "lsb" "macroexpansion" "nr" "nxcodec" "os" "pathname" "pngcrush" "reusability" "sbcl" "specializer" "speciifer" "subcomponent" "toplevel" "uname" "unbundle" "utils") ;; End:
19,224
Common Lisp
.lisp
432
40.923611
814
0.597125
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
70f9c9484cacac2fa026d955ee7bf871cbbf24ec630553825819b24d431696fc
29,260
[ -1 ]
29,261
common-type-sbcl.lisp
thinkum_ltp-main/src/main/lsp/common/common-type-sbcl.lisp
;; common-type-sbcl.lisp - Implementation-specific type system reflection, SBCL ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Local API and Implementation ;; ;;------------------------------------------------------------------------------ ;; FIXME - test in CMUCL (in-package #:ltp/common) #+SBCL (declaim (inline symbol-type) (sb-ext:maybe-inline find-lvar)) ;; NB/QA SBCL 1.5.2.8-5128df17d amd64 FreeBSD local build w/ safepoint etc ;; entering SBCL LDB e.g during SWANK::LOAD-FILE or LOAD w/o SLIME ;; when FIND-LVAR is declared expressly INLINE, here ;; ;; ... after emitting a warning that FIND-LVAR could not be inlined ;; ;; workaround: declare the function MAYBE-INLINE #+SBCL (defun find-lvar (name env) ;; NB: Roughly analogous to (sb-int:info :variable :type name) ;; but applied for access to binding information in the lexical ;; environmnent ENV (declare (type symbol name) (type sb-kernel:lexenv env) (values &optional sb-c::lambda-var)) (let ((spec (assoc name (sb-c::lexenv-vars env) :test #'eq))) (cond ((consp spec) (cdr (the cons spec))) ((sb-c::null-lexenv-p env) (values)) (t (find-lvar name (sb-c::lexenv-parent env)))))) ;; (defmacro frob-env (&environment env) `(values ,env)) ;; (find-lvar '*standard-output* (frob-env)) ;; => no values ;; ^ see SYMBOL-TYPE ;; (let ((a 5)) (find-lvar 'a (frob-env))) ;; (let ((a 5)) (let ((b 2)) (find-lvar 'a (frob-env)))) (define-condition no-binding (cell-error) () (:report (lambda (c s) ;; Assumption: If this error occurs, the debugger should be able to ;; provide information about the lexical environment in which the ;; error occurred. ;; ;; TBD: Portable representation for implementation-specific lexical ;; environment definitions, in LTP/Common (format s "~<No binding available for ~s~>" (cell-error-name c))))) ;; (error 'no-binding :name (make-symbol "_FrobP")) #+SBCL (defun symbol-type (s env) ;; NB: Broadly analogous to SYMBOL-VALUE, but providing access to some ;; information with regards to runtime type system reflection ;; ;; See also: SPECIFIER-TYPE in CMUCL, SBCL (declare (type symbol s) (type sb-kernel:lexenv env) (values type-designator &optional) (inline find-lvar)) ;; First search ENV for a binding onto S (let ((lvar (find-lvar s env))) (cond (lvar (sb-kernel:type-specifier (sb-c::lambda-var-type lvar))) ((boundp s) ;; NB: SB-INT:INFO may not be checking whether the symbol ;; is bound globally. The function appears to return T for any ;; unbound symbol provided to it. ;; ;; So, this function works around that by calling SYMBOL-BOUNDP ;; ;; Susbq, return information for S, from the global environment. ;; ;; Assumption The global binding state of the symbol has been ;; verified, previous to the following. ;; (sb-kernel:type-specifier (sb-int:info :variable :type s))) (t (error 'no-binding :name s))))) ;; (symbol-type '*standard-output* SB-CLTL2::*NULL-LEXENV*) ;; => STREAM ;; (symbol-type '*standard-output* (SB-KERNEL:MAKE-NULL-LEXENV)) ;; => STREAM ;; Expect Failure: ;; (symbol-type (make-symbol "frob") (SB-KERNEL:MAKE-NULL-LEXENV)) ;; NB using the following macro ;; (let ((s (make-symbol "frob"))) (setf (symbol-value s) nil) (symbol-type* s)) ;; => T ;; (symbol-type '*standard-output* (frob-env)) ;; => STREAM ;; (let ((a 1)) (declare (type (mod 2) a)) (symbol-type 'a (frob-env))) ;; => BIT ;; NB type was reduced by the compiler ;; (let ((a 1)) (declare (type (mod 10) a)) (symbol-type 'a (frob-env))) ;; => (MOD 10) ;; (let ((a 1)) (symbol-type 'a (frob-env))) ;; => T #+SBCL (defmacro symbol-type* (s &environment env) ;; NB: This has been defined as a macro, ;; in order to access the lexical environment ENV implicitly `(symbol-type ,s ,env)) ;; (symbol-type* '*standard-output*) ;; => STREAM ;; (let ((a 1)) (declare (type (mod 2) a)) (symbol-type* 'a)) ;; => BIT ;; NB type was reduced by the compiler ;; (let ((a 1)) (declare (type (mod 10) a)) (symbol-type* 'a)) ;; => (MOD 10) ;; (let ((a 1)) (symbol-type* 'a)) ;; => T ;; -- sketch-wk -------------------- (eval-when () ;; NB: Global symbols ;; See also: LOCALLY ... #+SBCL (sb-int:info :variable :type '*standard-output*) #+SBCL (sb-int:info :variable :type (make-symbol "frob")) #+SBCL (sb-int:info :variable :where-from '*standard-output*) ;; (sb-kernel::classoid-class-info (sb-int:info :variable :type '*standard-output*)) ;; (sb-kernel::type-class-info (sb-int:info :variable :type '*standard-output*)) ;; (SB-KERNEL:BUILT-IN-CLASSOID-TRANSLATION (sb-int:info :variable :type '*standard-output*)) ;; (sb-kernel:ctype-of ....) ;; operates on objects ) ;; EVAL-WHEN (eval-when () (defmacro frob-env (&environment env) `(values ,env)) ;; (frob-env) ;; (describe (class-of (frob-env))) ;; (type-of (frob-env)) ;; => SB-KERNEL:LEXENV ;; NB: SB-C:*LEXENV* ;; (sb-c::lexenv-type-restrictions ??) (let ((a 1)) (declare (type (mod 10) a)) (frob-env)) ;; NB: LEXENV-VARS (let ((a 1)) (declare (type (mod 10) a)) ;; NB: (SB-C::LEXENV-PARENT INST) (cdar (sb-c::lexenv-vars (frob-env)))) (let ((a 1)) (declare (type (mod 10) a)) ;; NB: (SB-C::LEXENV-PARENT INST) (sb-c::lambda-var-type (cdar (sb-c::lexenv-vars (frob-env))))) (let ((a 1)) (declare (type (mod 10) a)) ;; NB: (SB-C::LEXENV-PARENT INST) ;; (sb-c:primitive-type (sb-c::lambda-var-type (cdar (sb-c::lexenv-vars (frob-env)))))) (let ((a 1)) (declare (type (mod 10) a)) (sb-kernel:type-specifier (sb-c::lambda-var-type (cdar (sb-c::lexenv-vars (frob-env)))))) ) ;; EVAL-WHENx
6,256
Common Lisp
.lisp
163
34.478528
93
0.623443
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
f90c69ea330ae8ff70673450bf422860b44be638d5be4db46b55a33d5e394e7f
29,261
[ -1 ]
29,262
common-opt.lisp
thinkum_ltp-main/src/main/lsp/common/common-opt.lisp
;; common-opt.lisp - onto compiler optimizations ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (defmacro with-optimization ((&rest policy) &body body) ;; NB: POLICY will not be evaluated. See also: PROCLAIM ;; ;; Usage: WITH-TAIL-RECURSION defn `(locally (declare (optimize ,@policy)) ,@body)) ;; studies in implementation-specific optimizations ;; see also: ;; http://0branch.com/notes/tco-cl.html ;; http://trac.clozure.com/ccl/wiki/DeclareOptimize ;; http://ecls.sourceforge.net/new-manual/ch02.html#ansi.declarations.optimize (defmacro with-tail-recursion (&body body) ;; used in SPLIT-STRING definition `(with-optimization (#-allegro (debug 2) #+allegro (debug 1) (speed 3) (safety 2)) ,@body)) #+NIL (macrolet ((with-opt-env ((env &rest opt) &body body &environment environment) `(let ((,env ,environment)) (declare (optimize ,@opt)) ,@body)) (test-tail (&rest opt) `(with-opt-env (env ,@opt) #+CCL (ccl::policy.allow-tail-recursion-elimination env) ;; FIXME implement test form here ))) (values (test-tail (debug 2) (speed 3) (safety 2) (space 2)) (test-tail (debug 3) (speed 0) (safety 3) (space 0)))) ;; #+CCL => #<CCL::LEXICAL-ENVIRONMENT ...> , ...
1,776
Common Lisp
.lisp
44
37.022727
80
0.621951
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
29aae56266365da527362cff5e6dc4ca9d7444e7120e9315be62de3f8cf6ad94
29,262
[ -1 ]
29,263
common-misc.lisp
thinkum_ltp-main/src/main/lsp/common/common-misc.lisp
;; common-misc.lisp - lisp compiler integration (misc) ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (declaim (ftype (function ((or symbol cons)) (values boolean (or symbol cons) (or symbol cons) &optional)) featurep)) (defun featurep (expr) ;; ;; NB: This function does not provide support for *FEATURES* elements ;; interned in any CL:PACKAGE not equivalent to either *PACKAGE* or ;; the :KEYWORD package ;; ;; -- ;; ;; first return value: ;; a boolean indicating whether the EXPR is interpreted as ;; representing a true feature expression ;; ;; second return value: ;; an inner-most element within EXPR that did not evaluate as a true ;; feature expresion ;; ;; third return value ;; an inner-most element within EXPR that evaluated as a true feature ;; expression ;; ;; ;; NB: Return values of this function should not be destructively ;; modified, as they may represent constant data. ;; ;; -- ;; ;; The second and third return values are provided in an interest of ;; systems debugging, for nested feature expressions ;; (let (%mangled-name%) (declare (type symbol %mangled-name%)) (labels ((mangle-name-kwd (name) (setq %mangled-name% (intern (symbol-name name) (load-time-value (find-package :keyword) t)))) (feature-declared-p (name) ;; FIXME: Implementation of a name mangling function ;; providing behaviors similar to CLtL2 reader macros #\#\+ ;; and #\#\- ;; - would have to be implemented onto I/O streams ;; - may serve to support *FEATURES* expressions not ;; interned in the #:KEYWORD package ;; - is not provided here (cond ((find name *features* :test #'eq) ;; NB: The first check for any symbol expr is ;; performed, in this function, using that symbol's ;; initial SYMBOL-PACKAGE (values t nil name)) ((find (mangle-name-kwd name) *features* :test #'eq) ;; Subsequently, check for a symbol with equivalent ;; SYMBOL-NAME, in the :KEYWORD package. ;; ;; This labels function returns the keyword symbol, if found. ;; ;; NB: That symbol might be - in effect - lost for ;; some purposes of top-level return value capture, in ;; the methodology of return-value capture for feature ;; expressions, as developed internally in this function. ;; Regardless, it should be visible to some (TRACE FEATUREP) ;; (values t nil %mangled-name%)) (t (values nil name nil)))) (and-declared-p (exprs) (dolist (expr (cdr exprs) (values t nil exprs)) (multiple-value-bind (decl-p fail pass) (featurep expr) (declare (ignore pass)) (unless decl-p (return (values nil fail nil)))))) (or-declared-p (exprs) (dolist (expr (cdr exprs) (values nil exprs nil)) (multiple-value-bind (decl-p fail pass) (featurep expr) (declare (ignore fail)) (when decl-p (return (values t nil pass))))))) (etypecase expr (symbol (feature-declared-p expr)) (cons (let ((frst (car expr))) (ecase frst (and (and-declared-p expr)) (or (or-declared-p expr)) (not (multiple-value-bind (decl-p fail pass) (feature-declared-p (cadr expr)) (declare (ignore fail pass)) (cond (decl-p (values nil expr nil)) (t (values t nil expr)))))))))))) ;; FIXME: Note the topic, Global Locking During *FEATURES* Eval, ;; in project doc/markdown/ src. FEAUTREP should not be assumed ;; to be safe for application during concurrent evaluation of arbitrary ;; source forms such that may modify the value of *FEATURES* ;; (featurep 'sbcl) ;; =[SBCL]=> T, NIL, :SBCL ;; NB - by side effect ;; (featurep '#:sbcl) ;; =[SBCL]=> T, NIL, :SBCL ;; (featurep '(not sb-thread)) ;; (featurep '(and sbcl sb-thread)) ;; (featurep '(and openmcl cmucl)) ;; (featurep '(and :sbcl :sb-thread)) ;; (featurep '(and :sbcl (not :sb-thread))) ;; (featurep '(and :ansi-cl (or :unsupp-1 :unsupp-2))) ;; (featurep '(and :ansi-cl (and (not :unix) :unsupp-2))) ;; (featurep '(and :ansi-cl (or (not :unix) :unsupp-2))) ;; (featurep '(and :ansi-cl (or :unsupp-2 :unix))) ;; (featurep '(and :ansi-cl (and :unsupp-2 :unix))) ;; -- (defmacro mk-lf (form) "Evaluate FORM within a constantp LOAD-TIME-VALUE expression" `(load-time-value ,form t))
5,674
Common Lisp
.lisp
131
33.251908
80
0.549076
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
676c078c43a85784ea20249df8e801e8a1909ba30ff5c28fa6cb032d7fda41a3
29,263
[ -1 ]
29,264
common-condition.lisp
thinkum_ltp-main/src/main/lsp/common/common-condition.lisp
;; codition-utils.lisp ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) ;; NOTE analogous definitions in CMUCL, SBCL ;; NOTE portability (is not privatization) (define-condition simple-style-warning (style-warning simple-warning) ()) (defmacro simple-style-warning (fmt-ctrl &rest args) `(warn 'simple-style-warning :format-control ,fmt-ctrl :format-arguments (list ,@args))) (define-condition simple-program-error (program-error simple-error) ()) (defmacro simple-program-error (fmt-ctrl &rest args) `(error 'simple-program-error :format-control ,fmt-ctrl :format-arguments (list ,@args))) (defgeneric format-condition (condition stream) #+NIL (:documentation "CLOS Utility for application within condition class REPORT forms Example: (define-condition weather-condition () ((weather :initarg :weather :accessor weather-condition-weather)) (:report format-condition)) (defmethod format-condition ((c weather-condition) (s stream)) (format s \"The weather is ~S\" (weather-condition-weather c)) (when (next-method-p) (terpri s) (call-next-method)))") (:method ((condition condition) (stream t)) (simple-style-warning "~<Default FORMAT-CONDITION (T T) reached for (~S ~S)" condition stream) ;; cf. the CLHS as concerning definitions and semnatics of ;; DEFINE-CONDITION :REPORT forms in CLtL2 (print-object condition stream)) (:method ((condition condition) (stream symbol)) ;; FIXME_DESIGN symbol as stream designator => constant #+NIL "Dispatch for FORMAT-CONDITION onto a symbolic output stream designator. This method allows for symbolic indication of an output stream to FORMAT-CONDITION, with a syntax compatible onto ANSI CL (CLtL2)" ;; FIXME_DOCS See also: CL:PRINT; LTP `string-designator' type; LTP ;; `compute-output-stream' (format-condition condition (ecase stream ((t) *terminal-io*) ((nil) *standard-output*)))) (:method ((condition simple-condition) (stream stream)) #+NIL "Apply the format control and format arguments for the CONDITION, with output to the specified STREAM. If a next method is defined in the effective method sequence after this method, then that next method will be evaluated before the format-control and format-arguments for the CONDITION are applied for output to the stream. WA TERPRI call will be evaluted after the next method has returned, and before the direct format procedure in this method" (apply #'format (the stream stream) (simple-condition-format-control condition) (simple-condition-format-arguments condition))) (:method :after ((condition condition) (stream stream)) #+NIL "Ensure FINISH-OUTPUT is called onto STREAM" (finish-output stream))) #+NIL ;; Test for format-condition TBD (error 'simple-condition :format-control "Random event ~S at ~S" :format-arguments (list (gensym "e-") (get-universal-time))) ;; - FIXME: Move the following into supplemental system definitions (define-condition entity-condition () ;; FIXME_DOCS note that this is not `cell-error' ((name :initarg :name :reader entity-condition-name))) (define-condition entity-not-found (error entity-condition) () (:report format-condition)) (defmethod format-condition ((c entity-not-found) (s stream)) (format s "Not found: ~S" (entity-condition-name c))) ;; - (define-condition redefinition-condition (style-warning) ((previous-object :initarg :previous :accessor redefinition-condition-previous-object) (new-object :initarg :new :accessor redefinition-condition-new-object)) (:report format-condition)) (defmethod format-condition ((c redefinition-condition) (s stream)) (format s "Redefinition ~<~S~> => ~<~S~>" (redefinition-condition-previous-object c) (redefinition-condition-new-object c))) (define-condition container-condition () ;; FIXME_DOCS "Examples" ((container :initarg :container :reader container-condition-container)))
4,665
Common Lisp
.lisp
112
37
80
0.690539
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
a472ce3b372f5fa70d024f622d20c40dd72b6d75b66e17cf28479776a7f61326
29,264
[ -1 ]
29,265
common-print.lisp
thinkum_ltp-main/src/main/lsp/common/common-print.lisp
;; print-utils.lisp - utilities for object printing ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ ;; FIXME_DOCS - document the generic functions and methods defined ;; here. Refer to subsequent commentary, this file ;; Remarks - API Design - Synopsis ;; ;; - 'Object Name' as a short-form Object Identity string (was: Object Label) ;; ;; - principally designed for use with "The normal REPL printer" as ;; in regards to the "Name" part of object identity printouts for ;; unreadable objects. ;; ;; - may also be reused within MAKE-LOAD-FORM forms, but note that ;; these would need a management API to ensure a sense of ;; managability to the same, principally for the Common Lisp ;; systems developer (in FOSS environments) ;; ;; - note a generic analogy onto CL:RESTART names, vis a vis ;; RESTART :REPORT functions ;; ;; - 'Object Label' as a long-form Object Identity string (was: Object Name) ;; ;; - principally designed for use in "Pretty Printing" forms, in ;; console (LPC, LSRV) and desktop (LPC) environments. May be of some ;; limited use for system logging streams, in system service ;; applications (LSRV). TBD: Applicability for mobile Lisp ;; applications (LMBL) ;; ;; - Remarks - "Pretty Printer" as a novel concept in interactive systems ;; ;; - shoutouts to the original Multics developers & multicians.org ;; ;; - principally towards utilizing the 'Object Label' of an object as ;; "When Pretty Printing". ;; ;; - note the ANSI CL/CLtL2 API for Pretty Printing, namely ;; concerning global variables designed for "The Pretty Printer" ;; ;; - furthermore towards "Pretty Printing" in graphical desktop environments. ;; ;; - see also: Garnet KR ;; (in-package #:ltp/common) ;; ;; Note the class PRETTY-PRINTABLE-OBJECT ;; (defgeneric (setf object-print-name) (new-value object)) (defgeneric (setf object-print-label) (new-value object)) ;; FIXME DOCS [ACCESSOR] w/ #'OBJECT-PRINT-NAME, #'OBJECT-PRINT-LABEL #| Remarks - API Documentation The functions PRINT-NAME and PRINT-LABEL, and the functions OBJECT-PRINT-NAME and OBJECT-PRINT-LABEL, may be applied interchangably -- respectively, for printing an object's name or label to a stream, or for returning an object's name or label as a simple string value. For an object of a type that is a subclass of PRETTY-PRINTABLE-OBJECT, the functions OBJECT-PRINT-NAME and OBJECT-PRINT-LABEL, respectively, may dispatch to slot-value accessor methods specialized onto PRETTY-PRINTABLE-OBJECT, unless the respective methods are overridden for any extending class. Typically: - An object's print-name (was: print-label) would represent a succinct identity of the object. - An object's print-label (was: print-name) would represent a less succinct identity of the object It may be assumed that an object's print-name is readable in the Lisp environment. However, an object's print-name may not in itself be meaningful without an establishing sense of lexical context. It may be assumed that an object's print-label may not be readable in the Lisp environment. However, an object's print-label may serve to illustrate values indicating of the object's containing lexical context. ---- NB: ENUM wk - LTP ---- Examples (FIXME: Needs update, after name/label ambiguity in the API design) OBJECT-PRINT-NAME PACKAGE returns the name of the package OBJECT-PRINT-LABEL PACKAGE returns the shortest string among the name and nicknames of the package PRINT-NAME SYMBOL STREAM, for a symbol interned in a package, in will apply the value returned by OBJECT-PRINT-NAME, in printing the name of the package of the symbol. PRINT-NAME SYMBOL STREAM, for a symbol interned in a package, in will instead apply the value returned by OBJECT-PRINT-LABEL, in printing the name of the package of the symbol. The PRINT-NAME and PRINT-LABEL methods may be more readily useful, for instances in which an object's name represents the structural quaities of an object, such that may be indivdiually printed to an output stream string for constructing the structured name or label of the object. OBJECT-PRINT-NAME and OBJECT-PRINT-LABEL, altrenatey, may be most useful for objects of which a single string represents each of the object's name and label qualities -- for instance, for the measurement unit, MATH::METER, the print name of the object is the simple string, "meter", whereas the print lable of the object is the simple string, "m" An example of the application of this protocol is developed in the Igenous-Math system -- noting, in furthermore, the methods PRINT-LABEL (MATH:MEASUREMENT) PRINT-LABEL (MATH:KILOGRAM) FIXME: For a brief time, a similar protocol was being designed onto the Dobelle-App source tree, namely in the class LABELED-OBJECT Pending further updates to that source tree, that protoocl should be revised to align with the present pretty printing protocol, in conventional stream-io proedures, in CLIM presentation methods, and in other CLIM stream output procedures. ---- FORMAT-LABEL .... |# (defgeneric print-name (object stream) (:method (object (stream symbol)) (print-name object (ecase stream ((t) *terminal-io*) ((nil) *standard-output*)))) (:method (object (stream stream)) (prin1 object stream)) (:method ((object package) (stream stream)) ;; prefer package name (print-name (object-print-name object) stream)) (:method ((object class) (stream stream)) (print-name (class-name object) stream)) (:method ((object function) (stream stream)) (print-name (function-name object) stream)) (:method ((object symbol) (stream stream)) ;; Ed. NB: Note the specific handling, here. Reusable, moreover, ;; for printing any Common Lisp symbol onto any STREAM (multiple-value-bind (status pkg) (symbol-status object) (let ((keyword-p (and pkg (eq pkg (find-package '#:keyword))))) (cond (keyword-p (write-char #\: stream)) ;; NB : may fall through to PRINT-NAME for PKG (pkg (princ (object-print-name pkg) stream)) (t (write-char #\# stream) (write-char #\: stream))) (case status (:external (unless keyword-p (write-char #\: stream))) ((:internal :inherited) (write-char #\: stream) (write-char #\: stream))) (write-string (symbol-name object) stream)))) ) ;; (with-output-to-string (*terminal-io*) (print-name (find-class 'string) t)) ;; => "COMMON-LISP:STRING" (defgeneric print-label (object stream) (:method (object (stream symbol)) (print-label object (ecase stream ((t) *terminal-io*) ((nil) *standard-output*)))) (:method (object (stream stream)) (princ object stream)) (:method ((object package) (stream stream)) ;; prefer package short name - cf the corresponding method ;; onto OBJECT-PRINT-LABEL (print-label (object-print-label object) stream)) (:method ((object class) (stream stream)) (print-label (class-name object) stream)) (:method ((object function) (stream stream)) (print-label (function-name object) stream)) (:method ((object symbol) (stream stream)) ;; FIXME - this duplicates PRINT-NAME (SYMBOL STREAM) ;; in lieu of making any nested call to PRINT-NAME. The main ;; difference is in the call to OBJECT-PRINT-LABEL for the symbol ;; package of an interned symbol - in lieu of OBJECT-PRINT-NAME in ;; the PRINT-NAME form of this method definition ;; ;; It may represents something of a PRINT-CANONC-SYMBOL macro, broadly. (multiple-value-bind (status pkg) (symbol-status object) (let ((keyword-p (and pkg (eq pkg (find-package '#:keyword))))) (cond (keyword-p ;; [NB] (write-char #\: stream)) ;; NB : may fall through to PRINT-LABEL for PKG (pkg (princ (object-print-label pkg) stream)) (t (write-char #\# stream) (write-char #\: stream))) (case status (:external (unless keyword-p ;; [NB] (write-char #\: stream))) ((:internal :inherited) (write-char #\: stream) (write-char #\: stream))) (write-string (symbol-name object) stream))))) ;; (with-output-to-string (*terminal-io*) (print-label (find-class 'string) t)) ;; => "CL:STRING" (defgeneric object-print-name (object) ;; FIXME: rename to OBJECT-PRINT-NAME ;; FIXME DOCS [ACCESSOR] ;; FIXME: #I18N ;; FIXME: Generic function FTYPE declarations ;; => ftype (function (t) simple-string) (:documentation "Return a unique, human-readable name for OBJECT See also: `object-print-label'") ;; FIXME: This updates some qualities of the dobelle-app source tree (:method (object) (with-output-to-string (s) (print-name object s))) (:method ((object string)) (values object)) (:method ((object package)) ;; NB: Simple package name form (package-name object)) (:method ((object symbol)) (with-output-to-string (s) (print-name object s))) (:method ((object class)) (object-print-name (class-name object)))) ;; (object-print-name (find-package '#:utils)) ;; => "INFO.METACOMMUNITY.CLTL.UTILS" ;; (object-print-name '#:foo) ;; => "#:FOO" ;; (object-print-name 'print) ;; => "COMMON-LISP:PRINT" ;; (object-print-name ':test) ;; = ":TEST" (defgeneric object-print-label (object) ;; FIXME: rename to OBJECT-PRINT-LABEL ;; FIXME DOCS [ACCESSOR] ;; FIXME: This updates some qualities of the dobelle-app source tree ;; FIXME: Generic function FTYPE declarations ;; => ftype (function (t) simple-string) (:documentation "Return a succinct, unique, human-readable label for OBJECT See also: `object-print-name'") (:method (object) (princ-to-string object)) (:method ((object string)) (values object)) (:method ((object package)) ;; NB return the shortest string from the set of the package name ;; and any pacakge nicknames. ;; ;; In an estimate that that would typically comprise a short set, ;; this methodology produces some "Consing," for using a simple ;; "Sort a List" form, rather than developing any more per se ;; tedious iteration for computing the shortest string. (let ((name (package-name object)) (nicknames (package-nicknames object))) (car (sort (cons name (copy-list nicknames)) #'(lambda (a b) (declare (type simple-string a b)) (< (length a) (length b))))))) (:method ((object symbol)) (with-output-to-string (s) (print-label object s))) (:method ((object class)) (object-print-label (class-name object)))) ;; (object-print-label (find-package '#:utils)) ;; => "UTILS" ;; (object-print-label '#:foo) ;; => "#:FOO" ;; (object-print-label 'print) ;; => "CL:PRINT" ;; (object-print-label ':test) ;; => ":TEST" ;; (object-print-label (find-class 'stream)) ;; => "CL:STREAM" (defclass pretty-printable-object () ;; The 'label' and 'name' arguments might seem redundant. ;; This class was defined, originally, as a mixin for ;; application in the igneous-math system ((print-label :initarg :print-label :type simple-string :accessor object-print-label) (print-name :initarg :print-name :type simple-string :accessor object-print-name)) (:documentation "Protocol class for OBJECT-PRINT-LABEL, OBJECT-PRINT-NAME accessors See also: * `format-label' * `print-label' * `print-name'")) (defmethod print-name ((object pretty-printable-object) (stream stream)) (prin1 (object-print-label object) stream)) (defmethod print-label ((object pretty-printable-object) (stream stream)) (princ (object-print-label object) stream)) (defgeneric format-label (stream arg colon-p at-p) ;;; FIXME: Handle pprint-dipstach, etc (:documentation "Function for pretty-printing objects in format control strings Example: (format nil \"Class ~/utils:format-label/\" (find-class 'string)) => \"Class CL:STRING\" ") (:method (stream arg colon-p at-p) "If AT-P is NIL, PRINC to STREAM: the value of OBJECT-PRINT-NAME applied onto ARG If AT-P is non-nil, PRINC to STREAM: the value of OBJECT-PRINT-LABEL applied onto ARG" (declare (ignore colon-p)) (cond (at-p (princ (object-print-name arg) stream)) (t (princ (object-print-label arg) stream))))) ;; (format nil "Class ~/utils:format-label/" (find-class 'string)) ;; => "Class CL:STRING" (defun print-hash-table (table &key (stream *standard-output*) (format-control (load-time-value ;; NB: The NAMESPACE/SUBNAMESPACE naming ;; convention would be problematic, here (compile nil (formatter "~%~/ltp.common:format-label/ : ~/ltp.common:format-label/"))))) (declare (type hash-table table) (type format-control format-control) (type stream-designator stream)) (maphash (lambda (k v) (format stream format-control k v)) table)) #-(and) (eval-when () (with-output-to-string (*standard-output*) (print-hash-table asdf/system-registry:*registered-systems*)) )
13,648
Common Lisp
.lisp
335
37.137313
86
0.694661
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
6839174600819013681e8db6d833fd9016b570caca678f266e1089d7b783f15f
29,265
[ -1 ]
29,266
common-package.lisp
thinkum_ltp-main/src/main/lsp/common/common-package.lisp
;; common-package.lisp ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ ;; (in-package #:cl-user) (defpackage #:ltp/common (:nicknames #:ltp.common) (:use #:cl) (:export #:format* #:with-gensym #:with-symbols #:intern* #:intern-formatted #:file-name #:file-designator #:class-designator #:type-designator #:compute-class #:unsigned-fixnum #:simple-style-warning #:simple-program-error #:format-condition ;; - FIXME: Move the following into supplemental system definitions #:entity-condition ;; NB is not a cell-error #:entity-condition-name #:entity-not-found ;; NB see also container-condition #:redefinition-condition #:redefinition-condition-previous-object #:redefinition-condition-new-object #:container-condition #:container-condition-container #:compute-output-stream #:compute-input-stream #:setf-function-designator ;; NB typing & knowledge representation for Common Lisp programs #:lambda-function-designator #:function-designator #:compute-function #:with-safe-frefs ;; NB Usability @ ASDF extensions #:function-name ;; FIXME Consider moving the following three forms into the LTP common-mop system #:call-next-method* #:slot-value* #:when-slot-init #:stream-designator #:format-control #:defconstant* #:with-optimization ;; FIXME see also WITH-COMPILATION-UNIT (SBCL, ...) #:with-tail-recursion ;; [...] #:symbol-status #:package-designator #:package-exports-symbols #:package-exports-symbols-if #:defun* ;; #:labels* #:do-map #:do-mapped #:push-last #:nappend #:npushl #:map-plist #:do-cons #:simplify-vector #:do-vector #:simplify-string #:string-position #:null-string #:string-null-p #:array-dim #:array-index #:array-length #:typed-svector #:typed-vector #:split-string-1 #:split-string #:featurep #:mk-lf #:encapsulated-condition #:encapsulated-condition-condition #:compile-condition #:lambda-compile-condition #:lambda-compile-condition-form #:lambda-compile-error #:lambda-compile-warning #:lambda* ;; FIXME: Move the following to another system - ltp-common-parse e.g ;; Note the fairly XML-oriented nature of the terms, here. ;; ;; reuse in ltp-common-index #:character-code #:code-in-range #:code= #:code-name-start-char-p #:char-name-start-char-p #:code-name-char-p #:char-name-char-p #:read-name-string #:read-characters ;; FIXME: Move the following to another system - ltp-common-pprint e.g #:print-name #:print-label #:object-print-name #:object-print-label #:pretty-printable-object #:format-label #:print-hash-table ;; #:associative-object ;; moved to ../mop/aclass/ ;; #:object-name ))
3,320
Common Lisp
.lisp
116
24.818966
94
0.66436
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
d8f0740df7d85c881553a1eac3304ae039d155cd0c0763e279521460bf61f997
29,266
[ -1 ]
29,267
common-fn.lisp
thinkum_ltp-main/src/main/lsp/common/common-fn.lisp
;; fn-utils.lisp ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) ;; TD: DEFMACRO DEFUN* => (progn (declaim (ftype ...)) (defun ...)) (deftype setf-function-designator () '(cons (eql setf) (cons symbol null))) (deftype lambda-function-designator () '(cons (eql lambda) (cons list t))) (deftype function-designator () ;; NB: Using TYPEP as an argument parser/assert for CONS subtypes '(or symbol function setf-function-designator lambda-function-designator)) (defun* compute-function (form) "Evaluate FORM as a function designator, returning the function designated by FORM. Valid Syntax of FORM: * <SYMBOL> denoting a function name * (SETF <SYMBOL>) denoting a funtional SETF name * (LAMBDA () <BODY>) as a list, denoting an anonymous function * <FUNCTION> denoting itself If FORM is a LAMBDA form, this function will return the functional representation of FORM. See also: COMPILE*, COMPILE**" (declare (type function-designator form) (values function &optional)) (etypecase form (symbol (values (fdefinition form))) (function (values form)) (cons (let ((type (car form))) (ecase type (setf (values (fdefinition form))) (lambda (values (coerce form 'function)))))))) ;;;; Instance Tests ;; ;; (compute-function 'print) ;; (compute-function (quote (lambda () (list 1 2 3)))) ;; (compute-function '(setf gethash)) ;; (compute-function #'function) ;; ;; (compute-function (quote (lambda () (funcall (make-symbol "%fail"))))) ;; (compute-function `(lambda ,(values))) ;; ;;;; Instance "Fail Tests" ;; ;; (compute-function (gentemp)) ;; (compute-function (list 'setf (gentemp))) ;; (compute-function (list 'unknown 1 2 3)) ;; (compute-function (quote (lambda syntax-error))) (defmacro with-safe-frefs (specs &body body) ;;; NB: Prototype of a utility that could be useful for PERFORM ;;; methods within ASDF system definitions - in effect for making a ;;; forward reference to a function, without trying to intern a symbol ;;; in a package as yet undefined. "Evaluate BODY in a lexiccal environment in which each element of SPECS denotes a function. Syntax: > WITH-SAFE-FREFS ({SPECIFIER}*) {DECLARATION} {FORM}* > > SPECIFIER: A _safe function reference_ > DECLARATION, FORM: Like as in [CLHS] A _safe function reference_ denotes a set of a function name, with an optional pacakge specifier, and a symbol to which the function denoted by the function name is to be bound when the FORMS are evaluated. Example: (with-safe-frefs ((l #:list #:cl) (c #:identity)) (funcall c (funcall l 2))) => (2)" ;; FIXME N/A for (SETF FOO) function names (let ((%s (gentemp "%s-")) (%foundp (gentemp "%foundp-"))) (flet ((s-name (s) (etypecase s (string s) (symbol (symbol-name s)) (character (string s)))) (pkg-name (p) (etypecase p (package (package-name p)) (symbol (symbol-name p)) ((or string character) (values p))))) `(let (,@(mapcar (lambda (spec) (destructuring-bind (name fn &optional (package (etypecase fn (symbol (or (symbol-package fn) *package*)) ((or string character) *package*)))) spec (let ((fname (s-name fn)) (pkgname (pkg-name package))) `(,name (multiple-value-bind (,%s ,%foundp) (find-symbol ,fname ,pkgname) (cond (,%foundp (values (fdefinition ,%s))) (t (error "Package ~A does not contain a symbol ~S" (find-package ,pkgname) (quote (quote ,fname)))) )))))) specs)) ,@body)))) ;; (macroexpand-1 '(with-safe-frefs ((l list)) (funcall l 1 2))) ;; (with-safe-frefs ((l #:list #:cl)) (funcall l 1 2)) ;;; => (1 2) #+NIL ;; Instance Test (macroexpand (quote (with-safe-frefs ((l #:list #:cl) (c #:compute-function)) (funcall l (funcall c 'expt) 2)) )) (defun* function-name (fn) (declare (type function-designator fn) (values function-designator &optional)) (multiple-value-bind (lambda closure-p name) (function-lambda-expression (compute-function fn)) (declare (ignore lambda closure-p)) (cond ((and (consp name) (eq (car name) 'lambda)) (values nil)) (t (values name))))) ;; (function-name #'(setf gethash)) ;; => (SETF GETHASH) ;; (function-name #'print) ;; => PRINT ;; (function-name (lambda () (+ 1 1 ))) ;; => NIL ;; -- ;; FIXME - any portable "Local Inline" support - if tractably possible - ;; may require a manner of application-level system integration, so as ;; to enssure that all "Locally inline" functions will be available for ;; inlining, when initially defined. ;; ;; In such a configuration, those "Locally inline" functions might be ;; defined as "Inline in all calls," in some implementations - there ;; obviating the characteristic of those being defined as "Locally" ;; inline, in any context narrower than an entire application system.
5,584
Common Lisp
.lisp
161
30.52795
80
0.639043
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
25f7066f4e2078754d385516b051e97d75295b09dc3c7cb493570ee877379784
29,267
[ -1 ]
29,268
common-stream.lisp
thinkum_ltp-main/src/main/lsp/common/common-stream.lisp
;; stream-utils.lisp - stream utilities ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (deftype stream-designator () ;; FIXME revise - remove array-with-fill-pointer clause '(or (and symbol (member nil t)) stream (and string (satisfies array-has-fill-pointer-p)))) #+NIL (typep (make-array 20 :fill-pointer 0 :element-type 'base-char) 'stream-designator) ;; => T (deftype format-control () '(or string function)) (defun* compute-output-stream (s) "Given a stream designator, S, return: * S if S is a STREAM * *STANDARD-OUTPUT* if S is NULL * *TERMINAL-IO* if S is EQ to T See also: `compute-input-stream'" (declare (type stream-designator s) (values stream &optional)) (etypecase s (stream (values s)) (null (values *standard-output*)) ((eql t) (values *terminal-io*)))) (defun* compute-input-stream (s) "Given a stream designator, S, return: * S if S is a STREAM * *STANDARD-INPUT* if S is NULL * *TERMINAL-IO* if S is EQ to T See also: `compute-output-stream'" (declare (type stream-designator s) (values stream &optional)) (etypecase s (stream (values s)) (null (values *standard-input*)) ((eql t) (values *terminal-io*))))
1,722
Common Lisp
.lisp
46
34.5
80
0.635762
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
62d075f4cd43a891b53d1bc758fe03af44b56bdf0ab0bc7e795aaf2b2e176dfa
29,268
[ -1 ]
29,269
common-list.lisp
thinkum_ltp-main/src/main/lsp/common/common-list.lisp
;; common-list.lisp - utilities for Common Lisp lists ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (defmacro push-last (a l) ;; FIXME - Iterative application (with-list-append ?) ;; - Using a store variable STOR => (NIL) ;; and a pointer variable PTR => (CDR STOR) ;; such that the CDR of PTR is set to (CONS A) ;; returning lastly (CDR STOR) ;; this should not need to use LAST ;; See also: NAPPEND, NPUSHL (with-symbols (%l) `(let ((,%l ,l)) (cond ((consp ,%l) (rplacd (last ,%l) (list ,a)) ,%l) (t (setf ,l (list ,a))))))) #-(and) (eval-when () (push-last 3 '(1 2)) ;; => (1 2 3) (let ((l '(1 2))) (eq (push-last 3 l) l)) ;; => T (let ((l nil)) (values (eq (push-last 3 l) l) l)) ;; => T, (3) (let ((l (list nil))) (push-last 'a l) (values (push-last 'b l) l)) ;; => (NIL A B), (NIL A B) ) (define-modify-macro nappend (&rest lists) nconc "Destructively modify LISTS via NCONC") ;; (let (a (b '(1 2))) (values (nappend a b) a b)) (defmacro npushl (value where) "Destructively modify WHERE such that a list with VALUE as its single element becomes the LAST element of WHERE" `(setf ,where (nconc ,where (list ,value)))) ;; (let (a) (values (copy-list a) (npushl 1 a) a)) ;; (let ((b '(1 5))) (values (copy-list b) (npushl 17 b) b)) (defmacro map-plist (fn whence) (with-symbols (retv dispatch p v %whence %%whence %fn val) `(let ((,%fn ,fn) (,%%whence ,whence)) (labels ((,dispatch (,%whence ,val) (cond ((and (consp ,%whence) (consp (cdr ,%whence))) (let* ((,p (car ,%whence)) (,v (cadr ,%whence)) (,retv (funcall ,%fn ,p ,v))) (,dispatch (cddr ,%whence) (nappend ,val (list ,retv))))) (,%whence (error "~<Invalid property list syntax:~>~< ~S~>" ,%%whence)) (t (values ,val))))) (,dispatch ,%%whence nil))))) ;; (map-plist #'cons '(:a 1 :b 2)) ;; (map-plist #'cons '(:a (1) :b (2 3))) ;; (apply #'nconc (map-plist #'list '(:a 1 :b 2))) ;; (apply #'nconc (map-plist #'list '(:a (1) :b (2 3)))) ;; ;; (map-plist #'cons '(:a 1 :b 2 :err)) ;; (map-plist #'cons nil) ;; ---- (defmacro do-cons ((first rest whence &optional (return '(values))) &body body) ;; NB: For any dotted list, this macro's macroexpansion will return ;; before trying to bind the CDR of the dotted list, itself, as FIRST. ;; ;; It's assumed that the BODY forms will check the type of REST and ;; process accordingly, when REST may be neither NIL nor a CONS ;; (with-symbols (dispatch %whence) `(block nil (labels ((,dispatch (,%whence) ;; NB: RETURN is referenced twice, below. ;; ;; The expanded value of RETURN will only be evaluated ;; once. (cond ((consp ,%whence) (let ((,first (car ,%whence)) (,rest (cdr ,%whence))) ,@body (cond ((consp ,rest) (,dispatch ,rest)) (t (return ,return))))) ((null ,%whence) (return ,return)) (t (error 'type-error :expected-type 'list :datum ,%whence #+SBCL :context #+SBCL "as provided to DO-CONS")) ))) (,dispatch ,whence))))) #+NIL (eval-when () (do-cons (a rest (ltp/common/mop:class-precedence-list (find-class 'string))) (format t "~%~S" a)) (do-cons (a rest '(a b . c)) (format t "~%~S , ~S" a rest)) (do-cons (a b '(a . b)) (format t "~%~S , ~S" a b)) (do-cons (a b '(a)) (format t "~%~S : ~S" a b)) (do-cons (a b nil) (format t "~%~S : ~S" a b)) (do-cons (a b 'arbitrary) (format t "~%~S : ~S" a b)) )
4,649
Common Lisp
.lisp
123
29.357724
80
0.491767
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
e3cf5f1710b4942117d12777ee43e6068e20a27229d74e4265465ca10d648d4f
29,269
[ -1 ]
29,270
common-macro.lisp
thinkum_ltp-main/src/main/lsp/common/common-macro.lisp
;; macro-utils.lisp ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (defmacro format* (ctrl &rest args) ;; NB: Defined here, rather than in seq-utils.lisp ;; so as to avoid a certain dependency loop, as ;; would occur if it was defined in that file. ;; "Return a simple string formatted with the format conrtol string CTRL and the format arguments ARGS. See also: `simplify-string'" `(format nil ,ctrl ,@args)) (defmacro with-gensym ((&rest names) &body body) `(let (,@(mapcar (lambda (name) (let ((tmp (gensym (symbol-name name)))) `(,name (quote ,tmp)))) names)) ,@body)) ;; (macroexpand-1 '(with-gensym (a b) `(let ((,a 1) (,b 2)) (list ,a ,b 3 4)))) ;; (with-gensym (a b) `(let ((,a 1) (,b 2)) (list ,a ,b 3 4))) (defmacro with-symbols ((&rest names) &body body) ;; as an alternative to with-gensym ;; ;; FIXME Documentation. Note divergence onto the "with-gensyms" pattern `(let (,@(mapcar (lambda (name) (let ((tmp (make-symbol (symbol-name name)))) `(,name (quote ,tmp)))) names)) ,@body)) (defmacro intern* (s &optional (package *package*)) "Intern a symbol with a name equivalent to the symbol S, interned in the designated PACKAGE" `(intern (symbol-name ,s) ,package)) ;; (intern* (quote #:foo)) (defmacro intern-formatted (ctrl &rest args) ;; TD Define and apply a MAKE-SYMBOL-FORMATTED macro `(intern (format* ,ctrl ,@args))) ;; (intern-formatted "g_~a_foo" 'widget) ;; -- Macros onto the compiler environment ;; see also ;; ./common-opt.lisp ;; ./common-misc.lisp (defmacro defconstant* (name value &optional docstring &environment env) "Define NAME as a constant variable with value VALUE and optional DOCSTRING If NAME denotes an existing variable and its value is not EQUALP to the specified VALUE, then a `SIMPLE-STYLE-WARNING' will be emitted, and the previous value will be retained. This differs from the behavior of `CL:DEFCONSTANT' in that EQUALP is applied as the comparison, rather than EQL, moreover that the previous value will bex retained in all instances of BOUNDP NAME. If NAME does not denote an existing variable, then this macro's behavior is analogous onto `CL:DEFCONSTANT'" (with-symbols (%value %previous) ;; FIXME arbitrary discard of return values from GET-SETF-EXPANSION ;; FIXME Needs source review [LTP] (let ((%name (nth-value 4 (get-setf-expansion name env)))) ;; Ed. note: SBCL 1.2.5 was not handling a simpler form ;; when a certain file when McCLIM was compiled and loaded. So, ;; rather than using SYMBOL-VALUE directly on the NAME, this ;; will now try to wrap the reference to the symbol-value of ;; NAME around a return value from GET-SETF-EXPANSION w/ ENV ;; ...and still it doesn't work out. Effectively, it may be ;; that the BOUNDP call returns true (how?) but the SYMBOL-VALUE ;; call fails (how?) in "Some instances" ;; ;; So, EVAL instead of SYMBOL-VALUE ? Still, "Doesn't work out". ;; The 1st item in the backtrace is a FOP-FUNCALL, moreover, ;; as may serve to suggest a matter of some complexity towards ;; any complete debug of this particular issue. ;; ;; affected forms (McCLIM MCi fork) ;; * AUTOMATON::+MIN-CHAR-CODE+ (Drei state-and-transition.lisp) ;; * AUTOMATON::+INTERSECTION+ and later constants (Drei regexp.lisp) ;; ;; Each of those symbols is bound to a FIXNUM. ;; ;; Workaround: Use DEFCONSTANT instead, in those ;; bindings, considering: A FIXNUM is always EQL to itself ;; ;; Issue encountered in: ;; * SBCL 1.2.5 Linux 64 bit ;; * SBCL 1.2.5.76-65a44db Linux 64 bit `(defconstant ,name (cond ((boundp (quote ,%name)) (let ((,%previous (symbol-value (quote ,%name))) ;; ^ NB: LOAD-TIME-VALUE may DNW when binding %PREVIOUS ;; ;; NB This ensures, by side effect, that the VALUES ;; expression is always evaluated in DEFCONSTANT* (,%value ,value)) (unless (equalp ,%value ,%previous) (simple-style-warning "~<Ignoring non-EQUALP redefintion of constant ~S,~> ~ ~<existing value ~S~> ~<ignored value ~S~>" (quote ,%name) ,%previous ,%value)) (values ,%previous))) (t ,value)) ,@(when docstring (list docstring)))))) ;; (defconstant* quux "foo") ;; ;; (defconstant* foo 'foo) ;; (defconstant* foo '"foo") ;; note style warning ;; (symbol-value 'foo) ;; => FOO
5,193
Common Lisp
.lisp
119
38.07563
80
0.629652
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
193b7da91b83d810f17eea64ce2e32b29c8c1c220f2877774a2ac6ed05083882
29,270
[ -1 ]
29,271
common-name.lisp
thinkum_ltp-main/src/main/lsp/common/common-name.lisp
;; name-utils.lisp - symbol/name utilities ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - API and initial implementation ;; ;;------------------------------------------------------------------------------ ;; FIXME The annotations in this file obviously need to be managed in something like documentation (in-package #:ltp/common) (eval-when (:compile-toplevel :eval) (defmacro array-mkproto (arr) (with-symbols (%arr) `(let ((,%arr ,arr)) (cond ((adjustable-array-p ,%arr) (make-array (array-dimensions ,%arr) :element-type (array-element-type ,%arr) :adjustable t :fill-pointer (fill-pointer ,%arr))) (t (make-array (array-dimensions ,%arr) :element-type (array-element-type ,%arr) :adjustable nil))))))) (defun string-invert-case (str) "Return a copy of STR such that every letter charater in STR has an inverted character case" (let* ((len (length str)) (strcp (unless (zerop len) (array-mkproto str)))) (declare (type array-dim len)) (cond ((zerop len) (copy-seq str)) (t (dotimes (n len strcp) (let ((c (char str n))) (setf (aref strcp n) (cond ((upper-case-p c) (char-downcase c)) ((lower-case-p c) (char-upcase c)) (t c))))))))) ;; (string-invert-case "nAME") ;; => "Name" ;; ;; (string-invert-case "NAME") ;; => "NAME" ;; ;; (string-invert-case "name-2.4-8") ;; => "NAME-2.4-8" ;; #-(and) (let* ((initial "name-2.4-8") (buff (make-array 16 :element-type 'base-char :fill-pointer 10))) (dotimes (n (length initial)) (setf (char buff n) (schar initial n))) (let ((ret (string-invert-case buff))) (values ret (fill-pointer ret) (array-dimensions ret)))) ;; => "NAME-2.4-8", 10, (16) (defun nstring-invert-case (str) "Destructively modify STR such that every letter charater in STR will have a character case inverted to its orignal value. The object STR will be returned" (let ((len (length str))) (declare (type array-dim len)) (cond ((zerop len) (values str)) (t (dotimes (n len str) (let ((c (char str n))) (setf (aref str n) (cond ((upper-case-p c) (char-downcase c)) ((lower-case-p c) (char-upcase c)) (t c))))))))) ;; (nstring-invert-case "NaMe") ;; => "nAmE" (defun mangle-case (str case) ;; FIXME/TD Define a "destructively modifies" form ;; ;; -- requires [add'l to nstring-invert-case] ;; - nstring-downcase ;; - nstring-upcase ;; - nstring-capitalize (NB: Parser Hacks, or RATHER Pretty-Printer ;; hacks and quirks of the disjunction of CL #'READTABLE-CASE and ;; CL *PRINT-CASE* if only insofar as affecting behaviors of ;; prin1/prin1-to-string i.e print-readable-string/print-escaped-string ;; for SYMBOL type values - also w/ NB side effects of any ;; *PRINT-READABLY* bindings, such that establish a really ;; troubling set of requirements FOR portable PRINT-OBJECT methods) ;; ;; - NB: Three-state logic for character case onto CL ;; Upcase / Downcase / Nonchar ;; - NB: :UPCASE state in readtable => Wrap in || if name is not ;; all upcase / similar for :DOWNCASE / N/A for :PRESERVE ;; TBD for :INVERT ;; ;; +- and document these, in a "Names Dictionary" for LTP ;; - w/ xref in an introduction to the LTP manual, in which "Forms ;; for destructive modification of sequence values" may be ;; introduced - narrowly any confusion about pointers to pointers ;; in C type decls, and pointer dereferencing in C applications ;; ... and variables as lexically scoped metaobjects in Common Lisp. ;; ;; SEE ALSO: LIBREOFFICE; UNO SDK b.c DOCBOOIK and TEI P5 ;; ;; NB - Examples - CASE may be provided by #'READTABLE-CASE or *PRINT-CASE* ;; but note the slightly different syntax and semantics of which, namely: ;; - #'READTABLE-CASE - unique :INVERT specifier ;; - *PRINT-CASE* - unique :CAPITALIZE specifier (declare (type string str) (type (member :upcase :downcase :preserve :invert :capitalize) case) (values string)) (ecase case (:upcase (values (string-upcase str))) (:downcase (values (string-downcase str))) (:preserve (values (copy-string str))) (:capitalize (values (string-capitalize str))) (:invert (values (string-invert-case str))))) #| NB - CLSYS QA - SLIME/SWANK in SBCL when *PRINT-READABLY* Example [SBCL]: A) after (setq *print-readably* t) in SLIME B) subsq of find-symbol '<non-string-value>) #<TYPE-ERROR expected-type: STRING datum: <NON-STRING-VALUE>> cannot be printed readably. [Condition of type PRINT-NOT-READABLE] Alternately, with SLIME in CCL: Attempt to print object #<TYPE-ERROR #x14B0DB8E> on stream #<STRING-OUTPUT-STREAM #x14B17FF6> . This may be interpreted as representing a program error, -- NB MAKE-LOAD-FORM would not be applicable here. TBD: :AROUND methods for PRINT-OBJECT (in SLIME/SWANK?), dispatching when the object is denoted as to have an "Unreadable" printed represntation && *PRINT-READABLY* - TBD: Portable function for determining whether an object has a readable printed representation - TBD: Interoperability onto PRINT-UNREADABLE-OBJECT forms ---- NB - implementation-specific concerns @ low-level system reflection - SB-KERNEL:GET-LISP-OBJ-ADDRESS - SB-KERNEL:MAKE-LISP-OBJ - AND NOTE THE SOURCE COMMENTS NEAR THIS' <DEFUN>. cf GC IN SBCL ^ NB Uses intrinsict low-end-type-by-address semantics (per CMUCL, SBCL impl) - et c. EXAMPLE (sb-kernel:make-lisp-obj (sb-kernel:get-lisp-obj-address (find-class 'standard-class))) - NB SAP-STACK, CONTROL-STACK, UNSIGNED-STACK, ... in SBCL VOPs (e.g debug.lisp) - TOPIC (LTP INTERNALS KB - CMUCL, SBCL) : System Area Pointers and *CL xalloc -- ^ NB: Insofar as during the evaluation of any PRINT-OBJECT method, any OBJECT provided to that method may be assumed to be at least "Still Available" within the duration of the evaluation of that method. -- NB: Type-Tagged Memory Management in CMUCL and SBCL ... and that in CCL see e.g /usr/local/lib/ccl/compiler/X86/X8664/x8664-arch.lisp /usr/local/lib/ccl/compiler/ARM/arm-arch.lisp ^ in which it looks like a substantially different (?!) perhaps much more condensed (??) kernel than in CCL x86:64 ... WHICH MAY SERVE TO REITERATE THE UTILITY OF UML+SYSML MODELS FOR COMMON LISP - see also: {...} ---- TBD: #'CCL:EGC - note CCL x86-utils.lisp, arm-utils.lisp (ASM exprs in a Scheme-like langage) ---- NB: CCL X8664::*X8664-TARGET-ARCH* [source code] ^ note some *-offset slots NB (type-of x8664::*x8664-subprims*) => (SIMPLE-VECTOR 154) NB <SP> in CCL => <subprim> NB (?) (type-of x8664::*x8664-subprims-shift*) => (INTEGER 0 1152921504606846975) x8664::*x8664-subprims-shift* => 3 x8664::x8664-subprims-base => #x15000 NB every keyword bucket in x8664::*x8664-target-uvector-subtags* such that maps to a class name in #:CL (or elsewhere) - and those few that do not e.g (let ((clp (find-package '#:ccl)) (*print-base* 16)) (dolist (bucket x8664::*x8664-target-uvector-subtags* nil) (destructuring-bind (s . v) bucket (unless (find-class (intern (symbol-name s) clp) nil) (print (list s v) t))))) % ^ NB This simple form uses INTERN not FIND-SYMBOL (:STRUCT 36) (:ISTRUCT 46) (:HASH-VECTOR 35) (:INSTANCE 86) ;; NB (:SIGNED-8-BIT-VECTOR D7) (:UNSIGNED-8-BIT-VECTOR E7) (:SIGNED-16-BIT-VECTOR A7) (:UNSIGNED-16-BIT-VECTOR B7) (:SIGNED-32-BIT-VECTOR D9) (:UNSIGNED-32-BIT-VECTOR E9) (:SIGNED-64-BIT-VECTOR DA) (:UNSIGNED-64-BIT-VECTOR EA) ;; NB (:VECTOR-HEADER A6) (:ARRAY-HEADER A5) ;; SUBSQ (:MIN-CL-IVECTOR-SUBTAG 97) ---- TBD: 32-bit DSO ABI interop onto CCL, SBCL, ... TBD: 32-bit ELFs and dlsym() w/i a 64-bit "THING" ---- NB (?) static locations in FASL encodings ---- Note the many PRINT-OBJECT methods defined in <OpenMCL as CCL> Note also, the concept of a "LAP" in <OpenMCL as CCL> (Lisp Address Pointer??) Orthogonally note (apropos "addr" '#:ccl) - more specifically: (defun print-fns (name &optional (package '#:ccl)) (dolist (fn (mapcan #'(lambda (s) (when (fboundp s) (list (fdefinition s)))) (apropos-list name package))) (print fn t))) (print-fns "addr") (print-fns "obj") (print-fns "macptr") (print-fns "offset") (print-fns "acode") ;; cf. CCL FASL gen (??) NB CCL FRAG objs (??) (print-fns "ptr") - NB Novelty CCL #(ADDR <THING>) syntax during PRINT of a FUNCTION there ("addr" search, above) - note thus: CCL::%ADDRESS-OF (CCL x86:64, ARM, ...) NB: /usr/local/lib/ccl/level-0/X86/x86-utils.lisp /usr/local/lib/ccl/level-0/ARM/arm-utils.lisp -- NB (CCL::NX-LOOKUP-TARGET-UVECTOR-SUBTAG :MACPTR) -- NB CCL X8664::DEFINE-SUBTAG !- but HOWTO: ADDRESS to OBJECT with CCL ? ... d dh d d d ddhf (ccl:%address-of (find-class 'standard-class)) ^ insofar at least as for handling the :IDENTITY arg w/ PRINT-UNREADABLE-OBJECT ^ note that this function is passingly documented in debugging.ccldoc and it may not be tractably usable for much, without some more infrastructure "Low level" operations with CCL (namely for operns with "Intermediate Value" types in CCL) WOULDN'T IT BE NICE IF THEY'D DESCRIBED THE CCL DESIGN FOR ANYONE ELSE TO READ. EVEN A COMPLEAT UML MODEL OF THE SOURCE CODE MAY NOT BE NEARLY ENOUGH. SO, OTHERWISE FOCUSING ON PORTABLE SYMOBLIC REFERENCES ONTO COMMON LISP PROGRAMS -- (??) -- (ccl:%int-to-ptr (ccl:%address-of (find-class 'standard-class))) TO DERERENCE IT TO THE ORIGINAL OBJ ? FROM A CCL MACPTR OBJ ? N/A for this - CCL::%GET-PTR, CCL::SAFE-GET-PTR an interned symbol: CCL::DEREF-MACPTR but not useful w/o (????) -NB- defun of CCL::STANDARD-OBJECT-P -- [...] -- NB (CCL::ROOM) ... in a multi-threaded CCL build -- [.!...] -- NB /usr/local/lib/ccl/library/lispequ.lisp in which CCL's adoption of the CMUCL Python compiler's type system is openly referenced - TYPE-CLASS, CTYPE, and subsq (w/ a lot of %SVREF ??) -- PEVIOUSLY -- (CCL::%GET-OBJECT MACPTR?? OFFSET??) ^ OFFSET is an offset onto what again ? ? TBD CCL::WITH-MACPTRS ? NB (print-unreadable-object ((CCL:%NULL-PTR) t :type t :identity t)) ?? NB (ccl:%int-to-ptr 0) ?! (ccl:%int-to-ptr (ccl:%address-of (find-class 'standard-class))) ?! so what about the illustrious offset for %GET-OBJECT ? Irrelvant here ?? ?? NB "The MACTPR type" in /usr/local/lib/ccl/lib/foreign-types.lisp it looks so much like CMUCL's ALIEN system. Go figure? ^ NB in x86 CCL IMPL - ASM (??) (trap-unless-lisptag= offset target::tag-fixnum imm1) ^ NB: a numeric address in CCL is not usable as a MACPTR. - a CCL MACPTR is some kind of a structured object, though it's absolutely unclear as to how any such object is ever created in CCL. - NB QA W/ CCL - CCL:*RECORD-SOURCE-FILE*, CCL:*SAVE-SOURCE-FILE-LOCATIONS*, CCL:*RECORD-PC-MAPPING* - NB QA W/ CCL - (CCL:FUNCTION-SOURCE-NOTE #'PRINT) But it would be so simple if all implementations were CMUCL or SBCL. (??) - NB in CCL x8664-arch.lisp [structured strawpile] "There are two kinds of macptr; use the length field of the header if you need to distinguish between them" subsq: MACPTR, XMACPTR -- TBD: Meaning of source comments for CCL::ALL-OBJECTS-OF-TYPE NB (defun low-types () (let ((typel (list nil))) (ltp/common:do-vector (s ccl::*heap-utilization-vector-type-names* (cdr typel)) (unless (or (null s) (eq s 'ccl::bogus)) (rplacd (last typel) (cons s nil)))))) CL-USER> (low-types) (SYMBOL RATIO BIGNUM MACPTR CCL::CATCH-FRAME COMPLEX DOUBLE-FLOAT CCL::DEAD-MACPTR CCL::HASH-VECTOR STRUCTURE CCL::XCODE-VECTOR CCL::POOL CCL::INTERNAL-STRUCTURE CCL::COMPLEX-SINGLE-FLOAT POPULATION CCL::VALUE-CELL CCL::COMPLEX-DOUBLE-FLOAT PACKAGE CCL::XFUNCTION CCL::SLOT-VECTOR LOCK CCL::BASIC-STREAM CCL::INSTANCE FUNCTION CCL::SIMPLE-COMPLEX-DOUBLE-FLOAT-VECTOR CCL::ARRAY-HEADER CCL::VECTOR-HEADER CCL::SIMPLE-SIGNED-WORD-VECTOR SIMPLE-VECTOR CCL::SIMPLE-UNSIGNED-WORD-VECTOR CCL::SIMPLE-COMPLEX-SINGLE-FLOAT-VECTOR SIMPLE-BASE-STRING CCL::SIMPLE-FIXNUM-VECTOR CCL::SIMPLE-SIGNED-BYTE-VECTOR CCL::SIMPLE-SIGNED-LONG-VECTOR CCL::SIMPLE-SIGNED-DOUBLEWORD-VECTOR CCL::SIMPLE-UNSIGNED-BYTE-VECTOR CCL::SIMPLE-UNSIGNED-LONG-VECTOR CCL::SIMPLE-UNSIGNED-DOUBLEWORD-VECTOR BIT-VECTOR CCL::SINGLE-FLOAT-VECTOR CCL::DOUBLE-FLOAT-VECTOR) and NB CCL::ALL-OBJECTS-OF-TYPE (TYPE PRED) ;; feat. source code commentary AAAND NB CCL::%MAP-AREAS [used in CCL::ALL-OBJECTS-OF-TYPE] NB #'CCL::TYPECODE - internal meaning cf. all-objects-of-type SRC FORM e.g (ccl::typecode (find-class 'standard-class)) => 134 -- TBD (DEFLOWTYPE PODLE #:WOFF #'MAKE-WOFF #'FREE-WOFF #'WOFFUNDEF) (PRINT-UNBARKABLE-OBJECT (ALLOC 'PODLE) *WRONG-TREE*) -- NB FFI with CCL - CCL::SETUP-X8664-FTD (CCL foreign type data) NB FFI with CCL - CCL:%FF-CALL (arch-specific impl) -- NB /usr/local/lib/ccl/level-1/l1-clos-boot.lisp -- ... /usr/local/lib/ccl/compiler/subprims.lisp - CCL::SUBPRIMITIVE-INFO /usr/local/lib/ccl/compiler/X86/x86-lap.lisp - TBD Vectorization (??) and CCL - NB machine-specific extension of CCL::DLL-NODE w/ CCL::X86-LAP-NOTE & subtypes - see also /usr/local/lib/ccl/compiler/ARM/arm-lap.lisp - principally see also /usr/local/lib/ccl/compiler/dll-node.lisp ^ NB DLL => Doubly Linked List (UTIL) /usr/local/lib/ccl/compiler/backend.lisp (??) /usr/local/lib/ccl/compiler/nx-basic.lisp /usr/local/lib/ccl/compiler/nx0.lisp -(NB REFLX w/ CCL ??) /usr/local/lib/ccl/lib/source-files.lisp /usr/local/lib/ccl/compiler/X86/x86-disassemble.lisp -(NB FFI w/ CCL) /usr/local/lib/ccl/lib/foreign-types.lisp /usr/local/lib/ccl/lib/db-io.lisp -(NB MOP w/ CCL) /usr/local/lib/ccl/lib/method-combination.lisp /usr/local/lib/ccl/lib/hash.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS HASH-TABLE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-unicode.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CHARACTER-ENCODING> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-streams.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::IO-BUFFER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::BASIC-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS SYNONYM-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS TWO-WAY-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS STRING-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::FD-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::VECTOR-STREAM> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/linux-files.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS EXTERNAL-PROCESS> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-files.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS PATHNAME> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-typesys.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::TYPE-CLASS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::CTYPE> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::TYPE-CELL> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/sysutils.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::SPARSE-VECTOR> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-lisp-threads.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::LISP-THREAD> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-processes.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS PROCESS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS LOCK> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS LOCK-ACQUISITION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS SEMAPHORE-NOTIFICATION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-io.lisp (:METHOD PRINT-OBJECT :AROUND (#<BUILT-IN-CLASS T> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS T> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CHARACTER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS INTEGER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS RATIO> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS COMPLEX> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS FLOAT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CLASS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::VALUE-CELL> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS STANDARD-OBJECT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS STANDARD-METHOD> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS METHOD-FUNCTION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS METAOBJECT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::COMBINED-METHOD> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS SLOT-DEFINITION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS EQL-SPECIALIZER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::SLOT-ID> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::TAGGED-RETURN-ADDRESS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::SYMBOL-VECTOR> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::FUNCTION-VECTOR> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::CLASS-CELL> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-reader.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::PACKAGE-REF> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS SOURCE-NOTE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-error-system.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS RESTART> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CONDITION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-events.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::PERIODIC-TASK> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-sysio.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS EXTERNAL-FORMAT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::FUNDAMENTAL-FILE-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::BASIC-FILE-STREAM> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/numbers.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS RANDOM-STATE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/subprims.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::SUBPRIMITIVE-INFO> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/X86/x86-lap.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::X86-LAP-LABEL> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/backend.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::BACKEND> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/nx-basic.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::CODE-NOTE> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::ACODE-AFUNC-REF> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::ACODE-REF> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/nx0.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::VAR> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::ACODE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/source-files.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS DEFINITION-TYPE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/X86/x86-disassemble.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::X86-DISASSEMBLED-INSTRUCTION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/foreign-types.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::INTERFACE-DIR> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::FOREIGN-TYPE-CLASS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS EXTERNAL-ENTRY-POINT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::FOREIGN-VARIABLE> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS SHLIB> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/db-io.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::CDBX> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::FFI-TYPE> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::OBJC-METHOD-INFO> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/method-combination.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS METHOD-COMBINATION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/pprint.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::PPRINT-DISPATCH-TABLE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/describe.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS INSPECTOR::UNBOUND-MARKER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS INSPECTOR::BOGUS-OBJECT-WRAPPER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS INSPECTOR::ERROR-FRAME> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS INSPECTOR::STACK-INSPECTOR> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/library/remote-lisp.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::REMOTE-LISP-THREAD> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::REMOTE-LISP-CONNECTION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/library/sockets.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::SOCKET-ADDRESS> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/tools/asdf.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/COMPONENT:COMPONENT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/FIND-COMPONENT:MISSING-DEPENDENCY> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/FIND-SYSTEM:MISSING-COMPONENT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/FIND-COMPONENT:MISSING-COMPONENT-OF-VERSION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/OPERATION:OPERATION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/ACTION:ACTION-STATUS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/PLAN:PLANNED-ACTION-STATUS> #<BUILT-IN-CLASS T>)) /usr/home/gimbal/.emacs.d/libcl/slime/swank.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS SWANK::CHANNEL> #<BUILT-IN-CLASS T>)) /usr/home/gimbal/.emacs.d/libcl/slime/contrib/swank-trace-dialog.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS SWANK-TRACE-DIALOG::TRACE-ENTRY> #<BUILT-IN-CLASS T>))/usr/local/lib/ccl/lib/hash.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS HASH-TABLE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-unicode.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CHARACTER-ENCODING> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-streams.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::IO-BUFFER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::BASIC-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS SYNONYM-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS TWO-WAY-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS STRING-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::FD-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::VECTOR-STREAM> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/linux-files.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS EXTERNAL-PROCESS> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-files.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS PATHNAME> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-typesys.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::TYPE-CLASS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::CTYPE> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::TYPE-CELL> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/sysutils.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::SPARSE-VECTOR> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-lisp-threads.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::LISP-THREAD> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-processes.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS PROCESS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS LOCK> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS LOCK-ACQUISITION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS SEMAPHORE-NOTIFICATION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-io.lisp (:METHOD PRINT-OBJECT :AROUND (#<BUILT-IN-CLASS T> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS T> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CHARACTER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS INTEGER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS RATIO> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS COMPLEX> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS FLOAT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CLASS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::VALUE-CELL> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS STANDARD-OBJECT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS STANDARD-METHOD> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS METHOD-FUNCTION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS METAOBJECT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::COMBINED-METHOD> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS SLOT-DEFINITION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS EQL-SPECIALIZER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::SLOT-ID> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::TAGGED-RETURN-ADDRESS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::SYMBOL-VECTOR> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::FUNCTION-VECTOR> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::CLASS-CELL> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-reader.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::PACKAGE-REF> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS SOURCE-NOTE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-error-system.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS RESTART> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CONDITION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-events.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::PERIODIC-TASK> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/level-1/l1-sysio.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS EXTERNAL-FORMAT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::FUNDAMENTAL-FILE-STREAM> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::BASIC-FILE-STREAM> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/numbers.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS RANDOM-STATE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/subprims.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::SUBPRIMITIVE-INFO> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/X86/x86-lap.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::X86-LAP-LABEL> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/backend.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::BACKEND> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/nx-basic.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::CODE-NOTE> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::ACODE-AFUNC-REF> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::ACODE-REF> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/nx0.lisp (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::VAR> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::ACODE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/source-files.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS DEFINITION-TYPE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/compiler/X86/x86-disassemble.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::X86-DISASSEMBLED-INSTRUCTION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/foreign-types.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::INTERFACE-DIR> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::FOREIGN-TYPE-CLASS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS EXTERNAL-ENTRY-POINT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS CCL::FOREIGN-VARIABLE> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<BUILT-IN-CLASS SHLIB> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/db-io.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::CDBX> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::FFI-TYPE> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::OBJC-METHOD-INFO> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/method-combination.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS METHOD-COMBINATION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/pprint.lisp (:METHOD PRINT-OBJECT (#<STRUCTURE-CLASS CCL::PPRINT-DISPATCH-TABLE> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/lib/describe.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS INSPECTOR::UNBOUND-MARKER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS INSPECTOR::BOGUS-OBJECT-WRAPPER> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS INSPECTOR::ERROR-FRAME> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS INSPECTOR::STACK-INSPECTOR> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/library/remote-lisp.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::REMOTE-LISP-THREAD> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::REMOTE-LISP-CONNECTION> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/library/sockets.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS CCL::SOCKET-ADDRESS> #<BUILT-IN-CLASS T>)) /usr/local/lib/ccl/tools/asdf.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/COMPONENT:COMPONENT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/FIND-COMPONENT:MISSING-DEPENDENCY> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/FIND-SYSTEM:MISSING-COMPONENT> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/FIND-COMPONENT:MISSING-COMPONENT-OF-VERSION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/OPERATION:OPERATION> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/ACTION:ACTION-STATUS> #<BUILT-IN-CLASS T>)) (:METHOD PRINT-OBJECT (#<STANDARD-CLASS ASDF/PLAN:PLANNED-ACTION-STATUS> #<BUILT-IN-CLASS T>)) /usr/home/gimbal/.emacs.d/libcl/slime/swank.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS SWANK::CHANNEL> #<BUILT-IN-CLASS T>)) /usr/home/gimbal/.emacs.d/libcl/slime/contrib/swank-trace-dialog.lisp (:METHOD PRINT-OBJECT (#<STANDARD-CLASS SWANK-TRACE-DIALOG::TRACE-ENTRY> #<BUILT-IN-CLASS T>)) |#
32,176
Common Lisp
.lisp
581
51.387263
128
0.689966
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
b3cfc08c98d142690b752d3292c82ea954e1aed41befb80b0906b8c0e5d06c6e
29,271
[ -1 ]
29,272
common-reader.lisp
thinkum_ltp-main/src/main/lsp/common/common-reader.lisp
;; reader-utils.lisp - reader utilities ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) ;; NB: This assumes a Unicode manner of character encoding, and may not ;; be thoroughly portable as such. ;; ;; FIXME/NB: Up to and including NAME-CHAR-P the following definitions ;; represent something of an approach for developing a simple ;; character-oriented name parser such that may be intrinsically ;; interopable with name strings in XML syntax. (deftype character-code () '(integer 0 (#.char-code-limit))) (defmacro code-in-range (c rmin rmax) `(<= (the character-code ,rmin) (the character-code ,c) (the character-code ,rmax))) ;; NB: The following forms are defined principally for operation onto ;; numeric character codes. ;; ;; Note also the CL-BABEL API for charset compat across implementations (defmacro code= (c code) `(= (the character-code ,c) (the character-code ,code))) (declaim (inline name-start-char-p code-name-char-p char-name-char-p #| read-name-string read-characters |# )) (defun code-name-start-char-p (c) ;; cf. http://www.w3.org/TR/xml/#NT-NameStartChar (declare (type character-code c) (values boolean)) (unless (code= c #.(char-code #\Space )) (or (code-in-range c #.(char-code #\a) #.(char-code #\z)) (code-in-range c #.(char-code #\A) #.(char-code #\Z)) (code= c #.(char-code #\_)) (code= c #.(char-code #\:)) ;; NB ":" as a name start char - valid for some XML, but inadvisable cf. [XMLNS] ;; see also : {other sys}:ncname-start-char-p (code-in-range c #xC0 #xD6) (code-in-range c #xD8 #xF6) (code-in-range c #xF8 #x2FF) (code-in-range c #x370 #x37D) (code-in-range c #x37F #x1FFF) (code-in-range c #x200C #x200D) (code-in-range c #x2070 #x218F) (code-in-range c #x2C00 #x2FEF) (code-in-range c #x3001 #xD7FF) (code-in-range c #xF900 #xFDCF) (code-in-range c #xFDF0 #xFFFD) (code-in-range c #x10000 #xEFFFF)))) (defun char-name-start-char-p (c) (declare (type character c) (values boolean)) (code-name-start-char-p (char-code c))) (defun code-name-char-p (c) ;; cf. http://www.w3.org/TR/xml/#NT-NameChar ;; ;; NB: This API has define separate CODE-NAME-CHAR-P and ;; CHAR-NAME-CHAR-P functions, to one effect of obviating an ;; "Unreachable Code" error from SBCL when compiling READ-NAME-STRING ;; w/ this function inline. ;; ;; The principal effect has been of developing one specialized ;; function for each type of argument, C. (declare (type character-code c) (values boolean) (inline name-start-char-p)) (unless (code= c #.(char-code #\Space )) (or (code-name-start-char-p c) (code-in-range c #.(char-code #\0) #.(char-code #\9)) (code= c #.(char-code #\-)) (code= c #.(char-code #\.)) (code= c #xB7) (code-in-range c #x0300 #x036F) (code-in-range c #x203F #x2040)))) ;; (name-char-p #\A) ;; => T ;; (name-char-p #\.) ;; => T ;; (name-char-p #\Space) ;; => NIL (defun char-name-char-p (c) (declare (type character c) (values boolean) (inline code-name-char-p)) (code-name-char-p (char-code c))) (defun read-name-string (s &optional (eof-error-p t) eof-value) (declare (type stream s) (values t)) (with-output-to-string (buff) (let ((n 0)) (declare (type (integer 0 1) n)) (loop (let ((c (peek-char nil s nil))) (cond ((and c (char-name-char-p c)) (when (zerop n) (setq n 1)) ;; [?] (write-char (read-char s) buff)) ((zerop n) ;; EOF (cond (eof-error-p (error 'end-of-file :stream s)) (t (return-from read-name-string eof-value)))) (t (return)))))))) ;; (with-input-from-string (s "kfoo 100 +") (read-name-string s )) ;; => "kfoo" ;; (with-input-from-string (s "kfoo") (read-name-string s )) ;; => "kfoo" ;; (with-input-from-string (s "") (read-name-string s )) ;; --> error (end-of-file) ;; (with-input-from-string (s "") (read-name-string s nil)) ;; => NIL ;; (with-input-from-string (s "") (read-name-string s nil ':KEYWORD)) ;; => :KEYWORD (defun read-characters (stream n &key (element-type 'character) (eof-error-p t) eof-value) "Read N many characters from STREAM, returning a string of length N and of the specified ELEMENT-TYPE as a sequence of those characters, second value NIL, and third value, the value N If end of file is encountered on the STREAM before N many characters have been read: 1. If EOF-ERROR-P is NON-NIL then an END-OF-FILE error is signaled 2. Otherwise, if EOF-ERROR-P is NIL then EOF-VALUE is returned as the first value, with the second return value being the string as initalized until EOF, and as the third return value, the number of characters read from STREAM until EOF." (declare (type stream-designator stream) (type array-dim n) (type type-designator element-type) (values t (or simple-string null) array-dim)) #+NIL ;; FIXME: Implement this as a compiler warning? (when (and eof-value (null eof-error-p)) (simple-style-warning "EOF-VALUE specified with EOF-ERROR-P NIL: ~S" eof-value)) (let ((buff (make-array n :element-type element-type)) (eof (load-time-value (gensym "EOF-") t))) (declare (type simple-string buff) (type symbol eof)) (dotimes (%n n (values buff nil n)) (declare (type array-dim %n)) (let ((c (read-char stream nil eof))) (cond ((eq c eof) (cond (eof-error-p (error 'end-of-file :stream stream)) (t (return (values eof-value buff %n))))) (t (setf (schar buff %n) c))))))) ;; (with-input-from-string (s "42FOO42") (read-characters s 2)) ;; => "42", NIL, 2 ;; (with-input-from-string (s "42FOO42") (read-characters s 42)) ;; --> EOF-ERROR ;; (with-input-from-string (s "42FOO42") (read-characters s 8 :eof-error-p nil )) ;; => NIL, <string with null char>, 7 ;; (with-input-from-string (s "42FOO42") (read-characters s 8 :eof-error-p nil :eof-value 42)) ;; => 42, <string with null char>, 7
6,561
Common Lisp
.lisp
167
35.479042
113
0.637192
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
e5c1eb79433e974fcb29f953a4474c89f7382e40a00e40ab8ed8538af9edca73
29,272
[ -1 ]
29,273
common-string.lisp
thinkum_ltp-main/src/main/lsp/common/common-string.lisp
;; common-string.lisp - string utilities for Common Lisp programs ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (defun* simplify-string (string) "If STRING can be coerced to a SIMPLE-BASE-STRING, then return a SIMPLE-BASE-STRING representative of the contents of STRING. Otherwise, return a SIMPLE-STRING representative of the contents of STRING." (declare (type string string) (inline coerce) (values (or simple-string simple-base-string) &optional)) (handler-case (coerce string 'simple-base-string) (type-error (c) (cond ((eq (type-error-datum c) string) (coerce string 'simple-string)) (t (error c)))))) #-(and) (eval-when () ;; NB - SBCL (typep "FOO" 'simple-base-string) ;; => NIL (typep "FOO" 'simple-string) ;; => T (typep (simplify-string "FOO") 'simple-base-string) ;; => T (typep (simplify-string (make-string 0 :element-type 'base-char)) 'simple-base-string) ;; => T ) (defmacro string-position (char str &rest rest) ;; This macro expands to a strongly-typed wrapper for CL:POSITION ;; ;; a type-dispatching form, towards applying compiler optimizations ;; at runtime, cf. SB-KERNEL:%FIND-POSITION, and no-doubt similar in CMUCL ;; NB SBCL emits 'deleting unreachable code' when compiling this ;; macroexpansion within SPLIT-STRING-1. The compiler may be inferring ;; that the default (t) form may be unreachable, there. ;; FIXME/TD - Portable type system reflection for Lisp compiler ;; environments, pursuant towards portable compiler macro definition ;; ;; - When the type of STR can be inferred, use static dispatching for ;; that type - this could entail some dynamic dispatching, as when ;; the type of STR would denote a union type ;; ;; - When not, use dynamic dispatching - entailing, e.g that the ;; default 't' form will be compiled ;; ;; - Consider developing a CLOS-like interfce for the compiler ;; environment, but such that must allow method specialization at a ;; finer granularity than Common Lisp classes. See also, the ;; implementation type system in each of CMUCL, SBCL, CCL, .... ;; ;; - Note also, compiler mcros (with-symbols (%char %str) `(let ((,%char ,char) (,%str ,str)) (declare (inline position)) (typecase ,%str (simple-base-string (position ,%char (the simple-base-string ,%str) ,@rest)) (simple-string (position ,%char (the simple-string ,%str) ,@rest)) (string (position ,%char (the string ,%str) ,@rest)) (t (position ,%char (coerce ,%str 'simple-string) ,@rest)))))) (defconstant* +null-string+ (make-string 0 :element-type 'base-char)) ;; (declare (inline null-string string-null-p)) (defun* null-string () (declare (values simple-base-string &optional)) ;; FIXME declare inline (values +null-string+)) (defun* string-null-p (str) (declare (type string str) (values boolean &optional)) ;; FIXME: declare inline (or (eq str +null-string+) ;; FIXME_DOCS note opportunities for object reuse in ANSI CL ;; programs, and correspondingly, opportunities for using EQ as ;; an equivalence test (and (typep str 'string) (zerop (length (the string str)))))) (defun* split-string-1 (char str &key (start 0) end from-end key (test #'char=) test-not ) ;; FIXME_DOCS See also `split-string' ;; FIXME_DOCS note use of CL:SIMPLE-STRING in the type signature for ;; the return values of this function ;; ;; Concerning a "deleting unreachable code" message from SBCL when ;; compiling this function, see commentary in STRING-POSITION src. (declare (type string str) (values simple-string (or simple-string null) (or array-dim null) &optional)) (let ((n (string-position char str :start start :end end :from-end from-end :key key :test test :test-not test-not))) (cond ((and n (zerop n)) (values +null-string+ (subseq str 1) 0)) (n (values (subseq str 0 n) (subseq str (1+ n)) n)) (t (values str nil nil))))) ;; (split-string-1 #\. (simplify-string "a.b")) ;; => "a", "b", 1 ;; (split-string-1 #\. (simplify-string ".b")) ;; => "", "b", 0 ;; (split-string-1 #\. (simplify-string "a.")) ;; => "a", "", 1 ;; (split-string-1 #\. (simplify-string "ab")) ;; => "ab", NIL, NIL ;; ;; (split-string-1 #\. (simplify-string "a.b.c") :start 2) ;; => "a.b", "c", 3 ;; (split-string-1 #\. "a.b.c" :start 2) ;; => "a.b", "c", 3 (defun split-string (char str &key (start 0) end from-end key (test #'char=) test-not) ;; FIXME_DOCS See also `split-string-1' (declare (type string str) (values list &optional)) (with-tail-recursion ;; FIXME_DOCS note usage case here (labels ((split (str2 buffer) (declare (type string str) (type list buffer)) (multiple-value-bind (start rest n) (split-string-1 char str2 :start start :end end :from-end from-end :key key :test test :test-not test-not) (cond (n ;; FIXME_DESIGN cost of `push-last' onto arbitrary lists? (let ((more (push-last start buffer))) (split rest more))) (t (push-last str2 buffer)))))) (split str nil)))) ;; (split-string #\. (simplify-string "a.b.c.d")) ;; => ("a" "b" "c" "d") ;; (split-string #\. (simplify-string ".b.c.d")) ;; => "" "b" "c" "d") ;; (split-string #\. (simplify-string "abcd")) ;; => ("abcd") ;; (split-string #\. (simplify-string "...")) ;; => ("" "" "" "")
6,233
Common Lisp
.lisp
165
32.769697
80
0.614264
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
a36bd2501fb1d1027aee704d873cc2ada7655af6b25bbb84a047a0dd21f4c893
29,273
[ -1 ]
29,274
common-sym.lisp
thinkum_ltp-main/src/main/lsp/common/common-sym.lisp
;; common-sym.lisp - utilities for Common Lisp Symbols ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (defun* symbol-status (s) ;; Ed. NB: used in PRINT-NAME (SYMBOL STREAM) ;; and in PRINT-LABEL (SYMBOL STREAM) (declare (type symbol s) (values symbol (or package null))) (let ((pkg (symbol-package s))) (cond (pkg (multiple-value-bind (s status) (find-symbol (symbol-name s) pkg) (declare (ignore s)) (values status pkg))) (t (values nil nil))))) ;; (symbol-status 's) ;; => :INTERNAL, #<PACKAGE "LTP/COMMON"> ;; (symbol-status 'print) ;; => :EXTERNAL, #<PACKAGE "COMMON-LISP"> ;; (symbol-status 'ltp/common::print) ;; => :EXTERNAL, #<PACKAGE "COMMON-LISP"> ;; (symbol-status '#:foo) ;; => NIL, NIL (deftype package-designator () '(or symbol string package)) (declaim (inline package-exports-symbols-if package-exports-symbols)) (defun* package-exports-symbols-if (pkg filter) (declare (type package-designator pkg) (type function-designator filter) (values list &optional)) (let ((buffer (make-array 8 :fill-pointer 0 :adjustable t)) (%filter (compute-function filter))) (declare (type (array t (*)) buffer) (type function %filter)) (do-external-symbols (s pkg (coerce buffer 'list)) (when (funcall %filter s) (vector-push-extend s buffer 8))))) (defun* package-exports-symbols (pkg &optional filter) (declare (type package-designator pkg) (type (or function-designator null) filter) (values list &optional)) (cond (filter (package-exports-symbols-if pkg filter)) (t (let ((buffer (make-array 8 :fill-pointer 0))) (declare (type (array t (*)) buffer)) (do-external-symbols (s pkg (coerce buffer 'list)) (vector-push-extend s buffer 8)))))) ;; (package-exports-symbols '#:c2mop)
2,448
Common Lisp
.lisp
66
32.136364
80
0.608291
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
9fac955c21555a9bfb9a88643b095bfc1c5815ac3f46c73e355658d7768f67e0
29,274
[ -1 ]
29,275
common-clos.lisp
thinkum_ltp-main/src/main/lsp/common/common-clos.lisp
;; clos-utils.lisp ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (defmacro call-next-method* (&rest args) (with-symbols (%nmp) `(let ((,%nmp (next-method-p))) (cond (,%nmp (call-next-method ,@args)) (t (values nil nil)))))) (defmacro slot-value* (object slot &optional default) ;; NOTE: This is defined as a macro, so as to allow the compiler to ;; optimize the SLOT-VALUE call, if applicable (with-symbols (o s) `(let ((,o ,object) (,s ,slot)) (cond ((slot-boundp ,o ,s) (values (slot-value ,o ,s) t)) (t (values nil ,default)))))) (defmacro when-slot-init ((instance name sl-names-var) &body body) "WHEN-SLOT-INIT provides a convenience macro for initialization of slot values with effective initial forms, within SHARED-INITIALIZE. The INSTANCE expression should evaluate to an object provided to SHARED-INITIALIZE. The NAME expression should denote a symbol naming the slot to be initialized. This expression will not be evaluated. The SL-NAMES-VAR expression should evalute to the object provided as the second argument to SHARED-INITIALIZE The BODY form will be evaluated under the intersection of the following conditions: 1) when SL-NAMES-VAR effectively indicates that the initial form should be evaluted for the slot NAME[1] within SHARED-INITIALIZE. 2) when the slot NAME is not bound in the INSTANCE Example use case: Slot A-FUNCTION with its value dervied from slot A-FORM as a function compiled in the lexical environment of a method specialized onto SHARED-INITIALIZE (defclass %eval () ((a-form :initarg :a :accessor %eval-a-form :type list) (a-function :accessor %eval-a-function :type function))) (defmethod shared-initialize :after ((instance %eval) sl-names-var &rest initargs &key &allow-other-keys) (when-slot-init (instance a-function sl-names-var) (setf (%eval-a-function instance) (compile nil (%eval-a-form instance))))) (let ((inst (make-instance '%eval :a '(lambda () (+ 2 2))))) (funcall (%eval-a-function inst))) => 4 Footnotes [1] i.e when SL-NAMES-VAR is T or when SL-NAMES-VAR is a CONS and NAME is an element of SL-NAMES-VAR " (with-symbols (%inst %name %sl-names-var) `(let ((,%inst ,instance) (,%name (quote ,name)) (,%sl-names-var ,sl-names-var)) (when (and (or (eq ,%sl-names-var t) (and (consp ,%sl-names-var) (find ,%name (the cons ,%sl-names-var) :test #'eq))) (not (slot-boundp ,%inst ,%name))) ,@body))))
3,287
Common Lisp
.lisp
75
37.066667
80
0.616881
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
a132a9d7a49c6e76b9010f65bf95d2ab40ce0de6421a0cb12dc506e8f607b756
29,275
[ -1 ]
29,276
common-type.lisp
thinkum_ltp-main/src/main/lsp/common/common-type.lisp
;; common-type.lisp ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (deftype file-name () '(or string pathname)) (deftype file-designator () '(or string pathname file-stream)) (deftype class-designator () '(or symbol class)) (deftype type-designator () '(or symbol class (cons symbol t))) (defun* compute-class (ident &optional (errorp t) environment) (declare (type class-designator ident) (values (or class null) &optional)) (etypecase ident (symbol (find-class ident errorp environment)) (class ident))) ;; trivial tests for COMPUTE-CLASS ;; (compute-class 'string) ;; (compute-class (find-class 'ratio)) ;; (compute-class (class-of (1+ most-positive-fixnum))) (deftype unsigned-fixnum () '(integer 0 #.most-positive-fixnum)) ;; Novel but unused #-(and) (defun unsigned-size-of (uint) ;; NB: This does not align to either fixnum or bignum boundaries (declare (type (integer 0) uint) (values (integer 0) &optional)) (values (ceiling (log uint 2)))) ;; (unsigned-size-of (expt 2 8)) ;; => 8 (deftype array-dim () ;; FIXME_DOCS See also `array-length' ;; FIXME_DOCS Application Example - see DO-VECTOR '(mod #.array-dimension-limit)) (deftype array-index () ;; type alias - defined for convenience in applications, cf. aref 'array-dim) (deftype array-length () ;; FIXME_DOCS See also `array-dim' ;; FIXME_DOCS Application Example - see DO-VECTOR '(integer 0 #.array-dimension-limit)) ;; FIXME_DOCS Publication Model TBD ;; FIXME_DOCS Integration with site-local knowledgebases TBD (deftype typed-svector (element-type &optional (dimension '*)) ;; i.e simple vector of a specific element type - convenience defn. `(simple-array ,element-type (,dimension))) (deftype typed-vector (element-type &optional (dimension '*)) ;; i.e vector that may be "Non-simple" - convenience defn. `(array ,element-type (,dimension)))
2,443
Common Lisp
.lisp
62
36.403226
80
0.663421
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
fd4d7b6b0dc48a062cadf43f2f329eb203b65bc458c7a8f6fb549633423fa29e
29,276
[ -1 ]
29,277
common-seq.lisp
thinkum_ltp-main/src/main/lsp/common/common-seq.lisp
;; common-seq.lisp - utilities generalized for Common Lisp sequnces ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (defmacro do-map ((sym whence &optional return-type) &body forms) "Evaluate FORMS for each element of sequence WHENCE bound to symbol SYM Similar to DOLIST and other such standard iterative macros, the FORMS expression will be iteratively evaluated in a lexical environment within a block named NIL. As such, the FORMS may return with RETURN-FROM, as in order to exit from the iterative application of FORMS, before evaluation on all seqeuence elements of WHENCE. The optional RETURN-TYPE, a static symbol denoting the type of the value to return from the corresponding MAP call, will not be evaluated. This macro provides an iterative procedure syntactically similar to DOLIST. By comparison, DO-MAP may be applied onto arbitrary sequence types. Moreover, DO-MAP provides an optional storage for the final return value from each successive evaluation of FORMS, such that the optional storage sequence will provide the return value from the evaluation of DO-MAP. If RETURN-TYPE is the symbol NIL, the return value from each evaluation of FORMS is assumed to be discarded by the implementation, as within the underlying MAP call in this macro's macroexpanded form. Like as with DOLIST, FORMS may be prefixed with any number of DECLARE specifications, such that should be interpreted as local to the function enclosing the FORMS. See also: DO-MAPPED such that provides an alternate return value semantics for iterative evaluation onto DO-MAP." (with-symbols (fn) `(let ((,fn (lambda (,sym) ,@forms))) (block nil ;; NB: If ever using MAP-INTO NIL, below, the implementation ;; may opportunistically skip the eval. ;; ;; When using MAP NIL, instead, the forms are - in no less - ;; evaluated normally. The return value may not be stored, ;; however, for each successive evaluation of the forms onto ;; the sequence construed from evaluation of WHENCE, for ;; the call to MAP NIL (map (quote ,return-type) (the function ,fn) ,whence))))) ;; (do-map (c "Frob") (print (the character c) *debug-io*)) ;; -- (defmacro do-mapped ((sym whence &optional (retv nil retvp)) &body forms) ;; NB: This, in effect, deprecates DO-VECTOR "Evaluate FORMS for each element of sequence WHENCE bound to symbol SYM Similar to DOLIST and other such standard iterative macros, the FORMS expression will be iteratively evaluated in a lexical environment within a block named NIL. As such, the FORMS may return with RETURN-FROM, as in order to exit from the iterative application of FORMS, before evaluation on all seqeuence elements of WHENCE. If a return value expression is provided as RETV, the macroexpanded form will return with that return value expression, after normal exit from the iterative evaluation. If no such return value expression is provided, the macroexpanded form will return a nil values set. If the evaluation of FORMS returns to the block NIL for any element of WHENCE, any return value expression - if provided - will be evaluated subsequent of that return call. Alternately, DO-MAPPED may be evaluated in an environment providing a block other than NIL, such that any evaluation of FORMS may use as the RETURN-FROM block name. This macro provides an iterative procedure syntactically similar to DOLIST. By comparison, DO-MAPPED is implemented with MAP NIL. Thus, it can be used for iteration on vector values or lists. Like as with DOLIST, FORMS may be prefixed with any number of DECLARE specifications, such that should be interpreted as local to the function enclosing the FORMS. This macro is implemented onto DO-MAP." `(progn ;; NB, Assumption: DO-MAP expands to evaluation in BLOCK NIL (do-map (,sym ,whence nil) ,@forms) ,(if retvp retv '(values)))) ;; (do-mapped (c "Frob" 'frob) (print (the character c) *debug-io*)) ;; (do-mapped (c "Frob") (print (the character c) *debug-io*))
4,611
Common Lisp
.lisp
85
50.847059
80
0.732254
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
22ddf8bf0eee6635963c888c730800c973553e551ebb99b35580e170b5b070d3
29,277
[ -1 ]
29,278
ltp-proc.lisp
thinkum_ltp-main/src/main/lsp/common/ltp-proc.lisp
;; ltp-proc.lisp - ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2018 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) ;; NB: Better than trying to mangle "Shell Text" with Emacs' naive comint API (defun run-with-pipe (&rest procspec) "Create a process for each PROCSPEC, ensuring each process' normative output descriptor is bound to the subsequent process' normative input descriptor" ;; Notes ;; ;; * process specifiers and Process Descriptors - T.D (LTP) ;; - NB stderr descriptor & run-with-pipe ;; - TBD Semantics for descripror/file mapping (nin, nout, errout) ;; - NB: Portable I/O Descriptor Mapping (cf. CP/M?? and DOS and MSVC I/O, and POSIX systems) ;; - TBD Environment specifiers; note semantics of DJB envdir ;; - TBD Cmd parameter mapping for process specifiers [X] - Syntax ;; - argv[0] ;; - argv[1+] ;; - TBD Optional/Feature Dispatchable Syntax for Process 'Nice' priority ;; - Executor UID, GID (Principal UID/GID and Process UID/GID - onto POSIX terms) and OS permission models (SUSv4 and other) ;; - [X] Defun LTP/EO:EXTERN-STRING & subsq. See also: TL-Contrib//CL+J ;; - TD: Extenal ABI Environment (??) Specifiers (C, C++, Java, GLib) ;; - [X] TBD: SINGLETON-CLASS (All slots class-allocated; analogy onto Java static forms; impl-specific extensions for specialized storage - SBCL and the libc stack, CCL & subsq.; convenience methods and functional API) ;; - SINGLETON-CLASS application in LTP/EO ABI Environment Definitions ;; - C ABI [SINGLETON-CLASS] ;; - C++ ABI [ABSTRACT-CLASS - Subsume ABIs for LLVM and GCC] ;; - JLib ABI [SINGLETON-CLASS] - Onto CL+J (??) NB Java Embedded Invocation ABI and other JNI API options ;; - GLib ABI [SINGLETON-CLASS] - Onto C ABI ;; - gtkmm ABI [ABSTRACT CLASS] - Onto GLib ABI, C++ ABI ;; - Documentation, nothing too ostentatious in devsrc ;; ;; * Process Objects ;; - process reflection - operns from external to a process' OS environ (vis a vis the UNIX 'ps' util) ;; - process state ;; - process principal actor - host user descriptors - visible UID/GID (POSIX hosts); consult Cygwin documentation (Microsoftq Windows PC systems) ;; - process cmdline ;; - process PID, pgrp, and (may be unavl) controlling TTY ;; - wait, waitpid (POSIX environments) ;; - NB: Prototyping may require a multithreaded Lisp implementation (arm/other machine arch) ;; - process I/O descriptors ;; - dup ... (SBCL, POSIX; LTP EO Protyping @ OS. cf. SUSv4, et.c) (POSIX environments) ;; - streams - bare FD i/o stream, time-annotated FD i/o stream ;; - file I/O and OS process objects ;; - TBD detecting when a stream is open on a file, in "The Lisp" simultaneous to another open FD onto "The same file," in any process initialized from "The Lisp" ;; - TTYs, TERM, and termios ;; - functional API and interactive programming examples ;; ;; * QA - Usage Cases ;; - ltp-proc/ltp-cmd and git orchestration (gen-diffs.el example) ;; - ltp-proc/ltp-cmd and parameterization for XML tools (DocBook, TEI P5, other) ;; - arbitrarily toying around in SLIME (??) ;; - LTP model tools )
3,644
Common Lisp
.lisp
63
55.31746
222
0.668158
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
437c4b3570d5b1df587afa6c07254aaefc52f9876a702308b1578bfce54a14d2
29,278
[ -1 ]
29,279
common-vec.lisp
thinkum_ltp-main/src/main/lsp/common/common-vec.lisp
;; common-vec.lisp - utilities for Common Lisp vectors ;;----------------------------------------------------------------------------- ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (defun* simplify-vector (vector) (declare (type vector vector) (values (simple-array * (*)) &optional)) (coerce vector (list 'simple-array (array-element-type vector) (list (length vector))))) #-(and) (eval-when () (let* ((v-in (make-array 1 :fill-pointer 1 :element-type 'fixnum :initial-element 0)) (v-out (simplify-vector v-in))) (values (array-element-type v-out) (= (length v-in) (length v-out)) (array-has-fill-pointer-p v-out) v-out)) ;; => FIXNUM, T, NIL, #(0) ) ;; TBD: Define a compiler macro for SIMPLIFY-VECTOR such that - via ;; portable functions - would determine the element type and length of ;; the VECTOR, subsequently expanding into a form using those as ;; respectively static (when possible) and otherwise dynamic values. (defmacro do-vector ((elt v &optional return) &body body) ;; NB DEPRECATED - See DO-MAPPED in common-seq.lisp `(do-mapped (,elt ,v ,return) ,@body)) #-(and) (eval-when () (let ((buff (list nil))) (do-vector (c "FOO" (cdr buff)) (push-last c buff))) ;; => (#\F #\O #\O) (let ((buff nil)) (do-vector (c "FOO" buff) (push-last c buff))) ;; => (#\F #\O #\O) (let (buff) (do-vector (c "FOO" buff) (push c buff))) ;; => (#\O #\O #\F) ) ;; see also: common-string.lisp
2,005
Common Lisp
.lisp
53
33.207547
80
0.581095
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
47fbceb10471334d08bc8411ccba5dc5bea31edad373edae8d33246eda3f6750
29,279
[ -1 ]
29,280
common-mop-package.lisp
thinkum_ltp-main/src/main/lsp/mop/common/common-mop-package.lisp
;; mop-pkg.lisp - package definition for info.metacommunity.cltl.utils.mop ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common) (defpackage #:ltp/common/mop (:nicknames #:ltp.common.mop) (:use #:ltp/common #:closer-mop #:cl) #+(or SBCL CMU OpenMCL MCL ALLEGRO) ;; NB: PCL (:shadowing-import-from #+SBCL #:SB-MOP #+CMU #:PCL #+(or OpenMCL MCL) #:CCL #+ALLEGRO #:MOP #:validate-superclass #:standard-generic-function #:defmethod #:defgeneric #:standard-class #+(or OpenMCL MCL) #:standard-method ) #+(or SBCL CMU OpenMCL MCL ALLEGRO) ;; un-shadow symbols shadowed by C2MOP (:export #:validate-superclass ;; NB PCL #:standard-generic-function #:defmethod #:defgeneric #:standard-class #+(or OpenMCL MCL) #:standard-method ;; - class finalization support ;; NB: used in the SINGLETON definition #:class-finalization-condition #:class-finalization-condition-class #:class-finalization-error #:simple-class-finalization-error #:class-finalization-warning #:class-finalization-style-warning #:simple-class-finalization-style-warning #:finalize-reachable #:finalize-reachable-subclass #:finalize-reachable-superclass ) ;; locally defined forms (:export #:validate-class #:least-common-superclass #:instance ) ) ;; Make C2MOP symbols avaialble from this package, ;; except for those shadowed by this package. (let* ((p-dst (find-package '#:ltp/common/mop)) (p-org (find-package '#:closer-mop)) (s (package-shadowing-symbols p-org))) (declare (type cons s)) (labels ((not-shadowed-p (xs) (declare (type symbol xs)) (not (find (the simple-string (symbol-name xs)) s :key #'symbol-name :test #'string=)))) (let ((export (package-exports-symbols-if p-org #'not-shadowed-p))) (declare (type cons export)) (export export p-dst) (values export))))
2,504
Common Lisp
.lisp
76
28.276316
80
0.62966
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
5e11ba7657c78901c75a238e48f9d6f55ac2122757590107d9ad5adce2e6f49a
29,280
[ -1 ]
29,281
spec-mop.lisp
thinkum_ltp-main/src/main/lsp/mop/common/spec-mop.lisp
;; spec-mop.lisp - a demonstration about standard MOP method calls (in-package #:ltp/common/mop) (defgeneric frob-call (a b c)) (macrolet ((mk-specialization (types) (let ((vardecls (mapcar #'(lambda (typ) (list (gensym (symbol-name typ)) typ)) types))) `(defmethod frob-call (,@vardecls) (format *debug-io* "~%FROB-CALL (~s ~s ~s) : ~s ~s ~s" ,@(mapcar #'(lambda (typ) `(quote ,typ)) types) ,@(mapcar #'car vardecls)) (values (quote ,types)))))) (mk-specialization (array fixnum t)) (mk-specialization (string integer t)) (mk-specialization (string fixnum t)) (mk-specialization (array integer t)) (mk-specialization (t fixnum t)) (mk-specialization (t fixnum cons)) (mk-specialization (t integer t)) (mk-specialization (t t symbol)) (mk-specialization (array t t)) (mk-specialization (string t t)) (mk-specialization (t t t)) (mk-specialization (t t list)) (mk-specialization (integer t t)) (mk-specialization (fixnum t t))) (frob-call "Frob" 5 nil) ;; => (STRING FIXNUM T) (frob-call #() 5 nil) ;; => (ARRAY FIXNUM T) (frob-call 5 5 '(a b c)) ;; => (FIXNUM T T) ;; NB: The consing - a generalization of &REST ?? (compute-applicable-methods #'frob-call '("Frob" 5 nil)) ;; ^ it matches the specilization in spec.lisp (compute-applicable-methods #'frob-call '(#() 5 nil)) ;; ^ same (compute-applicable-methods #'frob-call '(5 5 '(a b c))) ;;
1,651
Common Lisp
.lisp
40
32.575
73
0.565625
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
01e7b19cb5055a742b541edc5919d5b02db55714bc3a10fe34a8aef8c3d65521
29,281
[ -1 ]
29,282
finalize.lisp
thinkum_ltp-main/src/main/lsp/mop/common/finalize.lisp
(in-package #:ltp/common/mop) ;; (defgeneric finalize-reachable-subclass (sub super)) (define-condition class-finalization-condition () ((class :initarg :class :reader class-finalization-condition-class))) (define-condition class-finalization-error (error class-finalization-condition) ()) (define-condition simple-class-finalization-error (simple-error class-finalization-error) ()) (define-condition class-finalization-warning (warning class-finalization-condition) ()) (define-condition class-finalization-style-warning (style-warning class-finalization-warning) ()) (define-condition simple-class-finalization-style-warning (simple-style-warning class-finalization-style-warning) ()) (eval-when (:compile-toplevel :execute) (defmacro class-finalization-note (fmt other &rest rest) `(warn 'simple-class-finalization-style-warning :class ,other :format-control ,fmt :format-arguments (list ,other ,@rest)) (values))) ;; -- ;; NB Interface Signatures: Ensure that successful calls to ;; FINALIZE-REACHABLE... will return one non-nil value (defgeneric finalize-reachable (instance seen-classes) ;; NB: An additional method onto this generic function is defined in ;; the SINGLETON system, such that will iterate across direct ;; superclasses of the INSTANCE -- finalizing each direct ;; superclass, when not a forward referenced class, or returning ;; no values from the method. That method will then finalize the ;; INSTANCE itself, and will ensure that any rechable subclass of ;; the INSTANCE is finalized. (:method ((instance forward-referenced-class) (seen-classes list)) (declare (ignore seen-classes)) (class-finalization-note "Cannot finalize foward-referenced class ~S" instance)) (:method ((instance standard-class) (seen-classes list)) (labels ((direct-super-fwd-p (c) (dolist (%c (class-direct-superclasses c) nil) (when (typep %c 'forward-referenced-class) (return %c))))) (let ((fwd (direct-super-fwd-p instance))) (cond (fwd (class-finalization-note "~<Cannot finalize class ~S~> ~ ~< having forward-referenced direct superclass ~S~>" instance fwd)) ((find instance (the list seen-classes) :test #'eq) (values)) (t (finalize-inheritance instance) (values instance))))))) (declaim (ftype (function (standard-object list) (values t)) finalize-reachable))
2,623
Common Lisp
.lisp
62
36.032258
71
0.682802
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
6abd97217942f3ac4a272fdfb9edc26b48cda62ee094c250bb868a1eeb627a91
29,282
[ -1 ]
29,283
spec.lisp
thinkum_ltp-main/src/main/lsp/mop/common/spec.lisp
;; spec.lisp - local prototypes for method specialization onto MOP ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common/mop) ;; rcs -i -U spec.lisp ;; ci spec.lisp ;; ;; co spec.lisp ;; NB: Development paused, while developing ltp-main:src/main/lsp/mt/ ;; - guarding.lisp - WITH-WRITE-GUARD, OBJECT-POOL, GUARDED-FUNCALL ;; - defportable.lisp - DEFSECTION [TBD], DEFSIGNATURE, DEFIMPLEMENTATION ;; ;; NB: With regards to initfunction definition, LTP/COMMON:LAMBDA* avl. ;; ;; TBD: Docstrings w/i a TeX environment ;; -------------------- ;; NB: FIXME WHILE is used only once, below ;; ;; Consider moving these two macros to LTP/COMMON (defmacro while* ((clause &optional retv) &body body) `(loop (or ,clause (return ,retv)) (progn ,@body))) ;; (let ((n 10)) (while* ((not (zerop n)) n) (decf n))) ;; (let ((n 10)) (while* ((not (zerop n)) n) (when (= n 5) (return -10)) (decf n))) (defmacro while (clause &body body) `(while* (,clause) ,@body)) ;; (let ((n 10)) (while (not (zerop n)) (decf n)) n) ;; -------------------- #+NIL ;; unused macro, in this revision (defmacro push-nth (n val whence) (with-symbols (%n %whence nc) `(let ((,%n ,n) (,%whence ,whence)) (declare (type (integer 0) ,%n)) (cond ((zerop ,%n) (setf ,whence (cons ,val ,%whence))) (t (let ((,nc (nthcdr (1- ,%n) ,%whence))) (cond ((consp ,nc) (push ,val (cdr ,nc)) ,%whence) (t (error "~<Cannot PUSH-NTH for index ~D of ~S :~>~ ~< NTH CDR ~D => ~S is not a CONS~>" ,%n ,%whence (1- ,%n) ,nc))))))))) ;; (let ((v (list 'a 'b))) (push-nth 0 t v) v) ;; (setq *print-circle* t) ;; (let ((v (list 'a 'b))) (push-nth 1 t v) v) ;; (let ((v (list 'a 'b))) (push-nth 2 t v) v) ;; FAIL NB: ;; (let ((v (list 'a 'b))) (push-nth 3 t v) v) ;; -------------------- ;; Trivial prototyping for specialized method dispatching ;; with minimal consing in generic function calls ;; FIXME move to spec-proto.lisp and update reference in spec-mop.lisp (defun mk-expandable-vec () (make-array 0 :fill-pointer t :adjustable t)) #+NIL ;; unused here (defun reset-expandable-vec (which) (setf (fill-pointer which) 0)) (eval-when () (let ((specialization-table (mk-expandable-vec)) ;; ^ NB: The call forms actually coerce this to a list #+TD (call-table (mk-expandable-vec)) ) (labels ((mk-specialization-row (args) ;; create and store an analogy to a method specialization (vector-push-extend (coerce (mapcar #'compute-class args) 'simple-vector) specialization-table)) (compute-call-info-for-n (cls specializer-offset known) ;; compute a list of all specializations for parameter of ;; class CLS at OFFSET in the specializable parameter list, ;; for an initial set of KNOWN specializations (let (;;; (start 0) (depth 0) (%known) tmp-1 tmp-2 ) #+DEBUG (warn "OK ~S KNOWN ~S" specializer-offset known) (dolist (c (class-precedence-list cls)) (let ((known known)) (while (progn #+DEBUG (warn "ITERATE ~D ~D ~D" specializer-offset depth (length known)) known) ;; (warn "ITERATE w/ KNOWN ~S" known) (let ((n (position c (the cons known) :key #'(lambda (row) (svref (cdr row) specializer-offset)) :test #'eq ;; :test #'subtypep ;;; :start start ))) (cond (n #+DEBUG (warn "~<GOT ~S for depth ~S of arg nr. ~S : ~>~< ~S~>" n depth specializer-offset (nth n known)) (setq tmp-1 (nthcdr n known) tmp-2 (car tmp-1)) (setf (car tmp-2) (nconc (car tmp-2) (list depth))) (push tmp-2 %known) (setq ;;; start n known (cdr tmp-1) )) ;; else return from while (t ;; (setq known nil) (return))))) ;; WHILE ) (incf depth)) ;; DOLIST #-NIL (values %known) #+NIL (sort %known #'(lambda (inst-a inst-b) ;; generic composite sort-by-maximal-precedence ;; for a generic function of three ;; specializable params (May not be 110% MOP) (destructuring-bind (a-n-1 &optional a-n-2 a-n-3) (car inst-a) (destructuring-bind (b-n-1 &optional b-n-2 b-n-3) (car inst-b) ;; FIXME no type optimization here. ;; When non-nil, each of these is an ;; unsigned fixnum (cond ((and a-n-3 (= a-n-1 b-n-1) (= a-n-2 b-n-2)) ;; NB This is the only case that ;; matters - call this from an ;; upper call, where A-N-3 and ;; A-N-2 := always avl (< a-n-3 b-n-3)) ((and a-n-2 (= a-n-1 b-n-1)) (< a-n-2 b-n-2)) (t (< a-n-1 b-n-1)) ))))) )) (compute-call-info-for (a b c) ;; compute for each arg ;; NB: this labels function can be computed with a template (let ((reachable (mapcar #'(lambda (spec) (cons nil spec)) (coerce specialization-table 'list)))) (dolist (hack (list (list a 0 reachable) (list b 1) (list c 2)) #+NIL (values reachable)) ;; FIXME - Cheap convenience hack for iterative computation ;; onto a static form. Uses needless CONS initialization (destructuring-bind (param-class param-offset &optional (%reachable reachable)) hack #+DEBUG (warn "Call for ~D with ~D reachable" param-offset (length reachable)) (setq reachable (compute-call-info-for-n param-class param-offset %reachable)) #+DEBUG (warn "Call for ~D got reachable ~S" param-offset reachable) )) (sort reachable #'(lambda (inst-a inst-b) ;; generic composite sort-by-maximal-precedence ;; for a generic function of three ;; specializable params (May not be 110% MOP) (destructuring-bind (a-n-1 a-n-2 a-n-3) (car inst-a) (destructuring-bind (b-n-1 b-n-2 b-n-3) (car inst-b) (declare (type (integer 0 #.most-positive-fixnum) a-n-1 a-n-2 a-n-3 b-n-1 b-n-2 b-n-3)) ;; NB: As sparse as this may seem, ;; it work out in tests. (cond ((and (= a-n-1 b-n-1) (= a-n-2 b-n-2)) (< a-n-3 b-n-3)) ((= a-n-1 b-n-1) (< a-n-2 b-n-2)) (t (< a-n-1 b-n-1)) ))))) )) (compute-call-for (a b c) (compute-call-info-for (class-of a) (class-of b) (class-of c))) ) (mk-specialization-row '(array fixnum t)) (mk-specialization-row '(string integer t)) (mk-specialization-row '(string fixnum t)) (mk-specialization-row '(array integer t)) (mk-specialization-row '(t fixnum t)) (mk-specialization-row '(t fixnum cons)) (mk-specialization-row '(t integer t)) (mk-specialization-row '(t t symbol)) (mk-specialization-row '(array t t)) (mk-specialization-row '(string t t)) (mk-specialization-row '(t t t)) (mk-specialization-row '(t t list)) (mk-specialization-row '(integer t t)) (mk-specialization-row '(fixnum t t)) (list (mapcar #'(lambda (row) (cons (car row) (mapcar #'class-name (coerce (cdr row) 'list)))) ;; should be the entire set, sorted (compute-call-for "Frob" 5 nil)) (mapcar #'(lambda (row) (cons (car row) (mapcar #'class-name (coerce (cdr row) 'list)))) ;; should be a sorted complete subset (compute-call-for #() 5 nil)) (mapcar #'(lambda (row) (cons (car row) (mapcar #'class-name (coerce (cdr row) 'list)))) ;; should be a sorted complete subset (compute-call-for 5 5 '(a b c))) ) ;; (setq *print-circle* nil) ;; (pushnew :debug *features* :test #'eq) )) ;; => ;; ((3 0 4) STRING FIXNUM T) ;; ((3 1 4) STRING INTEGER T) ;; ((3 5 4) STRING T T) ;; ((6 0 4) ARRAY FIXNUM T) ;; ((6 1 4) ARRAY INTEGER T) ;; ((6 5 4) ARRAY T T) ;; ((8 0 4) T FIXNUM T) ;; ((8 1 4) T INTEGER T) ;; ((8 5 1) T T SYMBOL) ;; ((8 5 2) T T LIST) ;; ((8 5 4) T T T) ;; , ... ) ;; see also: spec-mop.lisp #+NIL (defgeneric compute-call-lambda (op)) ;; cf COMPUTE-CALL-INFO-FOR... ^ ;; ^ cf. SET-FUNCALLABLE-INSTANCE-FUNCTION ;; ^ nb: May be called whenver a defop-method is added or removed from ;; the generic-op ;; ;; ;; ^ In lieu of MOP COMPUTE-DISCRIMINATING-FUNCTION ;; NB, "Goal:" Do not make any more consing. to determine "applicable methods" ;; ----- #| Ed. NB: The following was defined originally in an effort to provide a complete semantic model for lambda list expressions. It had provided, in version one, a preliminary support for the subset of labmda list syntax as supported in standard generic functions. The API is still in revision. Though it may lastly resemble not much more than a specially typed list-like API, but perhaps it may serve to be of some use in application support. |# (eval-when (:compile-toplevel :execute) (defmacro lform (val) `(load-time-value ,val t))) (defstruct (lambda-element (:constructor)) (name (lform (make-symbol "Unbound Name")) :type symbol :read-only t) (expr-next ;; FIXME: This comprises a redundant slot-vlue except across ;; instances of LAMBDA-KEYWORD nil :type (or lambda-element null) :read-only nil) ) (defmethod print-object ((object lambda-element) stream) (print-unreadable-object (object stream :type t :identity t) (princ (lambda-element-name object) stream))) (defstruct (lambda-keyword (:include lambda-element) (:constructor make-lambda-keyword (name)))) (defstruct (param (:include lambda-element) (:constructor)) (next ;; NB: Next parameter for purposes of call-form eval nil ;; indicating, in effect, "End of lambda list" :type (or param null) ;; NB: Theoretically, PARSE-LAMBDA-SIGNATURE could be updated to ;; allow for this slot to be defined as not read-only. It's been ;; defined as being not read-only, due to how PARAM subclases ;; will be initialized sequentially, within ;; PARSE-LAMBDA-SIGNATURE. ;l ;; As to why this slot is not defined as read-only, remarks in ;; the source form of PARSE-LAMBDA-SIGNATURE may serve to detail ;; that decision. ;; ;; If any application destructively modifies the value of this slot, ;; in any procedure external to PARSE-LAMBDA-SIGNATURE, the ;; behaviors will be unspecified for any later procedures operating ;; as to unparse a lambda list from any LAMBDA-SIGNATURE containing ;; such a modified PARAM. ;; ;; NB: Together with the FIRST-PARAM slot of LABMDA-SIGNATURE, these ;; data structures provide an interface not entirely unlike Lisp LIST ;; objects, insofar as for LIST CAR and CDR accessors. Somewhat ;; unlike CDR, however, the PARAM-NEXT accessor returns a PARAM ;; object, as whenever it does not return NIL. ;; ;; One might consider that this may be fairly trivial, for any data ;; sturctures that may be defined initially as being singularly ;; linked. :read-only nil) ) ;; FIXME: Although this API might be expanded beyond any point of ;; obvious utility, there may be support provided for storage of the ;; actual lambda list keywords symbols within the effective sequence of ;; PARAM-NEXT values. Otherwise, it may be impossible to maintain an ;; accurate, parsed representation of such as: ;; - &KEY without any subsequent keyword parameters ;; - &OPTIONAL without any subsequent optional parameters ;; ;; Furthermore, such an addition should serve to simplify the unparsing. ;; ;; Albeit, this API then would provide something very much like lambda ;; lists in a list format, albeit with some additional semantic ;; properties stored for any later application. (defstruct (initialized-param (:include param) (:constructor)) ;; NB: Usage by extension vis a vis CL:&KEY, CL:&OPT params (initform (lform (make-symbol "Unbound Initform")) :type t :read-only t) (initfunction ;; NB: NIL in this slot implies that the initorm slot can be ignored nil :type (or function null) :read-only t) ;; NB this needs a value-p-p slot, as the structure slot cannot be unbound (value-p-name (lform (make-symbol "Unbound Value-P-Name")) :type symbol :read-only t) (value-p-p ;; NB: To be construed as indicating that the value-p-name was ;; provided from evaluation of source forms, rather than being ;; initialized by default as in PARSE-LAMBDA-SIGNATURE ;; (May be removed in a subsequent changeset) nil :type boolean :read-only t)) (defstruct (param-subset (:constructor)) (members (lform (make-array 0)) :type simple-vector :read-only t)) ;; -- (defstruct (required-param (:include param) (:constructor make-required-param (name)))) (defstruct (required-subset (:include param-subset) (:constructor %mk-required-subset (members)))) (defstruct (optional-param (:include initialized-param) (:constructor make-optional-param (name &key ;; NB: Assuming the environment for the ;; initfunction is "Just handled," portably, ;; in applications. also for KEY-PARAM initform initfunction value-p-name value-p-p)))) (defstruct (optional-subset (:include param-subset) (:constructor %mk-optional-subset (members)))) (defstruct (rest-param (:include param) (:constructor make-rest-param (name &optional (kind (quote &rest))))) (kind (quote &rest) :type symbol ;; NB narrower type (member &rest &body) ; typically :read-only t)) (defstruct (key-param (:include initialized-param) (:constructor make-key-param (name &key initform initfunction value-p-name value-p-p (keyword-name (intern (symbol-name name) :keyword))))) (keyword-name (lform "Unbound Keyword Name") :type symbol :read-only t)) (defstruct (key-subset (:include param-subset) (:constructor %mk-key-subset (members &optional allow-other-keys))) (allow-other-keys nil :type boolean :read-only t)) #+NIL ;; unused as yet - see annotations, subsq. (defstruct (aux-param (:include initialized-param) (:constructor make-aux-param (name #:FIXME_INIT)))) (defstruct (other-subset (:include param-subset) (:constructor %mk-other-subset (members)))) (defstruct (lambda-signature (:constructor %mk-lambda-signature (&key lambda-list ((:first first-param) nil) ((:required required-subset) nil) ((:optional optional-subset) nil) ((:keyword key-subset) nil) ((:other other-subset) nil) ((:rest rest-param) nil) ))) ;; Ed. NB: See remarks about the design of this lambda list parser ;; model, in the PARSE-LAMBDA-SIGNATURE source form (first-param ;; FIXME: May actually be a LAMBDA-ELEMENT nil :type #+NIL param #-NIL lambda-element :read-only t) (lambda-list ;; NB: Redundant storage, but usable for PRINT-OBJECT methods (lform (list (make-symbol "Unbound Lambda List"))) :type list :read-only t) (required-subset nil :type (or required-subset null) :read-only t) (optional-subset nil :type (or optional-subset null) :read-only t) (key-subset nil :type (or key-subset null) :read-only t) (rest-param nil :type (or rest-param null) :read-only t) (other-subset ;; set of param-typed objects e.g for representation of &aux, &env, ;; &whole and various implementation-specific expressions ;; ;; cf. OTHER-HANDLER application (below) ;; ;; Of course, &ENV and &WHOLE would represent other-subset parameters ;; of some singular meaning - there being at most one of those ;; parameters available in each of some standard lambda syntaxes. ;; ;; For purposes both of brevity, this LAMBDA-SIGNATURE class will not ;; provide singular storage for &ENV and &WHOLE parameters. While it ;; does provide singular storage for the &REST parameter of a lambda ;; list, it was not believed - at the time of this implementation - ;; that &ENV and &WHOLE parameters represented any sufficiently ;; generalized feature of lambda-list syntax, sufficient for such ;; parameters to be represented individually, within a ;; LAMBDA-SIGNATURE class. The existence of those parameters, in a ;; LABMDA-SIGNATURE, may be determined either by parsing the ;; OTHER-SUBSET directly, or by parsing in a manner beginning at the ;; LAMBDA-SIGNATURE-FIRST-PARAM then to each PARAM-NEXT until either ;; arriving at the respective PARAM or else, arriving at a NULL ;; PARAM-NEXT. ;; ;; ---- ;; Additional Documentation Note: ;; ;; In so far, this lambda list parser model provides a direct support ;; only for the generalized lambda list syntax supported in standard ;; generic functions. ;; ;; It was thought that this model should be designed to permit for ;; reusability and extensibility. As such, the original design of ;; this parser model has been updated to provide the OTHER-SUBSET ;; field, for storage of arbitrary lambda list parameters within a ;; parsed LAMBDA-SIGNATURE. Moreover, this design has been updated to ;; provide a semantics of singly-linked lists for lambda PARAM ;; objects, such that may serve to provide a more simplified approach ;; for LAMBDA-SIGNATURE unparsing. ;; ;; nil :type (or other-subset null) :read-only t) ;; TBD in extensions: ;; - AUX-SUBSET - specifically for anonymous lambdas & defun forms ;; - ENV-PARAM - specifically for macro lambda forms ;; - WHOLE-PARAM - cf. SETF forms and similar ;; ... and interop. for implementation-specific lambda forms ;; ;; NB/Topic: User Interfaces & Accessibility for Lambda Model Definitions ;; ;; NB: This was originally defined for supporting implementation of ;; GENERIC-OP, begeinning with a method onto the locally defined generic ;; function, COMPUTE-FTYPE-PARAMS-TYPE. As such, the syntax supported ;; with this model, in its baseline features, was limited to the ;; lambda list syntax supported for standard generic functions. As a ;; happy side effect, this model supports a generlaized lambda list ;; syntax such that may be fairly common across specialized lambda ;; list kinds. ;; ;; Insofar as providing an OTHER-SUBSET semantics, together with the ;; addition of the optional OTHER-HANDLER argument for each of the ;; functions, PARSE-LAMBDA-SIGNATURE and UNPARSE-LAMBDA-SIGNATURE, this ;; parser model now provides a methodology for extending the existing ;; support to allow for other lambda list syntaxes - assuming, ;; specialized extensions of the PARAM class, correspondingly, and ;; some specific behaviors in the OTHER-HANDLER functions for each of ;; those call forms. ) (defmethod print-object ((object lambda-signature) (stream t)) (print-unreadable-object (object stream :type t :identity t) (princ (lambda-signature-lambda-list object) stream))) ;; ---- (declaim (ftype (function (lambda-signature &optional (or null function) (or null function) (or null function)) (values list &optional)) unparse-lambda-signature)) ;; NB: COMPUTE-CALL-FORM cf. GENERIC-OP - Generic prototype defined, below (defun unparse-lambda-signature (signature &optional other-unparser other-initialize other-finalize) ;; FIXME: Needs further update ;; ;; - Empty &KEY and &OPTIONAL subsets not being correctly unparsed. ;; ;; - The present LAMBDA-SIGNATURE definition may need to be updated ;; for those special conditions of syntax ;; NB: OTHER-UNPARSER - if provided, a function accepting two ;; arguments, i.e a PARAM object not handled below, and the SIGNATURE ;; object itself. The function should return a list of expressions ;; (optionally null) such that will be suffixed to the computed ;; lambda-list, for representing each respective PARAM received by the ;; function. ;; ;; The OTHER-UNPARSER function, if provided, should maintain internal ;; state as to ensure that any appropriate lambda-list-keyword symbol ;; are returned. [FIXME: Untested] ;; ;; NB: OTHER-INITIALIZE, OTHER-FINALIZE (let* ((buf (make-array 0 :fill-pointer 0 :adjustable t)) context (param (lambda-signature-first-param signature)) expr) ;; NB: The lambda-list form returned by UNPARSE-LAMBDA-SIGNATURE ;; may not be syntactically equivalent to the original lambda list ;; provided to PARSE-LAMBDA-SIGNATURE. ;; ;; The original lambda list can be retrieved for purposes of ;; reflection, analysis, etc, via the accessor function, ;; LAMBDA-SIGNATURE-LAMBDA-LIST (labels ((add-to-buffer (elt) (vector-push-extend elt buf)) (add-kwd (kwd) (add-to-buffer (lambda-keyword-name kwd))) (add-param (param) (add-to-buffer (param-name param))) (unparse-optional-param (param) (list (param-name param) (optional-param-initform param) (optional-param-value-p-name param))) (unparse-key-param (param) (let ((name (param-name param)) (key (key-param-keyword-name param))) (list (list key name) (key-param-initform param) (key-param-value-p-name param)))) (update-context (which) (unless (eq context which) (setq context which)))) ;; FIXME - need to handle empty KWD members, empty optional ;; members separate to the following ... but this would require ;; further update to the LAMBDA-SIGNATURE model, for so much as to ;; ensure that the &KEY or &OPTIONAL with-no-contextual-args ;; condition will be modeled from the lambda list. (when other-initialize (funcall (the function other-initialize) signature)) (loop (typecase param (null (return)) (required-param (add-param param)) (optional-param (update-context (quote &optional)) (add-to-buffer (unparse-optional-param param))) (rest-param (update-context (rest-param-kind param)) (add-param param)) (key-param ;; FIXME - need further processing here - initform etc ;; ;; FIXME - Understanding that initforms are not supported in ;; some lambda list syntaxes, this model should be ;; accompanied with forms for validating any parsed ;; LAMBDA-SIGNATURE onto any single lambda list syntax. (update-context (quote &key)) (add-to-buffer (unparse-key-param param)) ;; NB: &ALLOW-OTHER-KEYS is is handled as a plain ;; LAMBDA-KEYWORD now, insofar as for lambda signature ;; unparsing. It's also stored in the KEY-SUBSET of any ;; LAMBDA-SIGNATURE having a non-empty set of explicit ;; &KEY params (lambda-keyword (add-kwd param)) ;; FIXME - the other-unparser support needs testing, for ;; this unparser function (t (when other-unparser (mapcar #'add-to-buffer (funcall (the function other-unparser) param signature))))) (let ((next (lambda-element-expr-next param))) (setq param next))) (setq expr (coerce buf 'list)) (when other-finalize (funcall (the function other-finalize) expr signature)) (values expr)))) (define-condition lambda-list-syntax-error (simple-error) ((lambda-list :initarg :lambda-list :reader error-lambda-list)) (:report (lambda (c s) (apply #'format s (concatenate 'simple-string "~<" (simple-condition-format-control c) ":~>~< ~S~>") (append (simple-condition-format-arguments c) (list (error-lambda-list c))))))) (defmacro lambda-list-syntax-error (which fmt &rest args) `(error 'lambda-list-syntax-error :format-control ,fmt :format-arguments (list ,@args) :lambda-list ,which)) ;; (lambda-list-syntax-error '(n/a) "Unsupported N/A in lambda pseudo-form") (declaim (ftype (function (list &optional (or null function) (or null function) (or null function)) (values lambda-signature &optional)) parse-lambda-signature)) (defun parse-lambda-signature (lambda-list &optional other-parser other-initialize other-finalize) ;; ;; NB: OTHER-PARSER - if provided, a function accepting three ;; arguments: ;; ;; - a lambda-list keyword symbol, or a symbol or list type PARAM ;; expression -- namely, as not "otherwise handled", below. ;; ;; - a "context" symbol, denoting the context in which the expression ;; in the first argument has been parsed ;; ;; e.g when &aux is parsed after &rest, this second argument's ;; value would be the symbol CL:&REST, while the first argument's ;; value would be the symbol &AUX. Subsequently, each "aux ;; parameter" would be provided as the first argument to the ;; function, with the second argument's value being the symbol ;; CL:&AUX ;; ;; - the original LAMBDA-LIST expression ;; ;; - NB: This value should not be destructively modified. It may be ;; assumed to represent an object of a consistent identity, onto ;; EQ and SXHASH, throughout the duration of each call to ;; PARSE-LAMBDA-SIGNATURE ;; ;; Should return either a PARAM object - such that this function, ;; PARSE-LAMBDA-SIGNATURE, will then add to the OTHER-SUSBET ;; internally -- or return the value NIL, indicating that no value is ;; to be stored for the symbol that was provided to the function's ;; first argument. ;; ;; NB: OTHER-INITIALIZE, OTHER-FINALIZE ;; ;; TBD: Storage for OTHER-SUBSET, and ordering when unparsing to ;; produce a lambda list syntactically equivalent to the original, ;; unparsed list expression. ;; ;; - Concept: OTHER-SUBSET-SET as a "Meta-subset" of LAMBDA-SIGNATURE ;; containing a sequence of OTHER-SUBSET ... the latter, defined ;; with slots PREVIOUS NEXT => SYMBOL for purpose of ordering in ;; producing the portable, "other list" representation of an ;; arbitrary lambda list expression. ;; ;; ... OR: one could just store a simple vector under an OTHER-SUBSET ;; slot, and futhermore ensure the use of an OTHER-PARAM-NEXT ;; slot. The "Unparsing", in either approach to storage: TBD ;; ;; NB: at that point, the use of -NEXT slots may serve to make the ;; vector storage of PARAM objects more or less redundant. However, ;; this existing subset-oriented storage will be retained, generally ;; for purpose of caching of operative subsets of lambda list ;; parameters, excepting the genrealized storage in the OTHER-SUBSET ;; ;; see also: UNPARSE-LAMBDA-SIGNATURE ;; ;; NB: The OTHER-PARSER function may be for adding support for &AUX, ;; &WHOLE, &ENV, and implementation-specific lambda list keywords - ;; extesionally, portably, & without any requirement for rewriting the ;; function, PARSE-LAMBDA-SIGNATURE. ;; Ed. NB: Ad hoc, but practical (let (first required-subtree keyword-subtree optional-subtree other-subtree allow-other-keys rest-p rest-param last param-last context signature) ;; NB: see also: LTP/COMMON:DEFUN* ;; FIXME: Add intrinsic VALUE-P-NAME initialization for any ;; INITIALIZED-PARAM without a user-provided value-p name (macrolet ((update-for-element (elt) `(progn (unless first (setq first ,elt)) (when last (setf (lambda-element-expr-next last) ,elt)) (setq last ,elt) (when (param-p ,elt) (when (param-p param-last) (setf (param-next param-last) ,elt)) (setq param-last ,elt)))) (mk-v-p-name (name sfx) `(make-symbol (concatenate 'simple-string (symbol-name ,name) ,sfx))) (mkerror (msg &rest args) `(lambda-list-syntax-error lambda-list ,msg ,@args)) (mk-buffer (&optional (len 0)) `(make-array ,len :fill-pointer ,len :adjustable t)) (subtree-p (which) `(and ,which (not (zerop (length (the (array t (*)) ,which)))))) (add-to-buffer (elt which) ;; NB: This model may be updated to use a read-only ;; PARAM-NEXT slot. Albeit, the indirection required ;; for that change may seem a little less easy to ;; "Parse" from the source definition. ;; ;; It would, furthermore, require some changes in the ;; structure of this function's definiion -- as due to ;; a deferred "add to buffer" semantics, such as may be ;; implemented in such update. `(progn ;; NB: Evaluation of either ELT or WHICH will not ;; cause side-effects, for how this macro is called ;; within this function. (update-for-element ,elt) (cond (,which (vector-push-extend ,elt ,which)) (t (setq ,which (mk-buffer 1)) (setf (aref ,which 0) ,elt)))))) (labels ((add-to-required-buffer (elt) (add-to-buffer elt required-subtree)) (add-to-optional-buffer (elt) (add-to-buffer elt optional-subtree)) (add-to-key-buffer (elt) (add-to-buffer elt keyword-subtree)) (add-to-other-buffer (elt) (add-to-buffer elt other-subtree)) (set-state (which) (cond ((eq context which) (mkerror "Multiple subsequent ~S keywords in lambda list" which)) (t (let ((new (make-lambda-keyword which))) (update-for-element new) (setq context which))))) (simplify (which) (coerce (the (array t (*)) which) 'simple-vector)) (process-symbol-expr (elt) (declare (type symbol elt)) (case elt (&optional (set-state elt) (cond (optional-subtree (mkerror "Lambda list contains more than one &OPTIONAL symbol")) (t (setq optional-subtree (mk-buffer 0))))) (&key (set-state elt) (cond (keyword-subtree (mkerror "Lambda list contains more than one &KEY symbol")) (t (setq keyword-subtree (mk-buffer 0))))) (&allow-other-keys ;; FIXME: If no explicit &REST parameter is specified, ;; while &ALLOW-OTHER-KEYS is specified, create a ;; REST-PARAM from an uninterned symbol and ensure ;; that that is stored before the first KEY-PARAM in ;; the parsed lambda list. ;; ;; Subsquently, COMPUTE-CALL-FORM may then use the ;; intrinsic &REST param for maintaining call-state ;; across the effective variadic call. (unless keyword-subtree (mkerror "Lambda list contains &ALLOW-OTHER-KEYS ~ other than after &KEY symbol")) (when allow-other-keys (mkerror "Lambda list contains more than one ~ &ALLOW-OTHER-KEYS symbol")) (setq allow-other-keys t) (set-state elt)) (&rest ;; NB: &BODY not handled here. ;; ;; Handling for &BODY may be defined as to reuse the ;; exixting REST-PARAM class (when rest-p (mkerror "Lambda list contains more than one &REST symbol")) (setq rest-p t) (set-state elt)) ((position elt other-keywords :test #'eq) (process-other-expr elt)) (t ;; ---- proceed under the current parser state ---- (case context ((nil) (add-to-required-buffer (make-required-param elt))) (&optional (add-to-optional-buffer (make-optional-param elt :initform nil ;; NB: No :initfunction initialized here :value-p-name (mk-v-p-name elt "-p-default")))) (&key ;; FIXME check for &optional / warn on ambiguity (add-to-key-buffer (make-key-param elt :initform nil ;; NB: No :initfunction initialized here :value-p-name (mk-v-p-name elt "-p-default") :keyword-name (intern (symbol-name elt) :keyword)))) (&rest (when rest-param (mkerror "Lambda list contains more than one ~ &REST parameter")) (setq rest-param (make-rest-param elt context)) (update-for-element rest-param)) (t (process-other-expr elt)))))) (process-cons-expr (elt) (declare (type cons elt)) (cond ((eq context (quote &optional)) (destructuring-bind (param-name &optional initform (value-p nil v-p-p)) elt (let ((initfunction (when initform ;; FIXME: Compile the initfunction ;; ;; NB: After a review of the behaviors ;; of GET-SETF-EXPANSION this function ;; does not implement any special ;; handling for compilation environments ;; in LAMBDA definitions (coerce `(lambda () ,initform) 'function)))) (unless v-p-p (setq value-p (mk-v-p-name param-name "-p-default"))) (add-to-optional-buffer (make-optional-param param-name :initform initform :initfunction initfunction :value-p-name value-p :value-p-p v-p-p))))) ((eq context (quote &key)) (destructuring-bind (key-first &optional initform (value-p nil v-p-p)) elt (let ((key-name (etypecase key-first (symbol (intern (symbol-name key-first) (lform (find-package :keyword)))) (cons (car key-first)))) (param-name (etypecase key-first (symbol key-first) (cons (cadr key-first)))) (initfunction (when initform ;; FIXME: Compile the initfunction ;; ;; NB: After a review of the behaviors ;; of GET-SETF-EXPANSION this function ;; does not implement any special ;; handling for compilation environments ;; in LAMBDA definitions (coerce `(lambda () ,initform) 'function)))) (unless v-p-p (setq value-p (mk-v-p-name param-name "-p-default"))) (add-to-key-buffer (make-key-param param-name :keyword-name key-name :initform initform :initfunction initfunction :value-p-name value-p :value-p-p v-p-p))))) (t (process-other-expr elt)))) (process-other-expr (elt) (cond (other-parser (funcall (the function other-parser) elt context lambda-list)) (t ;; FIXME: Improve this error's message text (mkerror "Syntax not supported"))))) (when other-initialize (funcall (the function other-initialize) lambda-list)) (do-cons (elt rest lambda-list) (unless (listp rest) (mkerror "Syntax not supported - not a well formed list")) (typecase elt (symbol (process-symbol-expr elt)) (cons (process-cons-expr elt)) (t (process-other-expr elt)))) ;; TBD: ELSEWHERE, emit a style-warning for a GENERIC-OP of no ;; specializable parameters (setq signature (%mk-lambda-signature :lambda-list lambda-list :first first :required (when (subtree-p required-subtree) (%mk-required-subset (simplify required-subtree))) :optional (when (subtree-p optional-subtree) (%mk-optional-subset (simplify optional-subtree))) ;; NB: Similar to OPTIONAL-SUBTREE, for any initial specification ;; of &KEY or &OPTIONAL with an empty KEY or OPTIONAL param ;; subset, the respective &KEY or &OPTIONAL keyword wiill be ;; stored singularly in the unparse-vector of the ;; LAMBDA-SIGNATURE, rather than in the effective ;; call-form vector of the same (cf. PARAM-NEXT) :keyword (when (or allow-other-keys (subtree-p keyword-subtree)) (%mk-key-subset (simplify keyword-subtree) allow-other-keys)) :other (when (subtree-p other-subtree) (%mk-other-subset (simplify other-subtree))) :rest rest-param)) (when other-finalize (funcall (the function other-finalize) signature lambda-list)) (values signature) )))) (eval-when () ;; test for a limited subset of lambda list syntax (defparameter *l* (parse-lambda-signature '(a b &optional q &rest other &key frob &allow-other-keys))) (unparse-lsignature-expr-next *L*) (values (lambda-signature-first-param *l*) ;; (lambda-signature-required-subset *l*) ;; (lambda-signature-optional-subset *l*) (lambda-signature-rest-param *l*) ;; (lambda-signature-key-subset *l*)) ) ;; Test the mechanical unparser ;; ;; NB: In lieu of simply retrieving the cached lambda list, this more ;; or less serves as something of a partial consistency check onto the ;; LAMBDA-SIGNATURE framework (unparse-lambda-signature *l*) (unparse-lambda-signature (parse-lambda-signature '(a b &optional q &rest other &key frob &allow-other-keys))) (unparse-lambda-signature (parse-lambda-signature ;; FIXME: Update parser for intrinsic value-p-name initialization ;; when none is provided by the user '(a b &optional q &rest other &key frob (tbd 12312)))) (unparse-lambda-signature (parse-lambda-signature ;; FIXME: Update parser for intrinsic value-p-name initialization ;; when none is provided by the user '(a b &optional q &rest other &key frob ((:key tbd) 12312 key-p)))) (lambda-signature-first-param (parse-lambda-signature ;; FIXME: Update parser for intrinsic value-p-name initialization ;; when none is provided by the user '(a b &optional q &rest other &key frob (fixme tbd)))) ;; FIXME - empty key set was not being unparsed correctly (API updated) ;; (describe (parse-lambda-signature '(a b &optional q &rest other &key))) ;; -- (defun unparse-lsignature-expr-next (signature) (let* ((first (lambda-signature-first-param signature)) (next first) (bkt (make-array 0 :fill-pointer 0 :adjustable t))) (while next (vector-push-extend next bkt) (setq next (lambda-element-expr-next next))) (coerce bkt 'simple-vector))) (unparse-lsignature-expr-next (parse-lambda-signature '(&optional q &rest other &key)) ) (defun unparse-lsignature-param-next (signature) (let* ((first (lambda-signature-first-param signature)) (next first) (bkt (make-array 0 :fill-pointer 0 :adjustable t))) (while next ;; NB: this assumes that FIRST is a PARAM (vector-push-extend next bkt) (setq next (param-next next))) (coerce bkt 'list))) ;; some tests for the PARAM-NEXT handling in PARSE-LAMBDA-SIGNATURE (unparse-lsignature-param-next (parse-lambda-signature '(a &optional q &rest other &key)) ) ;; => (<<REQUIRED-PARAM A>> <<OPTIONAL-PARAM Q>> <<REST-PARAM other>>) (param-next (car (unparse-lsignature-param-next (parse-lambda-signature '(a &optional q &rest other &key))))) ;; => <<OPTIONL-PARAM Q>> ;; -- test for parsing of empty param subsets (defparameter *l2* (parse-lambda-signature '(a &optional &rest other &key))) (lambda-signature-optional-subset *l2*) ;; => NIL (lambda-signature-key-subset *l2*) ;; => NIL (unparse-lambda-signature *l2*) ;; => <equivalent lambda list> ;; -- test some failure cases (parse-lambda-signature '(&optional q &optional dnw &rest other &key)) (parse-lambda-signature '(&key q &key dnw &rest other &key)) (parse-lambda-signature '(&optional q &key dnw &optional dnw-2)) (parse-lambda-signature '(&key q &optional dnw &key dnw-2)) (parse-lambda-signature '(&key q &optional dnw &allow-other-keys)) ;; ^ FIXME should err ) ;; -- Partial MOP Interop (defclass generic-callable (funcallable-standard-object) ()) (defclass generic-op (generic-callable #+NIL standard-generic-class) ;; NB: See remarks, below, concerning GENERIC-METHOD ((name :reader generic-op-name ;; :access (:read :write-once) :type symbol) (signature :reader generic-op-signature ;; :access (:read :write-once) :type lambda-signature) (methods ;; :type simple-vector ;; :access (:read :write) :accessor %generic-op-methods) (cached-methods ;; NB: This would include any set of methods defined for purpose of ;; caching for effective method call-forms, for parameter sets to ;; which no single, directly specialized method would apply. ;; ;; NB: Similar to memoization in MOP, this set of cached methods may ;; be -- as a set -- made effectively invalid when any GENERIC-METHOD ;; is added to or removed to the GENERIC-OP. ;; ;; :type simple-vector ;; :access (:read :write) :accessor %generic-op-cached-methods) #+TBD (specialized-params ;; NB: Towards providing for definitions of a GENERIC-OP function ;; such that any GENERIC-METHOD defined to the GENERIC-OP would be ;; specialized onto a subset of required parameters to the GENERIC-OP ;; ... with a semantics not otherwise differing from a GENERIC-OP ;; such that would be specialized on every required parameter to the ;; GENERIC-OP ;; ;; NB: This protocol may define it as an error, to define a ;; GENERIC-OP without at least one specializable parameter. ;; :type simple-vector :reader %generic-op-specialized-params) ) ;; It reuses this from CLOS, NB: (:metaclass funcallable-standard-class)) (declaim (ftype (function (generic-op) (values cons &optional)) generic-op-lambda-list)) (defun generic-op-lambda-list (genop) ;; NB: This returns a cached lambda-list, such that may not be ;; completely representative of every lambda list used in any single ;; GENERIC-OP call form. ;; ;; See also: Other annotations, in this source file. (cond ((slot-boundp genop 'signature) (the cons (lambda-signature-lambda-list (generic-op-signature genop)))) (t (error "No lambda-signature initialized for ~S" genop)))) (defclass generic-method (generic-callable #+nil standard-method) ;; NB: Defininig this as a subclass of STANDARD-METHOD would be, in ;; short terms, "A stretch." However it may serve to emulate some ;; generic qualities of the STANDARD-METHOD class, and may whatsoever ;; emulate any quality of MOP in any application, but considering the ;; liberties that this protocol may be said to take with regards to ;; standard MOP conventions, this class should not actually be defined ;; as a subclass of STANDARD-METHOD, here. () (:metaclass funcallable-standard-class)) (defgeneric generic-op-method-class (generic-op) (:method ((genop generic-op)) (declare (ignore genop)) ;; structurally similar to GENERIC-FUNCTION-METHOD-CLASS ;; ;; NB: This standard-method does not use any accessor onto the GENOP (find-class 'generic-method))) ;; --- (defgeneric compute-ftype-params-type (genop) #+FIXME (:method ((genop generic-op)) (let ((signature (generic-function-lambda-signature genop))) ;; see also: defun* - concerning partially derived FTYPE procalmations ;; ;; Note the function PARSE-LAMBDA-SIGNATURE. defined above ;; ;; - would not be needed here, directly, for a GENERIC-OP ;; in which (GENERIC-OP-SIGNATURE GENOP) ;; is assumed to return a LAMBDA-SIGNATURE ;; ;; - may be of some use if implementing a method for this ;; function, specialized directly onto STANDARD-GENERIC-CLASSa ;; ;; - NB handle the LAMBDA-SIGNATURE-REQUIRED-SUBSET mainly, ;; with special processing as per e.g methods defined to the ;; GENOP at the time when this function is called. ;; ;; - TBD Provide some manner of caching and update mechanism, such ;; that may serve to ensure that any new ftype declration has ;; all specializable parameters specified as subtypep their ;; specification in any previous declaration. Failing that, ;; consider using CERROR as to permit any incompatible ftype ;; declaration, after notification & #"CONTINUE ;; ;; - FIXME also enure that this is called in the compiler ;; environment, when defining slot accessors onto an extension of ;; STANDARD-GENERIC-FUNCTION - to which, the set of definitive ;; ftype declarations may be cached and emitted at some point ;; after the top-level ENSURE-CLASS call. See also, the ;; SINGLETON definition in LTP. NB: DEFCLASS-LIKE-DEFSTRUCT ))) (defgeneric compute-ftype-values-type (genop) (:method ((genop generic-op)) `(values t))) (defgeneric compute-ftype (genop) (:method ((genop generic-op)) `(ftype (function ,(compute-ftype-params-type genop) ,(compute-ftype-values-type genop)) ,(generic-function-name genop)))) ;; --- #| Topic: Initialization of Instance-Specialized Callback Functions, via Methods Generalized on Class of Instance - Usage Case: COMPUTE-CALL-FORM for runtime evaluation of function calls to a GENERIC-OP - TBD: Generalized interoperability onto MOP conventions. - COMPUTE-EFFECTIVE-METHOD - MAKE-METHOD-LAMBDA - CALL-METHOD - Note the usage of an intrinsic CONS, throughout MOP, for representing the arguments to the original generic function call. Although this may be considered as a generalization, roughly, onto variadic &REST semantics and although the original "Argument list" -- as produced, one assumes, from the initial function call -- may be reused throughout the numerous method calls of the veritable "Standard MOP machine," but is this truly an optimal methodology? requiring that a new CONS will be produced, for every call to a generic function? and rather, using two CONS - one for the initial sequence of arguments to the original function call, and one that would be produced within MOP, as an ephemeral container for methods computed dynamically, for the list-based method dispatching protocol? |# #+nil (defun frob-call (a b &key (c nil c-p) (d nil d-p)) (labels ((frob-call-internal (a b &key (c nil c-p) (d nil d-p)) (warn "FROB-CALL called with ~S ~S (~S ~S) (~S ~S)" a b c c-p d d-p) )) (apply #'frob-call-internal ;; TBD: CONS usage in implementation of APPLY (??) a b (nconc (when c-p (list :c c)) (when d-p (list :d d))) ))) ;; (frob-call 1 2 :c 3 :d 4) ;; (frob-call 1 2 :d 4) ;; (frob-call 1 2 :c nil) (declaim (ftype (function (lambda-signature) (values boolean &optional)) call-form-variadic-p)) ;; NB: Call-Wrapping for GENERIC-OP and GENERIC-METHOD ;; ;; TBD: GENERIC-METHOD Specialization, static GENERIC-METHOD function ;; definitions, static GENERIC-OP function definitions -- simply, ;; in a manner of CLOS-oriented "Call wrapping," with support for a ;; lexically scoped CALL-SUPER function, not in all ways like ;; CALL-NEXT-METHOD -- and binidings onto FUNCALLABLE-INSTANCE ;; ;; In effect, it should be possible for the method function of any ;; defined GENERIC-METHOD to be called directly, as a function with a ;; lambda list compatible to that of the generic function to which the ;; method is defined. (defun call-form-variadic-p (signature) ;; FIXME only used once, so far (macrolet ((init-p (whence) `(and (,whence signature) t))) (or (init-p lambda-signature-optional-subset) (init-p lambda-signature-key-subset) #+TBD (init-p lambda-signature-other-subset) ) ;; NB also VARIADIC-P when null &KEY subset but &ALLOW-OTHER-KEYS ;; ;; NB: VARIADIC-P when any REST-PARAM, in precedence to any KEY ;; subset or &KEY with &ALLOW-OTHER-KEYS )) (defgeneric unparse-param-for-call (param whence) ;; NB: Extensions with regards to OTHER-SUBSET of a LAMBDA-SIGNATURE ;; should define methods onto this function, or errors may result ;; during UNPARSE-FOR-CALL (:method ((param required-param) (whence generic-callable)) (declare (ignore whence)) (required-param-name param)) ;; NB: Effectively variadic params must return a list (:method ((param optional-param) (whence generic-callable)) ;; NB: Used directly for OPTIONAL-PARAM, ;; and used via "dispatch to super" call for KEY-PARAM (declare (ignore whence)) (let ((param-name (optional-param-name param))) ;; TBD: Assuming that the resulting call form will be evaluated ;; within an environment in which the containing lambda list ;; will have served to establish any initial values, ;; consdierations: ;; ;; - The initfunction semantics of INITIALIZED-PARAM may be ;; removed from this design ;; Assumption: This form will be evaluated within NCONC ;; ;; Same assumption applies to the KEY-PARAM method, defined below. `(when ,(optional-param-value-p-name param) (list ,param-name)))) (:method ((param key-param) (whence generic-callable)) (declare (ignore whence)) (let ((param-name (key-param-name param))) `(when ,(key-param-value-p-name param) (list ,(key-param-keyword-name param) ,param-name)))) ) (defun unparse-signature-for-call (whence signature) (declare ;; (ignorable whence) ;; NB: May be removed in a subsq. revision (type lambda-signature signature) #+SBCL (values list list &optional)) ;; refer to remarks in COMPUTE-CALL-FORM ;; ;; .. esp. concerning CALL-SUPER semantics for GENERIC-OP and ;; GENERIC-METHOD definitions ;; (macrolet ((mkv () (make-array 0 :fill-pointer 0 :adjustable t))) (let* ((required-sub (lambda-signature-required-subset signature)) (optional-sub (lambda-signature-optional-subset signature)) (key-sub (lambda-signature-key-subset signature)) ;; NB: &REST param unused in constructing the call-form ;; TBD: unparse-signature-for-call for other-subset ;; Policy: Storing results in VARIADIC-FORMS (other-sub (lambda-signature-other-subset signature)) (variadic-p (call-form-variadic-p signature)) (required-args (mkv)) (variadic-forms (when variadic-p (mkv)))) ;; NB: within VARIADIC-FORMS: ;; - store any required conditional function calls for initializers ;; of &OPTIONAL and &KEY parameters ;; FIXME - iterate simply across PARAM-NEXT, below (??) (when required-sub ;; parameters onto a call for a form of known arity (do-vector (param (required-subset-members required-sub)) (vector-push-extend (unparse-param-for-call param whence) required-args))) ;; parameters and parameter initializers onto variadic calls (when optional-sub (do-vector (param (optional-subset-members optional-sub)) (let ((result (unparse-param-for-call param whence))) (vector-push-extend result variadic-forms)))) (when key-sub (do-vector (param (key-subset-members key-sub)) (let ((result (unparse-param-for-call param whence))) (vector-push-extend result variadic-forms)))) (when other-sub (do-vector (param (other-subset-members other-sub)) (let ((result (unparse-param-for-call param whence))) (vector-push-extend result variadic-forms)))) (values (coerce (the (array t (*)) required-args) 'list) (when variadic-p (coerce (the (array t (*)) variadic-forms) 'list))) ))) (defun compute-call-form (whence lambda-signature) ;; FIXME: Still need to support: ;; ;; - Selection of GENERIC-METHOD instnces from a GENERIC-OP, as based ;; on classes of required parameter sprovided in a call to the ;; GENERIC-OP - note that this does not, in fact, require creation ;; of arbitrary CONS objects for those parameters. It may dispatch ;; at least partly on the LAMBDA-SIGNATURE-REQUIRED-SUBSET of the ;; LAMBDA-SIGNATURE defined to a GENERIC-OP ;; ;; - Caching of effective call forms for GENERIC-METHOD calls to which ;; no single GENERIC-METHOD has an in-all-EQ set of method ;; specializers (may not be uncommon, in applications) ;; ;; - Dispatching across GENERIC-METHOD call forms, and the definition ;; and usage of the function CALL-SUPER in GENERIC-METHOD lambda ;; forms. ;; ;; - Updating for dispatch-chains when a GENERIC-METHOD is added to or ;; removed from a GENERIC-OP - in all regards, using a static ;; dispatching. ;; ;; - Handling for specific protocol constraints, to include: ;; - A GENERIC-OP must be defined with at least one specializable ;; parameter ;; - A GENERIC-OP may be defined with a specilized FTYPE. However, ;; on addition of any GENERIC-METHOD to such a GENERIC-OP, the ;; added method must be verified such as to not conflict with ;; the existing FTYPE form. Failing that, for purposes of ;; interactive development, an error may be signaled with restart ;; vis CERROR - somewhat analogous to some behaviors with regards ;; to DEFSTRUCT. ;; ;; - GENERIC-OP usage for slot-value and slot-boundp accessors - ;; partly onto MOP. ;; ;; - Extensions to this protocol, e.g for defining a storage and ;; call-form protocol for class-owned methods and corresponding ;; funcallable instance forms. ;; ;; - TBD: Analogy onto CLOS/MOP :AROUND, :BEFORE, and :AFTER methods, ;; as with standard method combination in CLOS ;; Prototype for an analogy to both of COMPUTE-DISCRIMINATING-FUNCTION ;; and MAKE-METHOD-LAMBDA onto GENERIC-OP and GENERIC-METHOD ;; NB: Towards application for GENERIC-OP specialization onto ;; instances of GENERIC-METHOD, this functional prototype ;; should be applied as to ensure that the first, most ;; specialized, statically available method for each specializable ;; paramter in LAMBDA-SIGNATURE will be selected and called for ;; the appropriate call-form - as namely a GENERIC-METHOD ;; function, serving in a role of WHENCE. ;; ;; Method-local dispatching within those methods may be handled ;; via a generic CALL-SUPER function - not in all ways equivalent ;; to CALL-NEXT-METHOD, though providing a similar semnatics as to ;; how CALL-SUPER may be called (assuming no mangling of the ;; arguments to the initial call-form, or however otherwise). ;; ;; Method-function resolution for CALL-SUPER may be addressed for ;; each GENERIC-METHOD added to a GENERIC-OP, after the ;; addition of any new GENERIC-METHOD to a GENERIC-OP - as to ;; suport an in-most-ways staic dispatching onto method ;; forms. This assumes that every class used as a specializer to a ;; GENERIC-OP will have been defined (not as a forward-referenced ;; class) and finalized at the time when any method applying that ;; class, as a specializer, will be initialized and stored as a ;; GENERIC-METHOD onto a GENERIC-OP. This also assumes that ;; GENERIC-OP will support only class specializers in any ;; GENERIC-METHOD. ;; ;; NB: As a side-effect to this approach for static method ;; dispatching, the method call infrastructure may need not ;; utilize a lot of epehmeral CONS objects. ;; NB: Not wrapping the call-form in LAMBDA here, during prototyping (let ((variadic-p (call-form-variadic-p lambda-signature))) ;; NB: WHENCE may represent a GENERIC-METHOD-FUNCTION of a ;; GENERIC-METHOD - NB: it's assumed to be an object, not an ;; evaluable expression. TBD: DEFINE-GENERIC-MACRO as such. ;; #+NIL (declare (type function ,%whence) (dynamic-extent ,%whence)) ;; NB: Intrinsic CONS production for variadic mapping of APPLY ;; onto FUNCALL - required here, if only when the ;; LAMBDA-SIGNATURE contains either &OPTIONAL or &KEY forms, ;; and thus for the characteristics of ephemeral &OPTIONAL ;; and &KEY parameters, their initializers, and their ;; "value-p" parameters, in some instances of conventional ;; Common Lisp function calls. ;; ;; Notable as a concern for applications: The extent to which ;; the GC must be used, for so much as normal call routines, ;; in a Common Lisp implementation - notable, in all of the ;; lazy memory allocation apparently assumed to be necessary ;; for the implementation of this programming language. ;; ;; APPLY may considered convenient, but estimably wasteful. ;; FIXME: Only use APPLY here, if there are keyword or optional ;; parameters, in the parsed LAMBDA-SIGNATURE ;; FIXME: In a further refinement of the design of the GENERIC-OP ;; and GENERIC-METHOD protocol defined here, this protocol may ;; prevent appliation of KEY, OPTIONAL, and REST parameters ;; insofar as onto method specialization - thus further ;; simplifying the design and implementation of this protocol, at ;; no estimably impossible cost to subsequent applications. ;; ;; For now, simply ensuring that the distriminating function will ;; not use APPLY if the GENERIC-OP does not permit any KEY or ;; OPTIONAL parameters ... provides a local optimization, such ;; that may be furthermore denoted in systems documentation. ;; ;; Towards a further optimization, as though by side effect: Note ;; also, the limitation of not permitting EQL specializers in ;; GENERIC-OP and GENERIC-METHOD definitions. ;; NB: for any KEY or OPTIONAL param, ensure that the ;; initfunction for the param is called when no actual value is ;; provided - assuming any non-nil initfunction, for each. ;; ^ FIXME: Also ensure that thoes initfunctions are compiled, ;; when initialized ;; TBD: Wrap the following in constant-p LOAD-TIME-VALUE (??) `(,@(if variadic-p ;; ASSUMPTION: WHENCE is, in all calls to this function, ;; a GENERIC-CALLABLE `((function apply) (the function ,whence)) `((function funcall) (the function ,whence))) ;; FIXME - MV-RET & when VARIADIC-P, wrap second value in NCONC ,@(multiple-value-bind (req-p varargs) (unparse-signature-for-call whence lambda-signature) ;; FIXME/TBD: OTHER-SUBSET support & VARIARIC-P in impl (cond (variadic-p `(,@req-p (nconc ,@varargs))) (t `(,@req-p)))) ;; FIXME when &ALLOW-OTHER-KEYS was specified in the initial ;; lambda list, a &REST param should also have been specified ;; or should be added by PARSE-LAMBDA-SIGNATURE (uninterned ;; symbol) and should be unparsed here. ;; ;; TBD: With such a lambda signature, consider whether ;; anything past the REST-PARAM need be provided in the call form ;; TD: Storing - together - any set of OPTIONAL and KEY ;; params from the SIGNATURE for a list type final arg to ;; APPLY ;; ... ;; NB: WHENCE may be ignorable in UNPARSE-SIGNATURE-FOR-CALL, assuming ;; the latter would be defined as a conventional DEFUN rather ;; than defined as generalized onto classes of WHENCE. In an ;; abstrct regard, it provides for a pairing of a ;; LAMBDA-SIGNATURE to an actual "Call instance" (e.g a ;; GENERIC-METHOD) ;; ;; Starting at LAMBDA-SIGNATURE-FIRST ;; - unparse required parameters for call, from LSIGNATURE ;; ;; - unparse optional and keyword parameters for call, from ;; LSIGNATURE ;; ;; - skipping any REST-PARAM, as its value would be ;; initialized only for the called function, i.e WHENCE ;; ;; - ... and handling any OTHER-SUBSET of the LSIGNATURE ;; - TBD: OTHER-SUBSET-CALL-APPLY-P ;; - NB: Skip any AUX param, for reasons similar to why ;; the REST-PARAM is skipped in producing the call ;; form ;; - NB: Skip any ENV param, similarly. ;; - ... and handling any implementation-specific lambda ;; list parameter kinds, assuming support for any more ;; specialized lambda list syntax onto this protocol ;; ... ;; ...... assuming "Appropriate binding of the parameters," ;; generically, in the environment in which this ;; macroexpansion would be evaluated, such as within a LAMBDA ;; form of a lambda signature per LAMBDA-SIGNATURE, or in any ;; binding of such a lambda form onto a funcallable instance. ;; ))) ;; TBD: Systems Test Forms - COMPUTE-CALL-FORM #+FROB ;; NB DNW for applications: Specialized CONS-type function names. (defun (frob a b c) () (values t t)) #+TBD ;; NB: may be analogous to MOP COMPUTE-DISCRIMINATING-FUNCTION (defun compute-generic-call-form (genop) (let ((signature (generic-op-signature genop))) `(lambda ,(lambda-signature-lambda-list signature) ,(compute-call-form op genop)))) (eval-when () (defparameter *c1* (make-instance 'generic-op)) ;; (functionp *c1*) (compute-call-form *c1* (parse-lambda-signature '(a b &optional q &rest other &key frob &allow-other-keys))) ) ;; --- ;; NB Design Decision: Definining a GENERIC-OP with no specilizable ;; parameters will result in a ERROR (declaim (ftype (function (generic-op cons) (values cons &optional)))) ;; NB: => CONS-OF GENERIC-METHOD #+TBD_IMPLEMENT (defun compute-reachble-methods (genop specializers) ;; NB This is not, per se: MOP COMPUTE-EFFECTIVE-METHOD ;; NB: The list returned from this function should only be used when ;; a GENERIC-METHOD is added to or removed from a GENERIC-OP. ;; ;; The GENERIC-OP framework is defined as to use a methodology of ;; static method dispatching. ;; ;; A GENERIC-OP may be specialized only onto any one or more ;; classes, such that - as with generic functions and standard methods ;; in CLOS - must be finalized when a GENERIC-METHOD is defined to a ;; GENERIC-OP. The convention of a default specializer class T is ;; retained, vis a vis CLOS. EQL specializers are not supported. ;; ;; Specialization of a GENERIC-OP may be permitted for a subset ;; of the required parameters of a GENERIC-OP. ;; ;; Specialization will be supported in a manner similar to ;; specialization with a standard method combination in CLOS. ;; Thus, SPECIALIZERS: a CONS, each element of which is a CLASS ;; NB: If this function is to return a CONS, it must err for when no ;; GENERIC-METHOD is reachable for any call form, provided the set of ;; SPECIALIZERS for arguments to the call form ;; ;; This function should not be called until after at least one ;; GENERIC-METHOD is in, in effect, defined to -- in another term, ;; registered to -- a GENERIC-OP, ;; ;; The definition of DEFINE-GENERIC-OP should be approached in a ;; manner such that COMPUTE-REACHABLE-METHODS will be called for each ;; set of specializers in each method defined in the DEFINE-GENERIC-OP ;; call, but not until after the entire set of methods has been ;; registered to the GENERIC-OP. ;; ;; -- ;; ;; For any GENERIC-METOHD that does not call CALL-SUPER in the method ;; lambda form, then any methods that would be reachable for any ;; CALL-SUPER call -- if it was present in that method's lambda form ;; -- may be discarded for the purpose of initializing the ;; funcallable instance function for the respective method. ;; ;; The funcallable instance function for a GENERIC-OP should be ;; defined sa to select the first reachable method for the set of ;; parameters provided in the call to the GENERIC-OP, then to ;; immediately dispatch to that method's funcallable instance ;; function, providing the same parameters to that function such that ;; were provided in the call to the GENERIC-OP. ;; ;; MOP has its conveniences, even in so much generalization onto ;; &REST. Although the amount of consuing used for method calculations ;; in MOP may not seem to be prohbitive to applications, but insofar ;; as that a CLOS-like method dispatching system may be implemented ;; without construction of so many ephemeral list objects at the time ;; of a call to function, it may be desired that so much consing would ;; be avoided, in applications. Although a protocol avoiding such ;; methodology may seem anyhow unwieldy, in implementation, but if ;; such a protocol may be implemented effectively, portably, and to no ;; forseeable error for applications, perhaps it may be of some use in ;; any subsequent development. ) ;; --- #+NIL (defmacro define-generic-op (name signature ....)) #+NIL (defmacro define-op-method (name signature &body body &environment env)) #+NIL (defmethod compute-discriminating-function ((gf generic-op)) (let ((llist (generic-function-lambda-list gf))) (compile (generic-function-name gf) `(lambda ,llist ;; ... ))))
74,918
Common Lisp
.lisp
1,631
35.011036
101
0.583395
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
7bb5784eed2cb797d510a58c45074de162de38da5baf541f9c0911c8c45ad4e6
29,283
[ -1 ]
29,284
mop-utils.lisp
thinkum_ltp-main/src/main/lsp/mop/common/mop-utils.lisp
;; mop-utils.lisp - utilities onto MOP implementations ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common/mop) (defmacro validate-class (class &optional (superclass 'standard-class)) #+(or SBCL CMU CCL ALLEGRO) `(progn (defmethod validate-superclass ((a ,class) (b ,superclass)) (values t)) (defmethod validate-superclass ((a ,superclass) (b ,class)) (values t))) #-(or SBCL CMU CCL ALLEGRO) `(progn (simple-style-warning "~<validate-class -~> ~<No known class/superclass validation ~ in this implementation -~> ~<class ~s with superclass ~s~>" (quote ,class) (quote ,superclass)) (values))) ;; -- Other Utils ;; ---- Class Precedence Reflection (eval-when (:compile-toplevel :load-toplevel :execute) ;; NB: ensure LEAST-COMMON-SUPERCLASS is defined in the environment, ;; previous to the INSTANCE deftype, such that uses MAKE-LOAD-FORM with ;; CONSTANTP non-nil. (declaim (ftype (function (class-designator class-designator) (values class cons &optional)) least-common-superclass)) (defun least-common-superclass (a b) ;; NB: MOP-util Onto CLOS, per se (let* ((%a (compute-class a)) (%b (compute-class b)) (common (nreverse (the cons (intersection (the cons (class-precedence-list %a)) (the cons (class-precedence-list %b)) :test #'eq))))) (declare (type class %a %b) (type cons common)) (values (car common) common))) ) ;; EVAL-WHEN ;; (least-common-superclass 'standard-object 'structure-object) ;; (least-common-superclass 'structure-object 'standard-object) ;; ---- Portable INSTANCE (not CONDITION) alias type (deftype instance () (mk-lf (class-name ;; FIXME - CONDITION is not ever TYPEP SLOT-OBJECT [SBCL] #+NIL (least-common-superclass (find-class 'condition) (least-common-superclass 'standard-object 'structure-object)) ;; ^ NB: The previous form returns the same as the following ;; form, in SBCL. The previous is not used, here, as it ;; introduces an inconsistency from the implementation. ;; ;; This inconsistency has been described to a further ;; extent, in the project tech note, `CONDITION` object is not ;; ever typep `SLOT-OBJECT` in some SBCL - avaialble in the ;; project documentation files under doc/markdown/ #-NIL (least-common-superclass 'standard-object 'structure-object))))
3,194
Common Lisp
.lisp
71
37.014085
80
0.59897
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
d04ff0df861d8b121b23326e4a4650206ed7919340237136454c226340413160
29,284
[ -1 ]
29,285
aclass.lisp
thinkum_ltp-main/src/main/lsp/mop/index/aclass.lisp
;; aclass.lisp - protocol for generic tabular indexing onto CLOS ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Interface and Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common/mop) ;; Previously defined in ../common/ ;; Remarks - API Design - Synopsis ;; ;; - This generalizes a concept of a contextually unique object name, ;; towards using such object name as a symbolic classifier. This is ;; for the purpose of defining a portable, generalized API for object ;; containers, container iterators, and operations onto contextual ;; object namespace/name definitions ;; ;; - cf LTP/COMMON:OBJECT-PRINT-NAME ;; ;; - In albeit a broad regard, an object index may be contrasted to a ;; formal data directory, data table system, or more generic data ;; records system. ;; Remarks - API Design - Provenance ;; ;; This source code was designed in a manner complimentary to a ;; definition of a set of "Indexed Test" classes for the AFFTA system. ;; ;; This also corresponds to the definition of the ASSOCIATIVE-OBJECT ;; class, previously in ../../common/common-print.lisp - whose source ;; code is now maintained, below. ;; ;; The class SIMPLE-ASSOCIATIVE-INDEX itself has been used in the ;; definition of AFFTA:TEST-SUITE, .... (eval-when () ;; prototype defs from ../../common/common-print.lisp (defclass associative-object () ;; FIXME - used in AFFTA, may be of some limited use in any "elsewhere" ;; ;; see also: ../mop/aclass/aclass.lisp ;; ;; FIXME - clarify the design of this. see also #<system:ltp-mop-utils:aclass.lisp> ((name :accessor object-name :type symbol ;; ED. NB: Note that this proposes a slot with type SYMBOL as an "Index Key" slot :initarg :name)) (:documentation "Prototype")) ;; Ed. NB: These generalized methods were defined to use PRINC, in lieu ;; of making nested calls to PRINT-NAME or PRINT-LABEL for an object-name ;; known to be of type SYMBOL (FIXME: Cheap decision) (defmethod print-name ((object associative-object) (stream stream)) ;; FIXME Consider dispatching on *PRINT-ESCAPE* for PRINT-NAME and/or ;; PRINT-LABEL methods ;; ;; Note that implementations of RESTART-BIND and RESTART-CASE forms ;; may also disptch on *PRINT-ESCAPE* ;; ;; Note also that implementations onto DEFINE-CONDITION may dispatch ;; on *PRINT-ESCAPE* as concerning implementations of CONDITION ;; :REPORT functions (princ (object-name object) stream)) (defmethod print-label ((object associative-object) (stream stream)) ;; NB: Applications inheriting ASSOCIATIVE-OBJECT should specialize ;; at least this method (princ (object-name object) stream)) ;; Redundant onto OBJECT-PRINT-NAME, OBJECT-PRINT-LABEL accessors #+NIL (defgeneric object-name (object)) #+NIL (defgeneric (setf object-name) (new-value object)) ) ;;; % Associative Index (defgeneric object-table-lock (index)) (defgeneric (setf object-table-lock) (new-value index)) (defgeneric object-table (index)) (defgeneric (setf object-table) (new-value index)) (defgeneric object-key-slot (index)) (defgeneric (setf object-key-slot) (new-value index)) (defclass associative-index () ((object-table-lock :initarg :object-table-lock ;; :type lock ;; FIXME: Define type `LOCK' in bordeaux-threads :accessor object-table-lock))) (defclass associative-table-index (associative-index) ((object-table ;; FIXME: This slot should be defined in a subclass, ;; as to not require that every ASSOCIATIVE-INDEX would store a ;; HASH-TABLE ;; ;; e.g within (DEFCLASS TABULAR-INDEX ...) :initarg :object-table :accessor object-table :type hash-table :initform (make-hash-table :test 'eq)))) (defmethod shared-initialize :after ((instance associative-index) slots &rest initargs) (declare (ignore initargs)) (when (or (eq slots t) (find 'object-table-lock (the list slots) :test #'eq)) (setf (object-table-lock instance) (make-lock (format nil "Object-Table Lock (~S)" (or (ignore-errors (class-name instance)) instance)))))) ;;; % Simple Associative Index (defgeneric object-table-key-function (index)) (defgeneric (setf object-table-key-function) (new-value index)) (defclass simple-associative-index (associative-table-index) ((key-function :initarg :key-function :type function :accessor object-table-key-function))) (defmethod shared-initialize :around ((instance simple-associative-index) slots &rest initargs &key (key-function nil kfp)) (let (args-changed-p) (when (and kfp (not (typep key-function 'function))) (setf args-changed-p t (getf initargs :key-function) (coerce key-function 'function))) (cond (args-changed-p (apply #'call-next-method instance slots initargs)) (t (call-next-method))))) ;;; % Index Protocol (defgeneric compute-key (object index) (:method (object (index simple-associative-index)) (funcall (the function (object-table-key-function index)) object))) (defgeneric register-object (object index) (:method ((object standard-object) (index associative-index)) (with-lock-held ((object-table-lock index)) (let* ((key (compute-key object index)) (table (object-table index)) (existing (gethash key table))) (when existing (warn 'redefinition-condition :new object :previous existing)) (setf (gethash key table) object) (values object key))))) (defgeneric find-object (name index &optional errorp) (:method (name (index associative-index) &optional (errorp t)) (with-lock-held ((object-table-lock index)) (let ((table (object-table index))) (multiple-value-bind (instance foundp) (gethash name table) (cond (foundp (values instance name)) (errorp (error 'entity-not-found :name name)) (t (values nil nil)))))))) (defgeneric remove-object (name index) (:method (name (index associative-index)) (with-lock-held ((object-table-lock index)) (let* ((table (object-table index)) (exp (remhash name table))) (values exp name))))) (defgeneric map-objects (function index) (:method (function (index associative-index)) (map-objects (coerce function 'function) index)) (:method ((function function) (index associative-index)) (with-lock-held ((object-table-lock index)) (let ((table (object-table index))) (labels ((fncall (key object) (declare (ignore key)) (funcall function object))) (maphash #'fncall table))) (values index)))) ;;; % Associative Class (defclass associative-class (associative-index standard-class) ;; protocol class ((key-slot :initarg :key-slot :accessor object-key-slot :type symbol ))) (defclass simple-associative-class (associative-table-index associative-class) ()) (validate-class simple-associative-class) (defmethod finalize-inheritance :after ((class associative-class)) (let ((ks (object-key-slot class)) (sl (class-slots class))) (unless (find ks (the list sl) :key #'slot-definition-name :test #'eq ) (simple-style-warning "Key slot ~S not defined to class ~S" sl class)))) (defmethod compute-key ((object standard-object) (index associative-class)) (slot-value object (object-key-slot index))) ;; (defgeneric remove-object ...) #| Instance tests ;;; % Instance Tests - REGISTER-OBJECT / FIND-OBJECT ;;; test setup (defclass afoo () ((fie :initarg :fie :type symbol) (fum :initarg :fum)) (:metaclass simple-associative-class) (:key-slot . fie)) ;;; test main (let ((af1 (make-instance 'afoo :fie '|1| :fum "One")) (af2 (make-instance 'afoo :fie '|2| :fum "Two")) (c (find-class 'afoo)) #+NIL (af3 (make-instance 'afoo))) (register-object af1 c) (register-object af2 c) (labels ((frob-test (k) (let ((o (find-object k c))) (eq (slot-value o 'fie) k)))) (values (frob-test '|1|) (frob-test '|2|)))) ;;; => T, T ;; FIXME: Define more tests - application of AFFTA |#
8,880
Common Lisp
.lisp
218
35.362385
85
0.659814
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
178445ec79c28c665a1a6f1b63ac498f0ee2a4d041f86d366a49d9ee03dcb637
29,285
[ -1 ]
29,286
singleton.lisp
thinkum_ltp-main/src/main/lsp/mop/singleton/singleton.lisp
;; singleton.lisp - ltp-common-mop-singleton protocol definitions ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:cl-user) ;; Ed. NB: See also Garnet [KR] (defpackage #:ltp/common/singleton (:nicknames #:ltp.common.singleton) (:use #:ltp/common/mop #:ltp/common #:cl) (:export #:singleton #:defsingleton )) (in-package #:ltp/common/singleton) ;; NB/TD SINGLETON Extensions => MODEL [OUTLINE] ;; - MODEL @ LTP-SYS ;; - MODEL @ LLVM ;; - MODEL @ ASN.1 ;; - MODEL @ UNIX (BSD) ;; - **Subsq. ext** - Model Development @ LTP DEVO INFRAST ;; - TBD LTP-SYS -> Data Flow ;; - MODEL @ LTP-DATA-MNG ;; - MODEL @ SQL ;; - NB Shared Components onto LTP-SYS -> Data Type Definition ;; - MODEL @ IPv4 (IPv6 w/ limited adoption ??) + infrast service model ;; - NB Shared Components onto LTP-SYS -> Data Type Definition ;; - MODEL @ GSS-API &SUBSQ ;; - NB Shared Components onto LTP-SYS -> Data Type Definition ;; - **Subsq. ext** - Model Development @ LTP DEVO INFRAST - SM ;; - MODEL => FIPA-SL-MODEL (TBD) ;; - TBD Shared Components onto LTP-SYS -> Data Flow ;; - MODEL @ XML ;; - MODEL => XSD-MODEL ;; - MODEL => RNC-MODEL ;; - MODEL => DTD[MODEL ;; - [X] XSD-MODEL -> XMI-MODEL ;; - NB Shared Components onto LTP-SYS -> Data Type Definitions ;; - MODEL after OMG MDA/OMA/... ;; - MODEL @ MOF ;; - Model @ UML/MOF shared classifiers ;; - Model @ MOF primary classifiers (cf. MOF meta-metamodel, pedagogically) ;; - Model @ OCL ;; - **TBD:** _Predicate-Oriented Decomposition_ of OCL Specifiers ;; - TBD: Parsing "OCL Strings" (is not VDM, per se) ;; - TD: _Isomorphism of_ "Parsed OCL Strings" I.R and "OCL onto XMI' I.R ;; - NB^2 : Garnet [KR] - KR O-FORMULA Objects & KR Schema - Defn & Eval'n ;; - Model @ UML ;; - Model @ UML/MOF shared classifiers (see previous) ;; - Model @ UML Metamodel ;; - Model @ UML Profiles, Stereotypes [...] ;; - NB Non-Isomorphism of UML Stereotypes and (ONTO) MOF Metaclasses ;; - Model @ UML Diagram Kinds [X] ;; - Model @ UML pedagogic visual notation ;; - Model @ SysML ;; - Model @ UML4SysML classifiers (& UML Profiles, Stereotypes) ;; - Model @ SysML primary classifiers (x SysML metamodel, pedagogically) ;; - Model @ SysML Diagram Kinds [X] ;; - Model @ SysML (and UML) pedagogic visual notation ;; - Model @ BPMN ;; - Model @ BPMN primary classifiers (BPMN as a UML Profile) ;; - Model @ "The BPMN Diagram kind" (pedagogicP ;; - Model @ BPMN pedagogic visual notation ;; - Model @ ODM [...] (NB: RDF impl @ librdf) ;; ;; = Model Development @ LTP DEVO INFRAST ;; - TBD Shared Components onto LTP-SYS -> Data Flow ;; - TBD Shared Components @ LTP-SYS -> WHICH CLIM GARNET GTK+ OTHER? ;; - Model Development @ LTP DEVO INFRAST / Application Environments ;; - Model Development @ LTP DEVO INFRAST / PC Desktop Environments ;; - Model Development @ LTP DEVO INFRAST / SRV Environments ;; - Model Development @ LTP DEVO INFRAST / Mobile Environments ;; - NB: Maemo (FOSS now entirely beyond Nokia) + HW & QEMU ;; - NB: Android (FOSS w/ Google Corp't & Inc. Hegemony) + HW & QEMU ;; - Model Development @ **LTP DEVO INFRAST - Shared Model Components** ;; - Machine Architecture Modeling ;; - Machine Processor Modeling (4DEVO) [xBSD, LLVM] ;; - Machine Subarchitecture Modeling (4DEVO) [xBSD, LLVM] ;; - OS Architecture Modeling (4DEVO) ;; - NB: BSD UNIX systems as OS Reference Impls (UNIX) ;; - ABI Architecture Modeling ;; - ELF ABI Modeling ;; - COFF ABI Modeling ;; - Itanium ABI Modeling ;; - TD: **Secondary ABI** Modeling @ **JNI (see also: C++)** ;; - TD: Shared Components @ **Bytecode Component & Toolchain** Models ;; = Model Development @ LTP DEVO INFRAST - SM ;; - [...] ;; -- Singleton Class Definition (defclass singleton (standard-class) ()) (validate-class singleton) (defmethod finalize-reachable ((class singleton) (seen-classes list)) (catch 'finalize-singleton (macrolet ((class-seen (c seen) `(find ,c ,seen :test #'eq)) (add-seen (c seen) `(setf ,seen (cons ,c ,seen))) (hcall (form) `(handler-bind ((class-finalization-warning (lambda (c) (warn c) (throw 'finalize-singleton (values))))) ;; Try to catch any call to finalize a forward-referenced ;; class, such as to return immediately ,form)) (dispatch (c seen call) `(progn ;;; #+DEBUG #+NIL (warn "DISPATCH for ~S ~S - SEEN ~S : ~S" (quote ,c) ,c ,seen (quote ,call)) (unless (class-seen ,c ,seen) (hcall (,call ,c ,seen)) ;; try this secondly (add-seen ,c ,seen))))) (unless (class-seen class seen-classes) (dolist (supc (class-direct-superclasses class)) (unless (class-seen supc seen-classes) ;;; #+DEBUG #+NIL (warn "DISPATCH for SUPC ~S - SEEN ~S : ~S" supc seen-classes 'finalize-reachable) (let ((seen-classes (cons class seen-classes))) ;; Do not destructively modify seen-classes to include CLASS yet (hcall (finalize-reachable class seen-classes))) (add-seen supc seen-classes))) (multiple-value-prog1 (dispatch class seen-classes call-next-method) (dolist (subc (class-direct-subclasses class)) (dispatch subc seen-classes finalize-reachable))))))) ;; -- (macrolet ((find-for (name accessor whence base-class) `(block search (dolist (c (reverse (class-precedence-list (find-class (quote ,base-class))))) (dolist (sl (,whence c)) (when (find (quote ,name) (the list (,accessor sl)) :test #'eq) (return-from search (slot-definition-name sl)))))))) (defconstant* +direct-superclasses-slot+ (or (find-for :direct-superclasses slot-definition-initargs class-slots standard-class) (find-for class-direct-superclasses slot-definition-readers class-direct-slots standard-class) (error "Cannot find direct superclasses slot for ~ standard-class, in this implementation")))) ;; -- (defmethod shared-initialize :after ((instance singleton) slots &rest initargs &key &allow-other-keys) (declare (ignore initargs)) ;; Ensure that the list of direct superclasses is initialized in a ;; manner appropriate for an instance of the class SINGLETON (when (or (eq slots t) (and (consp slots) (find +direct-superclasses-slot+ (the cons slots) :test #'eq))) (let ((tgt-class (find-class 'singleton)) (unused-class (find-class 'standard-object)) (dsup (slot-value instance +direct-superclasses-slot+))) (declare (dynamic-extent tgt-class unused-class)) (setq dsup (delete unused-class dsup :test #'eq)) (unless (some (lambda (c) (find-class-in-precedence tgt-class c nil)) dsup) (setq dsup (cons tgt-class dsup))) (setf (slot-value instance +direct-superclasses-slot+) dsup))) ;;;; ;; ;; FIXME/TBD: Update design and implementation of SINGLETON class ;; finalization, pursuant of reafctoring the definition of the classes ;; SINGLETON and PROTOTYPE-CLASS onto LTP BASE-CLASS (Metaclass) ;; ;; Refer to annotations, titled "Limitations on Design," in source file ;; ltp-main:src/main/lsp/base-class/fdef-acc.lisp ;; ;;;; ;; ;; Also ensure that the instance's superclasses, the instance itself, ;; and any non-forward-referenced subclasses are finalized (finalize-reachable instance nil)) ; Tests for Singleton Finalization - e.g #+NIL (eval-when () ;; NOTE ALSO the updated CHANGE-CLASS method, defined below (macrolet ((mk (class pfx &rest direct-sup) `(ensure-class ;; NB: Is not MAKE-INSTANCE (quote ,(gentemp (concatenate 'simple-string (symbol-name pfx) #.(symbol-name '#:_nr)))) ,@(when direct-sup (list :direct-superclasses (cons 'list direct-sup)))))) (defparameter *s1* (mk singleton s-1)) (values (class-finalized-p *s1*) ;; => T (prog2 (defparameter *s2* (mk forward-referenced-class s-2 *s1*)) (class-finalized-p *s2*)) ;; => NIL ;; NB: {SBCL & PCL} does not denote a forward-referenced-class as finalized ;; FIXME - the definition of *S3* is now breaking, in CCL, and ;; breaks subsequent evaluation of this source file (prog2 (defparameter *s3* (mk singleton s-3 *s2* *s1*)) (class-finalized-p *s3*)) ;; => NIL ;; class has a forward-referenced superclass, cannot be finalized ;; NB: This CHANGE-CLASS call may not be portable for applications, ;; per [AMOP]. In the PCL MOP implementation, it can be evaluated ;; when *S2* is a forward-referenced-class (prog2 (change-class *s2* (find-class 'singleton) :name (class-name *s2*) :direct-superclasses (class-direct-superclasses *s2*)) (class-finalized-p *s2*)) ;; => T ;; *S2* is no longer forward referenced and should be a finalized singleton (class-finalized-p *s3*) ;; => T ;; *S3* should have been finalized when *S2* was finalized as a singleton )) (finalize-reachable *s3* nil) (class-finalized-p *s3*) ;; => T ;; after explicitly calling it (class-finalized-p *s2*) ;; => NIL ;; FIXME - should not be NIL. Is not NIL, in SBCL ;; Misc ... (defsingleton s-x-1 () ()) (defsingleton s-x-2 (s-x-1) ()) (typep (find-class 's-x-2) 's-x-1) ;; => NIL ; which is - in short - why this was updated with DEFSINGLETON ;; ;; NB: A broader synposis about the DEFSINGLETON update is provided, ;; in commentary available in the macro definition's source form, below. ) ;; -- Singleton Slot Definitions (defclass singleton-slot-definition (standard-slot-definition) ;;;; ;; ;; FIXME/TBD: Update design and implementation of ;; SINGLETON-SLOT-DEFINITION subclasses, pursuant of reafctoring the ;; definition of the classes SINGLETON and PROTOTYPE-CLASS onto LTP ;; BASE-CLASS ;; ;; Refer to annotations, titled "Limitations on Design," in source file ;; ltp-main:src/main/lsp/base-class/fdef-acc.lisp ;; ;;;; () (:default-initargs :allocation :class)) (defclass singleton-direct-slot-definition (singleton-slot-definition standard-direct-slot-definition) ;; NB: These will extend the standard MOP classes ;; ;; The allocation meta-slot will be by-in-large unused here - assumed ;; to be, in effect, always :CLASS ()) ;; FIXME: Err for any singleton slot definition with ;; :ALLOCATION :INSTANCE specified during slot metaobject ;; initialization (defmethod direct-slot-definition-class ((class singleton) &rest initargs) (declare (ignore class initargs)) (find-class 'singleton-direct-slot-definition)) (defclass singleton-effective-slot-definition (singleton-slot-definition standard-effective-slot-definition) ()) (defmethod effective-slot-definition-class ((class singleton) &rest initargs) (declare (ignore class initargs)) (find-class 'singleton-effective-slot-definition)) ;; -- ;; Applications TD ;; - Use for internal representation of "Application Personalities" in ;; the Lisp Environment - Class definitions, method definitions, and ;; runtime application protocols. ;; ;; - Use for internal representation of bytecode ABIs (host ABIs, ;; and toolchain ABIs) ;; ;; - Extend SINGLETON => SINGLETON-FUNCALLABLE-INSTANCE ;; ;; - Use in definitions of external API forms - onto external type ;; schema, as also extending SINGLETON) ;; ;; - Observe XMI as a serialized representation of MOF (subsq. UML and ;; other metamodels tractably extending OMG MOF) towards ;; consideration with regards to portable definitions for such type ;; schema. (NB: MOF and RDF may occupy different domains, per se. ;; Note, however, the perhaps visually-oriented syntax of the RDF ;; metamodel defined in OMG ODM) ;; ;; - Note that this is not, per se, for redefining any single manner ;; of knowledge representation system ;; TBD: SINGLETON-FUNCALLABLE-INSTANCE & CLASS-OWNED-METHOD definitions ;; ;; - NB: Common Lisp GENERIC-FUNCTION metaobjects as globally scoped ;; objects, principally extending on a semantics of the Lisp ;; function as a first order object, for purposes of definining ;; polymorphic functions in Common Lisp programs ;; ;; - NB: Polymorphic functions in Simula and subsq. ;; ;; - NB: Type signatures in SML ;; TBD: SINGLETON usage in _static dispatching_ w/ portable extensions ;; onto CLtL2+MOP standard generic functions and standard methods - at ;; least insofar as may be portably integrated with any number of PCL ;; implementations. ;; NB: DEFSINGLETON Update ;; ;; The origingial DEFSINGLETON macro definition was removed in changeset ;; d2d9c76740f684a18276207cc149a981e76619a3 - 9 June, 2019 19:01:08-0700 ;; ;; Subsequently, the updated DEFSINGLETON* has been renamed DEFSINGLETON, ;; in effect replacing the original macro definition. ;; NB: Refer to DEFSINGLETON test definitions at end of file ;; -- misc utils (prototypes) (defun* find-class-in-precedence (the-class class &optional (errorp t)) ;; return the first class found, of which THE-CLASS is a superclass, ;; or the class itself if THE-CLASS is equivalent to CLASS (declare (type class-designator the-class class) (values &optional class)) (labels ((handle-fail () (cond (errorp (error "No superclss ~S found for ~S" the-class class)) (t (values))))) (let ((%the-class (compute-class the-class errorp)) (%class (compute-class class errorp))) (cond ((eq %class %the-class) (values %class)) ((eq %class (load-time-value (find-class 't) t)) (handle-fail)) (t (dolist (c (cond ((class-finalized-p %class) (cdr (class-precedence-list %class))) (t (class-direct-superclasses %class))) (handle-fail)) (cond ((eq c %the-class) (return %class)) (t (let ((found (find-class-in-precedence %the-class c nil))) (when found (return c))))))))))) #+NIL (eval-when () ;; instance tests - FIND-CLASS-IN-PRECEDENCE (defclass f-1 () ()) (defclass f-2 (f-1) ()) (defclass f-3 (f-2) ()) (find-class-in-precedence 'f-1 'f-1) => #.(find-class 'f-1) (find-class-in-precedence 'f-1 'f-3) => #.(find-class 'f-2) (find-class-in-precedence 'g-1 'f-3 nil) => no value returned (defclass g-2 () ()) (find-class-in-precedence 'g-2 'f-3 nil) => no value returned ) #+NIL ;; NB: Used in some ealier prototypes, retained here temporarily (defmacro getf* (place property &optional default) ;; FIXME - move definition to ltp-common (with-symbols (dflt obj) `(let* ((,dflt (load-time-value (make-symbol #.(symbol-name (quote :%default))) t)) (,obj (getf ,place ,property ,dflt))) (declare (dynamic-extent ,dflt)) (cond ((eq ,obj ,dflt) (values ,default nil)) (t (values ,obj t)))))) (defgeneric prototype-implementation-class (class)) (declaim (ftype (function (class) (values class-designator &optional)) prototype-implementation-class)) (defgeneric (setf %prototype-implementation-class) (new-value class)) (declaim (ftype (function (class-designator class) (values class-designator &optional)) (setf %prototype-implementation-class))) ;; NB: Considering that the class PROTOTYPE-CLASS is used in the ;; evaluation of the updated DEFSINGLETON maro, it cannot be defined with ;; DEFSINGLETON*. ;; ;; The class represents a SINGLETON type - equivalently, representing a ;; SINGLETON metaclass. As it defines the class PROTOTYPE-CLASS, ;; however, it will not be defined with a PROTOTYPE metaclass of type ;; PROTOTYPE-CLASS, such as how any class defined with DEFSINGLETON will be ;; defined. ;; ;; As such, the class of PROTOTYPE-CLASS will not be capable of storing ;; a refeernce to the class, PROTOTYPE-CLASS, itself. Although this ;; could be addressed with some indirection, it might not be asumed to ;; represent any serious concern for applications. ;; (defclass prototype-class (singleton) ((implementation-class :type class-designator :initarg :implementation-class :reader prototype-implementation-class :writer (setf %prototype-implementation-class))) (:metaclass singleton)) ;; -- (define-condition class-definition-error (error) ((class :initarg :class :reader class-definition-error-class))) (define-condition slot-definition-parse-error (class-definition-error) ((slot :initarg :slot :reader slot-definition-parse-error-slot) (name :initarg :name :reader slot-definition-parse-error-name) (value :initarg :value :reader slot-definition-parse-error-value))) (define-condition slot-definition-invalid-syntax (slot-definition-parse-error) () (:report (lambda (c s) (let ((name (slot-definition-parse-error-slot c))) (format s "~<Invalid slot definition syntax~>~ ~< for class ~s slot ~s :~>~< ~s~>" (class-definition-error-class c) name (cons name (slot-definition-parse-error-value c))))))) (define-condition duplicate-slot-initarg (slot-definition-parse-error) ((previous :initarg :previous :reader slot-definition-parse-error-previous)) (:report (lambda (c s) (format s "~<Duplicate slot definition initialization argument~>~ ~< for class ~s slot ~s :~>~< ~s value ~s~>~< was previously ~s)~>" (class-definition-error-class c) (slot-definition-parse-error-slot c) (slot-definition-parse-error-name c) (slot-definition-parse-error-value c) (slot-definition-parse-error-previous c))))) (define-condition unspported-slot-initarg (slot-definition-parse-error) () (:report (lambda (c s) (format s "~<Unsupported slot definition initialization argument~>~ ~< for class ~s slot ~s :~>~< ~s value ~s~>" (class-definition-error-class c) (slot-definition-parse-error-slot c) (slot-definition-parse-error-name c) (slot-definition-parse-error-value c))))) ;; NB: Per the particular semantics of SINGLETON class definitions, ;; in the protocol implemented in this system: It will not be ;; possible to use or create a forward-referenced superclass of any ;; SINGLETON, without further extension to this protocol. (define-condition forward-referenced-superclass (class-definition-error) ;; FIXME not aligned onto LTP/COMMON/MOP:CLASS-FINALIZATION-CONDITION ;; ;; Used in. ENSURE-DIRECT-SUPERCLASSES ((unfinalized-class :initarg :unfinalized-class :reader class-definition-error-unfinalized-class)) (:report (lambda (c s) (format s "Cannot define class ~S with non-finalied superclass ~S" (class-definition-error-class c) (class-definition-error-unfinalized-class c))))) (define-condition undefined-superclass (class-definition-error) ;; FIXME not aligned onto LTP/COMMON/MOP:CLASS-FINALIZATION-CONDITION ;; ;; Used in. ENSURE-DIRECT-SUPERCLASSES ((undefined-class :initarg :undefined-class :reader class-definition-error-undefined-class)) (:report (lambda (c s) (format s "Cannot define class ~S with undefined superclass ~S" (class-definition-error-class c) (class-definition-error-undefined-class c))))) (defmacro while (clause &body forms) `(block nil (loop (or ,clause (return)) (progn ,@forms)))) (defun parse-defclass-slot-description (desc class) (declare (type cons desc) (type symbol class) #+(or SBCL CMUCL) (values cons list &optional)) ;; NB: Return values may be destructively modified ;; ;; NB: DESC should not be destructively modified - may represent ;; static data, as from a compiler environment ;; ;; NB: The return value may not be, in itself, evaluated ;; ;; NB: The first return value is produced in a manner that every ;; element in that return value can be quoted, for processing within ;; a calling lexical environment. ;; ;; NB: The second return value represents a list of forms that ;; should be evaluated without quoting, in the calling lexical ;; environment. If any initform is specified, this second return ;; value will include :initfunction <list> for a <list> ;; representative of a lambda form representing the initial ;; initform. (destructuring-bind (%name &rest options) desc (let ((%options (copy-list options)) name value ;; allow only once initform initfunction type documentation allocation readers writers initargs other) (while %options ;; NB This assumes OPTIONS is formatted as a property list (setq name (pop %options) value (cond (options (pop %options)) (t (error 'slot-definition-invalid-syntax :slot name :class class :value options)))) (case name (:initarg (setq initargs (nconc initargs (list value)))) (:reader (setq readers (nconc readers (list value)))) (:writer (setq writers (nconc writers (list value)))) (:accessor (setq readers (nconc readers (list value)) writers (nconc writers (list (list 'setf value))))) (:initform ;; NB - The application will need to produce an ;; initialization function, such that may be evaluated ;; within the lexical environment calling this function. ;; ;; The following ensures that the LAMBDA form is returned ;; as a list type form, such that may be (but probably will ;; not be - FIXME) evaluated within the calling lexical ;; environment. Considering that the list generated with ;; this form is not - in fact - a function, it should not ;; cause any side-effects with regards to the evaluation ;; environment, so long as the value returned from this ;; function will be (FIXME) evaluated within that same ;; lexical environment. (when initform (error 'duplicate-slot-initarg :slot %name :class class :name name :value value :previous initform)) (setq initform value ;; FIXME - QUOTING FOR THE INITFORM FOR EVALUATION ENVIRONMENT initfunction `(lambda () ,value))) (:initfunction (error 'unsupported-slot-initarg :slot %name :class class :name name :value value)) (:type (when type (error 'duplicate-slot-initarg :slot %name :class class :name name :value value :previous type)) (setq type value)) (:documentation (when documentation (error 'duplicate-slot-initarg :slot %name :class class :name name :duplicate value :previous documentation)) (setq documentation value)) (:allocation (when allocation (error 'duplicate-slot-initarg :slot %name :class class :name name :duplicate value :previous allocation)) (setq allocation value)) (t (setq other (nconc other (list (list name value))))))) (values (list* :name %name (nconc (when readers (list :readers readers)) (when writers (list :writers writers)) (when initargs (list :initargs initargs)) (when initform ;; NB: initfunction form returned ;; as a second value (list :initform initform)) (when documentation (list :documentation documentation)) (when allocation (list :allocation allocation)) other)) initfunction)))) (defun ensure-direct-superclasses (supers class &optional environment) (mapcar (lambda (c) (let ((%class (compute-class c nil environment))) (cond ((typep %class 'forward-referenced-class) (error 'forward-referenced-superclass :class class :unfinalized-class c)) (%class (values %class)) (t (error 'undefined-superclass :class class :undefined-class c))))) supers)) ;; (ensure-direct-superclasses '(string vector complex) 'nope) ;; (ensure-direct-superclasses '(undef vector complex) 'nope) (defun parse-defclass-parameter (name value) (declare #+(or SBCL CMUCL) (values list list &optional)) ;; Polymorphic Parsing for Class Initialization Arguments ;; ;; NB: Return value may be destructively modified - as with MAPCAN ;; ;; NB: VALUE should not be destructively modified - may represent ;; static data, as from a compiler environment ;; the first return value represents values that should be quoted ;; before evaluation within any calling lexical environment. ;; ;; the second return value represents values that should be evaluated, ;; unquoted. ;; NB: :default-initargs => :direct-default-initargs ;; and more initfunctions (case name (:default-initargs (values nil (list :direct-default-initargs (map-plist (lambda (k v) (list k (list 'quote v) `(lambda () ,v))) value)))) (t (values (list name value) nil)))) ;; (parse-defclass-parameter :default-initargs '(:a 1 :b b)) ;; ^ NB: Second return value will have to be specially handled [FIXME] (defmacro defsingleton (name (&rest superclasses) slots &rest params &environment env) ;; NB: As one purpose that this new DEFSINGLETON serves, juxtaposed ;; to the original DEFSINGLETON definition: The resulting ;; SINGLETON instance, as defined with this updated macro, will ;; represent a subtype to every class specified in SUPERCLASSES. ;; ;; -- ;; NB: This documentation, in effect, uses the term PROTOTYPE-CLASS in ;; lieu of METACLASS as it denotes -- in the former -- a class ;; defined during evaluation of DEFSINGLETON, however serving ;; in a role of a conventional CLOS metaclass. ;; --- ;; ;; Considering limitations as extended of MOP implementations, it ;; may be impossible to produce a portable definition of a class ;; such that will be TYPEP of its own class -- anywhere beyond ;; STANDARD-CLASS. ;; ;; For any singleton class C2 that may be defined as a subclass of ;; a class C1 -- such as for any purpose of extending the ;; semantics of the class C1 onto the definition of C2 -- after ;; addressing some of the superclass semantics onto the metaclass ;; of C2 -- i.e onto the class M of which the class C is itself an ;; instance -- such that M will be a subtype of C2, as well as C1 ;; being a subtype of C2 -- it may thus be ensured that the singleton ;; instance C2 is, at least, a subtype of those types specified in ;; the instance's direct superclasses list. This may serve to ;; alleviate some concerns with regards to typing for SINGLETON ;; instances, in applications. ;; ;; In that regard, this macro definition provides something of an ;; update to the original DEFSINGLETON macro definition. ;; ;; ;; This, of course, is still not sufficient to portably emulate ;; the Metacircular character of STANDARD-CLASS -- there being, ;; simply, no portable API available for extending of any ;; meachanisms by which STANDARD-CLASS was defined in a manner as ;; to represent an instance of itself, in any implementation. ;; FIXME: Document the :PROTOTYPE-CLASS parameter to DEFSINGLETON. ;; ;; Note that the parameter serves to allow the calling ;; environment to specify a class name for the resulting ;; prototype class. In all instances of DEFSINGLETON, a class ;; will be defined -- using DEFCLASS -- with that class name. A ;; default value is computed, if none is specified. ;; ;; FIXME: Document the handling of the :METACLASS parameter, together ;; with the direct superclass list provided to DEFSINGLETON, as ;; related to the definition of the prototype metaclass. ;; ;; In effect, the class defined by DEFSINGLETON will not be an ;; instance of the class specified in the :METACLASS parameter, ;; but will be an instance of a subtype of that class. ;; NB: As the singleton metaclass definition is now being handled ;; via some extensions onto ALLOCATE-INSTANCE, SHARED-INITIALIZE, ;; and ENSURE-CLASS, this macro will no longer expand to a ;; DEFCLASS form. (labels ((compute-user-metaclass (params) (let ((meta-n (position :metaclass (the list params) :test #'eq :key #'car))) (cond (meta-n (let* ((meta-prop (nth meta-n params)) (params-adj (remove meta-prop params :test #'eq))) (values (cdr meta-prop) params-adj))) (t (values nil params))))) (compute-prototype-class-spec (params) (let ((name-n (position :prototype-class (the list params) :test #'eq :key #'car))) (cond (name-n (let* ((name-prop (nth name-n params)) (params-adj (remove name-prop params :test #'eq))) (values (cdr name-prop) params-adj))) (t (values nil params)))))) (multiple-value-bind (proto-spec %params) (compute-prototype-class-spec params) (with-symbols (proto-meta direct-meta base-class %superclasses the-class) (multiple-value-bind (user-metaclass %params) (compute-user-metaclass %params) ;; NB: Using an implcit PROTOTYPE-METACLASS is-a SINGLETON here. `(progn ;; NB: This implementation, in effect, prevents any usage ;; of forward-referenced classes in the SUPERCLASSES list (let* ((,base-class (find-class 'singleton)) ;; ^ FIXME define +SINGLETON-BASE-CLASS+ ;; ;; see also ALLOCATE-INSTANCE, below ;; (,direct-meta ,(cond (user-metaclass `(compute-class ,@user-metaclass)) (t base-class))) (,%superclasses (ensure-direct-superclasses (quote (,@superclasses)) (quote ,name) ,env)) (,proto-meta (ensure-prototype-metaclass (or ,proto-spec (ensure-prototype-metaclass-name ,base-class (quote ,name))) ,direct-meta ,base-class ,%superclasses)) (,the-class (#+NIL apply ensure-class (quote ,name) :direct-superclasses ,%superclasses :metaclass ,proto-meta :direct-slots (list ,@(mapcar #'(lambda (spec) (multiple-value-bind (parsed initfn) (parse-defclass-slot-description spec name) (cons 'list (nconc (mapcar #'(lambda (literal) (list 'quote literal)) parsed) (when initfn (list :initfunction initfn)))))) slots)) ;; &REST ,@(mapcan #'(lambda (spec) (destructuring-bind (param . pvalue) spec (multiple-value-bind (to-quote eval) (parse-defclass-parameter param pvalue) (nconc (mapcar #'(lambda (literal) (list 'quote literal)) to-quote) (apply #'nconc (map-plist #'(lambda (name form) (case name (:direct-default-initargs `(#+NIL list ,name (list ,@(mapcar #'(lambda (f) (cons 'list f)) form)))) (t (list name form)))) eval) ))))) %params) ))) ;; NB/DOCUMENTATION (and PCL) - NOTE THE FOLLOWING (shared-initialize ,the-class (list +direct-superclasses-slot+)) ;; ^ FIXME reimplement that behavior, onto ENSURE-CLASS (SINGLETON) (setf (%prototype-implementation-class ,proto-meta) ,the-class) (values ,the-class)))))))) ;; -- ;; FIXME: Test DEFSINGLETON with a superclass not being of a metatype ;; SINGLETON, but such that a direct superclass of that class is of ;; metatype SINGLETON #+NIL (eval-when () ;; TO DO - TEST DEFSINGLETON w/ :default-intiargs, environment ;; TO DO - TEST DEFSINGLETON w/ slotdef initforms, environment (defclass frob-c () ()) (defsingleton frob-s-1 (frob-c) ()) (class-finalized-p (find-class 'frob-s-1)) ;; => T [SBCL] [CCL] (class-direct-superclasses (find-class 'frob-s-1)) ;; =>( #.(... SINGLETON) #.(... FROB-C)) (typep (find-class 'frob-s-1) 'frob-c) ;; => T (subtypep (find-class 'frob-s-1) 'frob-c) ;; => T, T (typep (make-instance (find-class 'frob-s-1)) 'frob-c) ;; => T ;; OK ... ;; NB - Errors seen w/ SUBTYPEP for non-finalized classes [CCL] ;; (class-of (find-class 'frob-s-1)) ;; (class-direct-superclasses (class-of (find-class 'frob-s-1))) ;; => (#<SINGLETON PROTOTYPE-CLASS> ;; #<STANDARD-CLASS SINGLETON> ;; #<STANDARD-CLASS FROB-C>) ;; ;; This, now.... ;; (subtypep (find-class 'frob-s-1) 'standard-class) ;; ;; FIXME => NIL, T [CCL] (??!!?) ;; IFF FROB-S-1 IS NOT FINALIZED ;; ^ by side-effect, this breaks some of the following tests & protocol ;; ;; OK => T, T [SBCL] ;; (subtypep (find-class 'singleton) 'standard-class) ;; => T, T [CCL]... ;; ;; (subtypep (find-class 'frob-s-1) 'singleton) ;; => NIL, T (!?) [CCL] ;; IFF FROB-S-1 IS NOT FINALIZED ;; => T, T [SBCL] ;; (find (find-class 'singleton) (class-precedence-list (find-class 'frob-s-1))) ;; FIXME - CCL - IF FROB-S-1 HAS NOT BEEN FINALIZED ;; (class-precedence-list (find-class 'frob-s-1)) ;; => (#<FROB-S-1!SINGLETON FROB-S-1> #<STANDARD-CLASS FROB-C> #<STANDARD-CLASS STANDARD-OBJECT> #<BUILT-IN-CLASS T>) ;; ^ no #<SINGLETON> even while ... ;; ;; (class-direct-superclasses (find-class 'frob-s-1)) ;; => (#<SINGLETON> #<FROB-C>) ;; (finalize-inheritance (find-class 'frob-s-1)) ;; (subtypep (class-of (find-class 'frob-s-1)) 'standard-class) ;; => T, T ;; of course ;; ;; (typep (class-of (find-class 'frob-s-1)) 'standard-class) ;; => T ;; of course ;; (subtypep (find-class 'standard-class) 'standard-object) ;; => T, T [CCL] [SBCL] ... (subtypep (make-instance (find-class 'frob-s-1)) 'frob-c) ;; NB => NIL, T ;; NB: BREAKS in CCL IF FROB-S-1 NOT FINALIZEDC ;; ;; FIXME: Consider inheriting the direct superclasses from the ;; metaclass, for any SINGLETON instance ;; (subtypep (make-instance (find-class 'frob-s-1) :direct-superclasses (list (find-class 'frob-s-1))) 'frob-c) ;; => T, T #+NIL ;; NB: the :DIRECT-SUPERCLASSES sequence may be ignored, "By now" .... (shared-initialize (find-class 'frob-s-1) t :direct-superclasses (list (find-class 'frob-c))) (class-direct-superclasses (find-class 'frob-s-1)) (class-precedence-list (find-class 'frob-s-1)) (class-precedence-list (class-of (find-class 'frob-s-1))) (defsingleton frob-s-1-1 (frob-s-1) ()) (typep (find-class 'frob-s-1-1) 'frob-s-1) ;; => T ! for the singleton superclass ;; - suitable for some OO protocol definitions ;; - nearly works around limitations imposed by the implementation, ;; in effect disallowing any class except STANDARD-CLASS to be an ;; instance of itself. ;; -- (macroexpand-1 (quote (defsingleton singleton-1-2 () ((sl-a :initarg :sl-a :initform "the-sl-a") (sl-b :initarg :sl-b)) ;; NB: :DEFAULT-INITARGS should be handled specially in SINGLETON [FIXME] (:default-initargs :sl-a *default-pathname-defaults* :sl-b (quote nil))) ;; (class-direct-default-initargs (find-class 'singleton-1-2)) ;; ;; (slot-value (make-instance 'singleton-1-2) 'sl-a) ;; => <varies lexically> ;; ;; (slot-value (make-instance 'singleton-1-2) 'sl-b) ;; => NIL )) ) #+TBD (eval-when () (macroexpand-1 (quote (defsingleton singleton-1-1 () ((sl-1 :initform "the-sl-1") (sl-b))) )) (class-direct-superclasses (find-class 'singleton-1-1)) ;; NB: ^ should always include SINGLETON (class-of (find-class 'singleton-1-1)) (typep (find-class 'singleton-1-1) 'singleton) ;; => T (subtypep (find-class 'singleton-1-1) 'singleton) ;; => T, T ;; alternately ... (let ((c (find-class 'singleton-1-1))) (multiple-value-bind (st-1 st-2) (subtypep c 'singleton) (multiple-value-bind (mt-1 mt-2) (subtypep (class-of c) 'singleton) (values st-1 st-2 mt-1 mt-2)))) ;; => T, T, T, T (class-slots (find-class 'singleton-1-1)) (class-direct-slots (find-class 'singleton-1-1)) (defsingleton singleton-2-2 (singleton-1-1) ((sl-c))) ;; FIXME [CCL] - LOOP (??) (class-slots (find-class 'singleton-2-2)) (class-direct-slots (find-class 'singleton-2-2)) (typep (find-class 'singleton-1-1) 'singleton-1-1) ;; => NIL ; which still is not good for this design (typep (find-class 'singleton-2-2) 'singleton-1-1) ;; => T ;; NB "OK" (this differs from the original DEFSINGLETON) ;; (subtypep (class-of (find-class 'singleton-2-2)) 'singleton-1-1) ;; => T, T (typep (make-instance 'singleton-1-1) 'singleton-1-1) ;; => T ;; which is passable, ;; but really no different than STANDARD-OBJECT semiotics (subtypep (make-instance 'singleton-1-1) 'singleton-1-1) ;; => NIL, T (subtypep (make-instance 'singleton-2-2) 'singleton-1-1) ;; => NIL, T (subtypep (make-instance 'singleton-2-2 :direct-superclasses (list (find-class 'singleton-2-2))) 'singleton-1-1) ;; => T, T (typep (make-instance 'singleton-2-2) 'singleton-1-1) ;; => T ;; OK ! ;; NB: To produce a suclass C2 of a class C1, such that C2 is both an ;; instance typep C1 and a subtype of C1 ... ;; ;; ... one may define MAKE-INSTANCE => CREATE-IMPLICIT-SUBCLASS ;; via ALLOCATE-INSTANCE ) ;; -------------------------------------------------- (defmethod change-class :after ((instance forward-referenced-class) (new prototype-class) &rest initargs &key &allow-other-keys) ;;;; ;; ;; FIXME/TBD: Update design and implementation of SINGLETON class ;; finalization, pursuant of reafctoring the definition of the classes ;; SINGLETON and PROTOTYPE-CLASS onto LTP BASE-CLASS (Metaclass) ;; ;; Refer to annotations, titled "Limitations on Design," in source file ;; ltp-main:src/main/lsp/base-class/fdef-acc.lisp ;; ;;;; (declare (ignore initargs)) (let* ((implc (and (slot-boundp instance 'implementation-class) (prototype-implementation-class new))) (implc-inst (when implc (compute-class implc nil)))) (cond (implc-inst ;; FIXME: If no IMPLC-INST -- i.e if the instance's ;; implementation-class is not yet defined -- need to defer ;; evaluation ! This may serve to require some extensions in the ;; compiler environment. #+nil (warn "Dispatch from CHANGE-CLASS ~S ~S to initialize ~S" instance new implc-inst) ;; NB: in PCL this may be the only way to ensure that the ;; direct-supeclasses slot winds up initialized from ;; CHANGE-CLASS (??) (FIXME: Evaluate how that's been implemented) (shared-initialize implc-inst (list +direct-superclasses-slot+)) (finalize-reachable implc-inst nil) (finalize-reachable instance (list implc-inst))) ;; In lieu of deferred evaluation, emit a warning ;; ;; NB: In this scenario, the instance's implementation-class may ;; be manually initialized from outside of CHANGE-CLASS, using a ;; SHARED-INITIALIZE call similar to the previous. (t (warn "~<Unable to initilize unreachable ~ implementation class ~S for ~S~>~< during (CHANGE-CLASS ~S ~S)~>" implc new instance new))))) ;; -------------------------------------------------- (defmethod initialize-instance ((instance singleton) &rest initargs &key direct-superclasses &allow-other-keys) ;; NB: This method serves to ensure that SINGLETON should appear in ;; the class precedence list for INSTANCE. If none of the ;; direct-superclasses is a subclass of SINGLETON, the class SINGLETON ;; will be added to the head of the direct superclasses list. This ;; method also serve to ensure that any instance of the class ;; STANDARD-OBJECT is removed from the initial direct superclasses ;; list. ;; NB: In some call sequences -- such as when a singleton is created ;; initially from DEFCLASS, rather than CHANGE-CLASS from a ;; FORWARD-RERFERENCED-CLASS -- this may be "Early enough" to catch ;; where PCL is initially setting the direct-superclasses list for the ;; class definition. NB: See also CHANGE-CLASS, SHARED-INITIALIZE ;; FIXME: Also ensure that any call to MAKE-INSTANCE of a SINGLETON ;; will produce an object that is a subtype of the original ;; SINGLETON. This may be approached, somewhat portably, with ;; ALLOCATE-INSTANCE. Such a methodology may serve to require ;; that a new class will be initialized within some calls to ;; ALLOCATE-INSTANCE - rather than within a top-level DEFCLASS form, ;; such that would be processed by the implementation compiler. ;; ;; In such a methodology, there may be an effect produced such that ;; the class of a SINGLETON created with MAKE-INSTANCE would a ;; subclass of, but not equivalent to the class provided to ;; MAKE-INSTANCE ;; ;; To an effect ;; (subtypep (make-instance the-singleton) the-singleton) => T, T ;; (let ((tgt-class (find-class 'singleton)) (unused-class (find-class 'standard-object)) initargs-updated) (declare (dynamic-extent tgt-class unused-class)) (macrolet ((dispatch () `(cond (initargs-updated #+NIL (warn "~<Updated Dispatch for ~S in INITIALIZE-INSTANCE ~>~ ~< - DIRECT-SUPERCLASSES modified: ~S~>" instance direct-superclasses) (apply #'call-next-method instance initargs)) (t (call-next-method))))) (labels ((ensure-tgt-superclass () (cond (direct-superclasses (unless (some (lambda (c) (find-class-in-precedence tgt-class c nil)) direct-superclasses) (prog1 (setf (getf initargs :direct-superclasses) (cons tgt-class (remove unused-class direct-superclasses :test #'eq))) (setq initargs-updated t)))) (t (prog1 (setf (getf initargs :direct-superclasses) (cons tgt-class (remove unused-class direct-superclasses :test #'eq))) (setq initargs-updated t)))))) ;;;; ;; ;; FIXME/TBD: Update design and implementation of SINGLETON class ;; finalization, pursuant of reafctoring the definition of the classes ;; SINGLETON and PROTOTYPE-CLASS onto LTP BASE-CLASS (Metaclass) ;; ;; Refer to annotations, titled "Limitations on Design," in source file ;; ltp-main:src/main/lsp/base-class/fdef-acc.lisp ;; ;;;; (setq direct-superclasses (ensure-tgt-superclass)) ;; NB: Not useful, if the updated value is being ignored ;; by the implementation. See also SHARED-INITIALIZE (dispatch))))) ;; ) #+NIL (eval-when () (defsingleton x-a () ()) (typep (make-instance 'x-a) 'x-a) ;; => T ;; consistent onto CLOS (subtypep (make-instance 'x-a) 'x-a) ;; FIXME while => NIL, T ;; NB/ORTHOGONAL - CLOS and MOP (list* (find-class nil nil) (let* ((nm (gentemp "Singleton-")) (c (make-instance 'standard-class :name nm))) (list (find-class nm nil) c))) ;; => NIL, NIL ;; ;; THUS: While MAKE-INSTANCE of a STANDARD-CLASS does result in an ;; object that is (TYPEP object 'STANDARD-CLASS) but it may not ;; result in the compiler type system recognizing the instance as ;; representing a defined class. In that regard, it would seem as ;; though the class-name has no consistent effect, until the class is ;; registered -- via non-portable code -- in the implementation type ;; system. ;; ;; FIXME - VULN ANALYSIS: Theoretically, it may be possible to use ;; MAKE-INSTANCE to create a STANDARD-CLASS that has a name EQ to any ;; defined system class, while that named but "Unknown" class would ;; not be EQ to the corresponding system class, in the ;; implementation. (find-class-in-precedence 'singleton 'x-a nil) ;; => #.(find-class 'X-A) (class-precedence-list (find-class 'x-a)) ;; ... (defsingleton x-b (x-a) ;; NB: PCL will err here iff x-a is a forward referenced class ()) (typep (make-instance 'x-b) 'x-b) ;; => T ;; consistent onto CLOS (typep (make-instance 'x-b) 'x-a) ;; => T ;; consistent onto CLOS (subtypep (make-instance 'x-b) 'x-a) ;; FIXME while => NIL, T (subtypep (class-of (make-instance 'x-b)) 'x-a) ;; => T, T ;; consistent onto CLOS ;; ;; approximately equivalent: (subtypep (find-class 'x-b) 'x-a) ;; => T, T ;; consistent onto CLOS ;; -- test the new SHARED-INITIALIZE method with the original DEFSINGLETON macro (defsingleton x-c () ()) (typep (make-instance 'x-c) 'x-c) ;; => T ;; consistent onto CLOS (class-direct-superclasses (find-class 'x-c)) (class-direct-superclasses (class-of (find-class 'x-c))) ;; - (defsingleton x-d (x-c) ()) (typep (make-instance 'x-d) 'x-d) ;; => T ;; consistent onto CLOS (subtypep (make-instance 'x-d) 'x-c) ;; FIXME while => NIL, T ;; same behavior as with new DEFSINGLETON [FIXME there too] (class-direct-superclasses (find-class 'x-d)) (subtypep 'x-d 'x-c) ;; => T, T ;; consistent onto CLOS ;; -- tests onto forward referenced classes (defclass proto-frob-pf~2 (proto-frob-pf~1) ;; NB: The class proto-frob-pf~2 will be unused in this test. ;; ;; The defclass form is evaluated once, as a trivial way to create ;; a forward-referenced class ()) ;; (class-name (class-of (find-class 'proto-frob-pf~1))) ;; => FORWARD-REFERENCED-CLASS ;; or else do not reevaluate these test forms ... ;; Now where can any portable application initialize proto-frob-pf~1 ;; completely, during the following? (defsingleton proto-frob-pf~1 (x-a) ()) (class-direct-superclasses (find-class 'proto-frob-pf~1)) ;; ^ FIXME - needs to include SINGLETON (via ... ??) ;; (class-direct-superclasses (class-of (find-class 'proto-frob-pf~1))) ;; -- test w/ slot definitions (defsingleton misc-singleton () ((sl-a :type t :initarg :sl-a :accessor misc-singleton-a ))) ;; NB: THIS NEEDS TO BE TESTED IN A COMPILER ENVIRONMENT (??) (class-direct-slots (find-class 'misc-singleton)) (class-slots (find-class 'misc-singleton)) ) ;; -- ;; NB: The following was originally defined as a prototype ;; onto two classes SINGLETON* and SINGLETON**. As such, the source code ;; was located at end-of-file. ;; ;; This should be evaluated before any calls to the updated DEFSINGLETON macro (defgeneric class-prototype-metaclass (class) (:method ((class standard-class)) (load-time-value (find-class 'prototype-class) t))) (defgeneric ensure-prototype-metaclass (proto use-metaclass for-class direct-superclasses) ;;;; ;; ;; FIXME/TBD: Update design and implementation of SINGLETON class ;; finalization, pursuant of reafctoring the definition of the classes ;; SINGLETON and PROTOTYPE-CLASS onto LTP BASE-CLASS (Metaclass) ;; ;; Refer to annotations, titled "Limitations on Design," in source file ;; ltp-main:src/main/lsp/base-class/fdef-acc.lisp ;; ;;;; (:method ((proto singleton) (use-metaclass standard-class) (for-class standard-class) ;; may be #<SINGLETON> (direct-superclasses list)) ;; (declare (ignore use-metaclass for-class direct-superclasses)) ;; FIXME - note the FIND-CLASS call, below, similarly ;; (values proto)) ;; NB - a trivial hack to ensure that the PROTO class matches per ;; the protocol implemented for a newly defined prototype-metaclass (ensure-prototype-metaclass (class-name proto) use-metaclass for-class (remove proto direct-superclasses :test #'eq))) (:method ((proto null) (use-metaclass standard-class) (for-class singleton) (direct-superclasses list)) (error "Invalid prototype metaclass name for ~s: ~s" proto for-class)) (:method ((proto symbol) (use-metaclass standard-class) (for-class standard-class) ;; may be #<SINGLETON> (direct-superclasses list)) (or (find-class proto nil) ;; NB - CLASS REUSE ;; FIXME - only reuse the class when it conforms to the ;; following implementation pattern - else generate a new ;; prototype class name and dispatch to the following ;; FIXME - SORT-CLASSES needs an update (labels ((find-class-in-superclasses (c supers) (some #'(lambda (sc) (find-class-in-precedence c sc nil)) supers)) (guarded-add (c supers) (cond ((find-class-in-superclasses c supers) (values supers)) (t (cons c supers)))) (sort-classes (proto-meta for-c use-meta direct-supers) ;; NB - does not add FOR-C if it's EQ to USE-META ;; ;; Similarly, does not add PROTO-META if it's EQ to USE-META ;; ;; ... or if appears in the class precedence list ;; of any class in DIRECT-SUPERS ;; ;; NB: This does not sort the result per any added classes ;; ;; FIXME This fails to add #<SINGLETON> when evaluated ;; w/ CCL (guarded-add proto-meta (guarded-add for-c (guarded-add use-meta direct-supers))))) (let ((proto-metaclass (class-prototype-metaclass for-class)) (%direct-superclasses ;; TBD - wrap the COMPUTE-CLASS call with something to ;; signal a FORWARD-REFERENCED-SUPRECLASS error ;; onto FOR-CLASS, for any forward-referenced class ;; in direct-superclasses (mapcar #'compute-class direct-superclasses))) (ensure-class proto :metaclass proto-metaclass :name proto :direct-superclasses ;; FIXME : Trivial superclass sorting (sort-classes proto-metaclass for-class use-metaclass %direct-superclasses) :implementation-class for-class)))))) (defmethod shared-initialize ((instance singleton) slots &rest initargs &key (ensure-prototype nil esp) &allow-other-keys) (declare (ignore ensure-prototype)) ;; Remove (and not delete) initargs not used in the class instance ;; ;; NB: This method's definition, itself, may have a side-effect of ;; validating the initarg :ENSURE-PROTOTYPE during ENSURE-CLASS and similar ;; (let (initargs-updated) (macrolet ((remf* (whence name) (with-symbols (%whence) `(let ((,%whence (copy-list ,whence))) (remf ,%whence ,name) (values ,%whence)))) (dispatch () `(cond (initargs-updated (apply #'call-next-method instance slots initargs)) (t (call-next-method))))) (when esp (setq initargs (remf* initargs :ensure-prototype) initargs-updated t)) (dispatch)))) (defgeneric ensure-prototype-metaclass-name (for-metaclass class-name) (:method ((for-metaclass standard-class) (class-name symbol)) (intern (concatenate 'simple-string (symbol-name class-name) "!" (symbol-name (class-name for-metaclass)))))) (defmethod allocate-instance ((class singleton) &rest initargs) (cond ((or (getf initargs :prototype-class) (getf initargs :ensure-prototype)) ;; ^ NB: Prevent that this protocol would be, in effect, active for ;; definitions of SINGLETON classes outside of DEFSINGLETON and similar. ;; FIXME - Consider inheriting direct superclasses (filtered) from ;; the metaclass (labels ((mk-default-name (class) (make-symbol (concatenate 'simple-string #.(symbol-name (quote #:uninterned-)) (symbol-name (class-name class)))))) (let* ((name (or (getf initargs :name (mk-default-name class)))) (proto-spec (getf initargs :prototype-class (ensure-prototype-metaclass-name class name))) (metaclass (compute-class (getf initargs :metaclass (load-time-value (find-class 'singleton) t)))) (direct-supers (getf initargs :direct-superclasses)) (proto-metaclass (ensure-prototype-metaclass proto-spec metaclass class direct-supers))) ;;;; ;; ;; FIXME/TBD: Update design and implementation of SINGLETON class ;; finalization, pursuant of reafctoring the definition of the classes ;; SINGLETON and PROTOTYPE-CLASS onto LTP BASE-CLASS (Metaclass) ;; ;; Refer to annotations, titled "Limitations on Design," in source file ;; ltp-main:src/main/lsp/base-class/fdef-acc.lisp ;; ;;;; #+NIL (warn "ALLOCATE-INSTANCE ~s as instance of ~s" class proto-metaclass) (let ((%initargs (copy-list initargs))) (remf %initargs :ensure-prototype) (remf %initargs :prototype-class) (apply #'allocate-instance proto-metaclass %initargs))))) (t (call-next-method)))) #+NIL (eval-when () (let ((s (find-class 'prototype-class))) (defparameter *the-s* (ensure-class (gentemp "S-") :metaclass s :prototype-class (gensym "S-PROTO-") :direct-superclasses (list s) )) (finalize-inheritance *the-s*) (values #+NIL (typep *the-s* s) *the-s*)) ;; (class-of *the-s*) ;; (class-of (class-of *the-s*)) ;; (class-direct-superclasses (class-of *the-s*)) ;; (class-direct-subclasses (find-class 'prototype-class)) ;; NB ! QA for the updated ALLOCATE-INSTANCE method ;; (class-of (class-prototype (find-class 'singleton))) ;; ^ should be the class SINGLETON (eq (class-of (class-prototype *the-s*) ) *the-s*) ;; => T (eq (class-of (class-prototype (class-of *the-s*))) (class-of *the-s*)) ;; => T (subtypep *the-s* 'singleton) ;; => T, T (typep *the-s* 'singleton) ;; T ;; and of course (per CLOS unadorned) ... (typep (make-instance *the-s*) 'singleton) ;; T ;; NOW THIS NEEDS DOCUMENTATION ;; &MISC (subtypep (make-instance *the-s*) 'singleton) ;; T, T ;; per CLOS (subtypep (ensure-class (gensym "THE-S") :metaclass *the-s*) 'singleton) ;; T, T (subtypep (make-instance *the-s*) 'singleton) ;; T, T ;; -- (let ((s (find-class 'prototype-class))) (defparameter *the-s-2* (make-instance s :name (gentemp "S2-") ;; NB - make-instance with :prototype-class class ;; ;; Ensuring prototype-class reuse here - trivial test :prototype-class (find-class 'prototype-class) :direct-superclasses (list s) :ensure-prototype t :metaclass s )) (finalize-inheritance *the-s-2*) (values #+NIL (typep *the-s* s) (symbol-value '*the-s-2*))) ;; (typep *the-s-2* 'singleton) ;; => NIL ;; consequent of the user-specified metaclass ;; -- (let ((s (find-class 'prototype-class))) (defparameter *the-s-3* (make-instance s :name (gentemp "S3-") ;; NB test prototype-class name initialization :direct-superclasses (list s) :ensure-prototype t :metaclass s )) (values #+NIL (typep *the-s* s) (symbol-value '*the-s-3*))) ;; -- test with non-singleton user-specified superclasses (defclass obj-a () ()) (let ((s (find-class 'prototype-class))) (defparameter *the-s-4* (ensure-class (gentemp "S4-") :metaclass s :direct-superclasses (list (find-class 'obj-a)) :ensure-prototype t )) ;; (finalize-inheritance *the-s-4*) (values #+NIL (typep *the-s* s) (symbol-value '*the-s-4*))) #+NIL (make-instance (find-class 'prototype-class) :ensure-prototype t :metaclass (find-class 'singleton)) (make-instance (find-class 'prototype-class) ;; :ensure-prototype t :metaclass (find-class 'singleton)) ;; ^ No loop, but not using the correct metaclass semantics (class-of *the-s-4*) ;; => #<PROTOTYPE-CLASS> ;; (typep *the-s-4* 'obj-a) ;; => T ;; (subtypep *the-s-4* 'obj-a) ;; => T, T ;; (typep (make-instance *the-s-4*) 'obj-a) ;; => T ;; ;; ... which is pretty much the point of this - NB [DOCUMENTATION] ;; ... in which it's more or less like DEFSINGLETON but implemented ;; via ALLOCATE-INSTANCE ;; nb - consequent of ENSURE-CLASS (find-class (class-name *the-s-4*) nil) ;; => <CLASS> ;; (find-class (class-name (class-of *the-s-4*)) nil) ;; => <CLASS> (class-direct-superclasses *the-s-4*) (subtypep (make-instance *the-s-4*) 'obj-a) ;; NB => NIL, T ;; note no :DIRECT-SUPERCLASSES specified to the instance (subtypep *the-s-4* 'obj-a) ;; => T ;; (describe (find-class 'obj-a)) ;; NB (class-of (class-of *the-s-4*)) ;; => #<SINGLETON PROTOTYPE-CLASS> (subtypep (make-instance *the-s-4* :direct-superclasses (list *the-s-4*)) 'obj-a) ;; => T, T ;; -- ;; FIXME - Test with user-specified metaclass )
65,459
Common Lisp
.lisp
1,478
34.238836
119
0.576609
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
da1702b772694f30ef999a5194d490f833ec9418aa8975ffe59603efe3f2ccf7
29,286
[ -1 ]
29,287
guarding.lisp
thinkum_ltp-main/src/main/lsp/mt/guarding.lisp
;; guarding.lisp - WITH-WRITE-GUARD, OBJECT-POOL, GUARDED-FUNCALL - Impl & Suppt ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation onto SB-THREAD ;; ;;------------------------------------------------------------------------------ ;; NB: Concerning applications, refer to ;; ltp-main:src/main/lsp/stor/README.md ;; Ed. NB: The Initial protoype for this implementation has been ;; developed, as though singularly, onto SBCL SB-THREAD. ;; ;; Subsequent of further development for DEFPORTABLE.LISP, ;; this implementation may be generalized for support with other ;; implementation-specific APIs for program multi-tasking. ;; Ed. NB: When developed for implementation in CCL, the "Write Guard" ;; concept -- insofar as developed onto GUARDED-FUNCALL -- ;; should be generalized support of Model (R/W) locks, vis a vis ;; POSIX threads. Such support may be summarized, in a manner, ;; generally: ;; ;; - Require mutually exclusive access during write. ;; ;; - Prevent mutually exclusive access during read, until all ;; threads holding the nonexclusive read-lock have released ;; the nonexclusive read-lock ;; ;; Thus, a READ-LOCK -- in this methodology -- may not be ;; updated to a WRITE-LOCK until the thread requesting to ;; update to a WRITE-LOCK will be the first requesting thread ;; for a WRITE-LOCK onto the same modal (R/W) lock ;; ;; See also: The FreeBSD kernel, which provides a number of ;; forms for facilitating concurrent access to kernel resources ;; - moreover, as extensively described in formal documentation ;; about the FreeBSD kernel. (in-package #:ltp/common/mop) ;; TBD: mk local defpackge - reusing LTP/COMMON/MOP only temporarily, here (declaim (type #+(and SBCL SB-THREAD) sb-thread:mutex #+(and SBCL (not SB-THREAD)) null #-SBCL nil ;; NB: Consider this onto DEFPORTABLE.LISP ;; NB: In effect, a type declaration for a symbol as ;; having the type NIL, in any single lexical ;; environment, may serve to prevent any binding of a ;; value onto that symbol, in the same lexical ;; environment. +write-guard-1+)) (defconstant* +write-guard-1+ ;; NB: see also ./defportable.lisp ;; NB: In the initial prototype -- using mutually-exclusive locks in ;; implementation, vis a vis SB-THREAD -- This +WRITE-GUARD-1+ is ;; to be held only for the duration of checking, and optionally ;; initializing, and subsequently releasing a lock for any ;; guarded location - such as of the MEMBERS slot of an ;; OBJECT-POOL, or the guarded FUNCTION of a GUARDED-FUNCALL ;; #+(and SBCL SB-THREAD) (sb-thread:make-mutex :name "+write-guard-1+") #+(and SBCL (not SB-THREAD)) nil #-SBCL (error "+write-guard-1+ not supported in this implementation") "Generalized initial write-guard for instance-localized, mutually exclusive access locking protocols" ) ;; NB: SBCL SB-SYS:SIGNAL-DEADLINE ;; ;; - used in SB-THREAD::%WAIT-FOR-MUTEX ... which is used in ;; SB-THREAD:GRAB-MUTEX when a MUTEX cannot be initially acquired ;; ;; - signals an error of type SB-SYS:DEADLINE-TIMEOUT within a ;; lexical environment in which the restarts DEFER-DEADLINE and ;; CANCEL-DEADLINE are avaialble - the former, such that the ;; restart's main function would reinitialize the deadline and ;; (in effect) defer to wait for a number of additional ;; <seconds>. That number of additional <seconds> may be specified ;; via TRY-RESTART, or the convenience function DEFER-DEADLINE. ;; By default, the same number of <seconds> will be used as was ;; specified to the previous deadline-wait entry. The restart ;; CANCEL-DEADLINE may be called directly as to "Gracefully exit" ;; from the location in which the initial deadline-wait was ;; initialized. The dedline itself is implemented with the ;; structure class SB-IMPL::DEADLINE. See also: SB-THREAD:GRAB-MUTEX ;; ;; - may serve to provides a basis for a calling application to ;; handle the circumstance of when a blocking lock request has ;; failed due to timeout ;; ;; - does not in itself serve to provide a basis for a calling ;; application to handle the circumstance of when a non-blocking ;; lock request has failed due to mutual exclusion (defmacro with-write-guard ((which &key block-p timeout when-timeout-fail when-acquire-fail) &body body) ;; NB: Not guaranteed to be portable "Out of the box" ;; TBD: This macro's definition may be moved into a source system ;; independent of GUARDED-FUNCALL, as it may be of some general ;; usage in applications without GUARDED-FUNCALL, per se. ;; NB: For SBCL w/ SB-THREAD the WHEN-FAIL form may be called only ;; when a TIMEOUT is specified and exceeded ;; ;; NB: In this prototype, the WHEN-ACQUIRE-FAIL form should be called ;; for any non-blocking request that fails to acquire the lock ;; denoted in WHICH. This has been approached, below, using a ;; simple methodology in application of two lexically scoped ;; varaibles -- one, storing a lexically available symbol, ;; the other initially storing the value NIL. It may be assumed ;; that the value of the let-var storing the value NIL will be set ;; to be EQ to the value of the let-var storing the original ;; symbol only when the lock acquisition has succeeded. ;; ;; This methodology may be portable onto other implementations. ;; ;; TBD: Portability for the implemeentation onto SBCL DEADLIMNE ;; TBD: Organizing this source system in a manner as to ensure that ;; each set of implementation-specific forms will be defined in a ;; single source file for the specific implementation. ;; ;; Alternately, see also: DEFPORTABLE.LISP #+(and SBCL SB-THREAD) (with-symbols (%which %block-p %timeout %time-fail %acq-fail %c %thunk %thunk-p) `(let ((,%which ,which) (,%block-p ,block-p) (,%timeout ,timeout) (,%time-fail ,when-timeout-fail) (,%acq-fail ,when-acquire-fail)) (declare (type (or null function) ,%time-fail ,%acq-fail)) ;; FIXME: Only emit the following warnings in the macroexpansion, ;; under certain policy configurations - it can be non-portable, ;; here, as this branch is already evaluated locally to SBCL (when (and ,%time-fail (null ,%timeout)) (simple-style-warning "~<WITH-WRITE-GUARD called with ~>~ ~< non-null WHEN-TIMEOUT-FAIL but null TIMEOUT~>")) (when (and ,%timeout (null ,%block-p)) (simple-style-warning "~<Intrinsic blocking call to ~ WITH-WRITE-GUARD~>~< assuming TIMEOUT ~S overriding null BLOCK-P~>" ,timeout)) (let ((,%thunk (make-symbol "%thunk-internal")) (,%thunk-p nil)) (declare (type symbol ,%thunk ,%thunk-p) (dynamic-extent ,%thunk ,%thunk-p)) (handler-bind ((sb-sys:deadline-timeout (,%c) (cond ((functionp ,%time-fail) (funcall (the function ,%time-fail) ,%which ,%c)) (t (sb-sys:cancel-deadline ,%c))))) (unwind-protect (sb-thread:with-mutex (,%which :waitp (or ,%block-p ,%timeout) :timeout ,%timeout) (unwind-protect (progn ,@body) (setq ,%thunk-p %thunk))) ;; NB: Try to provide a WHEN-ACQUIRE-FAIL support for ;; non-blocking calls (unless (eq ,%thunk-p ,%thunk) (when ,%acq-fail (funcall (the function ,%acq-fail) ,%which)))))))) #+(and SBCL (not SB-THREAD)) `(progn ,@body) ;; TBD: Ever single-threaded implementation case #-SBCL ;; TBD: Every unsupported multi-threaded implementation case (error "WITH-WRITE-GUARD not yet supported in this implementation") ) ;; -- ;; TBD - OBJECT-POOL should be generally portable ;; ;; Note, however ... the pool-members lock ;; and thus also, +WRITE-GUARD-1+ ;; for any multi-threaded implementation. ;; ;; Note also, MAKE-HASH-TABLE :synchronized t ; in some SBCL ;; Concept - Effective MUTEX pooling for GUARDED-FUNCALL, in supported impls ;; ;; See also: +WRITE-GUARD-1+ (deftype sxhash-key () ;; NB: This assumes that no CONDITION object will be tested for ;; consistency onto the SXHASH-KEY type - otherwise could be defined as: ;; (and (not instance) (not condition)) ;; ;; See also: QA for the INSTANCE deftype in LTP/COMMON/MOP '(not instance)) #+TBD (declaim (ftype (function (sxhash-key sxhash-key) (values boolean &optional)) sxhash-key-eql)) #+TBD (defun sxhash-key-eql (obj1 obj2) (= (sxhash obj1) (sxhash obj2))) #+TBD (defstruct (object-pool #+TBD (:constructor %make-object-pool (... %objects instance-guard))) ;; NB: Concurrent access to an OBJECT-PO0L must be, in itself, ;; guarded. ;; ;; This implementation will reuse the same pattern extended for ;; GUARDED-FUNCALL, as of using a +WRITE-GUARD-1+ pursuant ;; to initialization, checking, or <<free+deallocation>> of an ;; instance-local write lock (%objects (make-array 16) :type simple-vector ;; TBD @ IMPL/QA: The slot's binding should be understood as ;; read-only - more or less, static/constant as a slot value ;; binding. However, the object stored in the slot value, itself, ;; will be destructively modified. :read-only t) #+TBD (object-allocation-table ;; NB/Concept: During RELEASE-OBJECT, with the POOL-WRITE-GUARD held, ;; scan this simple bit vector for the first index having a value 0. ;; Use that index as an index onto the %OBJECTS simple-vector. ;; ;; If no index can be found with value 0, the pool is "Full" and the ;; object can be discarded ;; ;; Note that this would be applicable for any type of object in the ;; %OBJECTS table. It may be redundant, however, for many types of ;; OBJECT in active storage - as where a simple "non-nil" test onto ;; the %OBJECTS simple vector may be sufficient. (make-array 16 :element-type 'bit) :type simple-bit-vector :read-only t) (depth 16 ;; NB arbitrary initform :type array-length :read-only t) (last-free-index ;; NB: Caching for storage onto the members-pool, may be useful in ;; any generalized task in which ALLOCATE-OBJECT is called on an ;; OBJECT-POOL, followed immediately with RELEASE-OBJECT onto the ;; same OBJECT-POOL - thus avoiding iteration onto the %OBJECTS ;; vector, in the call to any RELEASE-OBJECT for that OBJECT-POOL 0 :type (or null array-index) :read-only nil) (name (make-symbol "Anonymous Object Pool") ;; NB: using the SXHASH-KEY type in an interest of support for ;; portable object-pool naming onto arbitrary application-specific ;; naming schema :type sxhash-key :read-only t) ;; TBD: Porting this pattern onto C callbacks @ GTK+ (initialize-new-function ;; ... :type function :read-only t ) (initialize-exists-function ;; ... :type function :read-only t ) (deinitialize-exists-function ;; ... :type function :read-only t ) (pool-write-guard ;; ... (impl-ecase ((and :SBCL :SB-THREAD) (error "Uninitialized...")) (:SBCL nil)) :type (impl-ecase ;; FIXME: This may not parse well, during DEFSTRUCT eval. ;; ;; Consider DEFTYPE WRITE-GUARD w/ IMPL-ECASE ;; ;; TBD: "PORTING THIS" onto the modal (R/W) locks API avl in CCL ((and :SBCL :SB-THREAD) SB-THREAD:MUTEX) (:SBCL null)) :read-only t) ) (defconstant* +object-meta-pool+ (make-hash-table :test #'equal #+SBCL :synchronized #+SBCL t)) (defmacro define-ftype (args-type values-type &rest which-fns) `(declaim (ftype (function ,args-type ,values-type) ,@which-fns))) (define-ftype (sxhash-key &optional t) (values (or object-pool null) &optional) find-object-pool) (defun find-object-pool (name &optional errorp) (multiple-value-bind (pool fp) (gethash name +object-meta-pool+) (declare (type boolean fp)) (cond (fp (values pool)) (errorp (error "No object pool registered for name ~S" name)) (t (values nil))))) ;; NB This assumes that no scheduling concern may occur between ;; generalized tasks of (A) object-pool initialization and ;; (B) subsequent access for retrieving any single named ;; object pool onto +OBJECT-META-POOL+ #+TBD (declaim (ftype (function (...) (values object-pool boolean &optional)) ensure-object-pool)) #+TBD (defun ensure-object-pool (name ..args check-initialized-for-args-p) ;; NAME := SXHASH-KEY (let ((pool (find-object-pool name nil))) (cond (pool (values pool) nil) (t (setq pool (frob-new-pool name ..args)) (setf (gethash name +object-meta-pool+) pool) (values pool t))))) #+TBD (defun allocate-object (initarg pool)) ;; ^ INITARG := single value for the object pool's INITIALIZE-NEW-FUNCTION ;; or first arg for the object pool's INITIALIZE-EXISTS-FUNCTION ;; ^ may return an object previously stored in the pool members vector, ;; or a newly created object, when the pool is empty #+TBD (defun release-object (object pool)) ;; ^ If pool is full, discard OBJECT and release the pool members lock, otherwise store OBJECT. ;; If stored, call the pool's deinitialize-exists-function on the object ;; then release the pool members lock ;; SUBSQ: Create an OBJECT-POOL of implementation-specific mutex/... objects ;; for usage in GUARDED-FUNCALL. NB: Ensure that this singular ;; object pool will be accessed by direct reference, not via its name ;; -- (defstruct (guarded-funcall (:constructor %mk-guarded-funcall (function))) (function (load-time-value #'(lambda () (error "Uninitialized GUARDED-FUNCALL-FUNCTION")) t) :type function :read-only t) #+(and SBCL SB-THREAD) ;; NB: SBCL -- as yet -- does not provide nay intrinsic support for ;; modal (read/write) locking, vis a vis the POSIX threads API, in ;; any build. Considering some concerns as may attend with ;; arbitrary patches onto arbitrary calling conventions within ;; arbitrary operating systems on arbitrary hardware/machine ;; architectures, rather than trying to port any methodology for ;; modal read/write locking onto SBCL, this implementation-specific ;; code will use exclusive (write) locks for every access to a ;; guarded form, in SBCL. As such, it may be assumed to not be as ;; theoretically responsive for applications in which any ;; significant number of non-exclusive "read" locks would be ;; useful -- assuming any significant number of concurrent ;; accesses to individual objects held under any exclusive ;; GUARDED-FUNCALL-WRITE-GUARD. ;; ;; NB: While a GUARDED-FUNCALL-WRITE-GUARD is being checked, initialized, ;; or freed, the singular +WRITE-GUARD-1+ must be held ;; within the calling thread. This should serve to ensure safe ;; conccurrent access to individual GUARDED-FUNCALL-WRITE-LOCk ;; objects, and thus should serve to allow for safely initializing ;; a GUARDED-FUNCALL-WRITE-LOCK from the GUARDED-FUNCALL-WRITE-GUARD-POOL[TBD], ;; pursuant of making a dynamically guarded funcall to the ;; GUARDED-FUNCALL FUNCTION, as guarded with an allocated ;; WRITE-GUARD, -- "In Theory". ;; ;; .. if it may not serve to make the GUARDED-FUNCALL WRITE-GUARD, in ;; effect, redundant. ;; ;; [Indemnification Clause Here] ; (write-guard ;; TBD: Whether this may be implemented as a semaphore in the SBCL ;; SB-THREAD API, together with +WRITE-GUARD-1+ nil :type (or null sb-thread:mutex ) :read-only nil )) ;; NB: subsq of development of DEFPORTABLE.LISP, ;; continue implementing GUARDED-FUNCALL
17,065
Common Lisp
.lisp
379
39.709763
95
0.654679
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
3a9f7091dcc9bff3c47aef9966dbabb6cd9e68d73a8683c3233370fff24b9191
29,287
[ -1 ]
29,288
defportable.lisp
thinkum_ltp-main/src/main/lsp/mt/defportable.lisp
;; defportable.lisp - Portable Signature Definition and Implementation in Lisp ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation onto SB-THREAD ;; ;;------------------------------------------------------------------------------ #| Design Notes Concerning applications, refer to ltp-main:src/main/lsp/stor/README.md Usage Cases - Synopsis - cf. FEATUREP and ./guarding.lisp [MT] (Portability across CL implementations) - CommonIDE asn1-proto.lisp - Local API (IR) and ASN.1 tools interop. - CommonIDE Generalized Widgets - GLib, GDK, GTK+ (GNOME) - CommonIDE Generalized Widgets - JNI in Dalvik/Art (Android) Design State - Synopsis: Early prototype, APIs - Meta-Object Signature - Implementation Feature Set - cf. FEATUREP - Implementation Section, per (A) Source System, in Definition (B) Active Feature Set, in Evaluation - Meta-Object Implementation and Implementation-Signature Binding w/ Informative Feature Set storage |# (in-package #:ltp/common) (defstruct (signature (:constructor)) (name (mk-lf (make-symbol "Unnamed Signature")) :type sxhash-key :read-only t) (kind (mk-lf (make-symbol "Unspecified Kind")) :type symbol :read-only t) (docs ;; TBD: DOCS handling for FUNCTION-SIGNATURE, VARIABLE-SIGNATURE ;; ;; NB: DEFPORTABLE-VALIDATE is not a declarations iterator nil :type (or simple-string null) :read-only nil)) (defstruct (single-signature (:constructor) (:include signature)) ;; A class for program meta-object signatures such that may be ;; provided, in each, with a single implementation ;; ;; NB: Juxtaposed to (TBD) CLASS-SIGNATURE ;; such that may be provided with multiple implementations (impl ;; FIXME rename => implementation nil ;; NB may be EQ to NAME, portably, for any implemented variable-signature ;; ;; FIXME if this was implemented with a portable CLOS-like semantics, ;; (SLOT-BOUNDP THUNK 'IMPLEMENTATION) would serve in appliations, ;; alternate to storing NIL in this slot, for any unbound impl. ;; ;; In which case, :access (:read :write-once) may apply ;; :type (or function symbol) ;; or instance, condition, ... :read-only nil) (impl-feature-set ;; NB: To be provided by DEFIMPLEMENTATION nil :type (or symbol cons) :read-only nil)) (defstruct (function-signature (:include single-signature) ;; TBD: FTYPE declaration for FUNCTION-SIGNATURE (:constructor make-function-signature (kind name args &optional arg-types values-type docs))) (name (mk-lf (make-symbol "Unnamed Function Signature")) :type (or (cons symbol t) symbol) :read-only t) (args nil :type list :read-only t) (arg-types nil :type list :read-only t) (values-type nil :type list :read-only t)) (defstruct (variable-signature (:include single-signature) ;; TBD: TYPE declaration for VARIABLE-SIGNATURE (:constructor make-variable-signature (kind name &optional (type t) docs))) (name (mk-lf (make-symbol "Unnamed Variable")) :type symbol :read-only t)) #+TBD (defstruct (class-template (:include signature)) ;; .... ;; NB: May have multiple IMPLEMENTATION ;; as per a generalized class structure prototype ;; TBD: Analogy onto C++ template forms ) ;; -- #+THISv1 (defun bind-impl (inst signature) ;; emit a specific style-warning if SIGNATURE already has a bound ;; IMPLEMENTATION not EQ to INST ) ;; -- (defvar *avec-initial-length* 8) ;; NB: Mostly arbitrary default (defmacro mk-avec (&key (length nil lenp) (fill-pointer nil fp) (initial-contents nil cp)) (with-symbols ( %contents %lenc %dim %fp) `(let* (,@(when cp `((,%contents ,initial-contents))) (,%lenc ,(when cp `(length ,%contents))) (,%dim ,(cond (lenp length) (cp %lenc) (t (quote *avec-initial-length*)))) (,%fp ,(cond (fp fill-pointer) (cp %lenc) (t 0)))) (make-array ,%dim :fill-pointer ,%fp :adjustable t ,@(when cp `(:initial-contents ,%contents)))))) ;; (mk-avec :length 10) ;; (array-dimensions (mk-avec)) ;; => (8) ;; (fill-pointer (mk-avec :fill-pointer 5)) ;; => 5 ;; (array-dimensions (mk-avec :fill-pointer 5)) ;; => (8) ;; (fill-pointer (mk-avec :initial-contents '(1 2 3))) ;; => 3 ;; (fill-pointer (mk-avec :fill-pointer 5 :initial-contents '(1 2 3))) ;;;; FIXME - the failure case is peculiar here w/ SBCL (1.4.16.debian) ;;;; i.e warn about the fill-pointer, but error about the nr. args ;;;; ;;;; Well-formed expr, NB: ;; (macroexpand-1 (quote (mk-avec :fill-pointer 5 :initial-contents '(1 2 3)))) ;; (fill-pointer (mk-avec :fill-pointer 3 :initial-contents '(1 2 3))) ;; => 3 ;; (fill-pointer (mk-avec :initial-contents '(1 2 3))) ;; => 3 (defmacro push-avec (elt whence) `(vector-push-extend ,elt ,whence *avec-initial-length*)) ;; -- (defconstant +implementation+ (let ((typ (lisp-implementation-type))) (multiple-value-bind (s alloc) (find-symbol typ (mk-lf (find-package :keyword))) (if alloc (values s) (error "~<Initialization not supported for +IMPLEMENTATION+~>~ ~< on implementation ~S~>" typ)))) "Keyword symbol denoting this [lisp-implementation-type] as per well-known *FEATURES* symbols") ;; TOPIC: System Structure & Reflection (defstruct (impl-section ;; FIXME - abbreviated 'impl' prefix is inconsistent ;; per DEFIMPLEMENTATION (:constructor %mk-impl-section (name &key (forms (mk-avec)) (implementations (mk-avec)) #+TBD_NESTED_FS (subsections (mk-avec)))) (:constructor mk-impl-section (name &optional (%forms nil %formsp) &aux (forms (cond (%formsp (mk-avec :initial-contents %forms)) (t (mk-avec))))))) ;; TBD ;; - IMPL-SECTION source location, w/ support per ;; - named filesystems - local to projects, site ;; - truename for load file ;; - load-file pathname for load file ;; - IMPL-SECTION onto LTP EO ;; - IMPL-SECTION onto LLVM ;; - IMPL-SECTION onto JLS - Static analysis (pre-JNI) (name (mk-lf (make-symbol "Unnamed Feature Section")) :type symbol :read-only t) (finalized-p :type boolean ;; NB: if FINALIED-P, the IMPLEMENTATIONS, FORMS, and non-nil SUBSECTIONS ;; contents should all be simple vectors for purpose of iteration :read-only nil) (forms (mk-avec) ;; TBD: consider using EQ hash-tables onto (SXHASH NAME) (EQX-Table) :type (array t (*)) :read-only nil) #+NIL (implementations ;; NB - bind the implementation to the signature form itself (mk-avec) ;; TBD: consider using EQ hash-tables onto (SXHASH NAME) :type (array t (*)) :read-only nil) #+TBD_NESTED_FS (subsections ;; NB: A file represents a feature section - source locations nil ;; TBD: consider usihg an EQ hash-table onto NAME here, when non-nil :type (or null (array t (*))) :read-only nil) ) ;; (make-impl-section (make-symbol "Unbound") '(1 2 3)) ;; (make-impl-section (make-symbol "Unbound")) #+TBD (defun signature-declarations (...)) #+TBD (defun signature-implemented-p (signature-spec whence-spec)) ;; ^ may return a second value, the implementation (when defined to whence) #+TBD (declaim (type impl-section +null-impl-section+ *section*)) #+TBD (defconstant* +null-impl-section+ (make-impl-section nil)) #+TBD (defvar *section* +null-impl-section+) #+TBD (defun find-impl-section (name #+TBD_NESTED_FS &optional #+TBD_NESTED_FS (whence (find-feature-sectrion nil))) ;; TBD: impl-section nesting ) ;; -- (defmacro define-decl-kind (kind (&rest config) &rest specification) ;; NB: Definition form for handlers for [TBD] ;; &PUNTING -- see examples below ;; - DEFINE-DECL-KIND DEFUN ;; - TBD (??) shared forms for ;; DEFINE-DECL-KIND LTP/COMMON:DEFUN* ;; - NB: DEFUN* might be ultimately disfavored as any manner ;; of a convenience form, pursuant of (A) normal, ;; portable FTYPE declrations at top-level, and ;; (B) signature forms as being developed in this system ;; DEFINE-DECL-KIND DEFMACRO (w/ generic signature ??) ;; DEFINE-DECL-KIND DEFGENERIC (??) ;; - TBD DEFINE-DECL-KIND DEFVAR ;; - TBD (??) shared forms for ;; DEFINE-DECL-KIND DEFPARAMETER ;; DEFINE-DECL-KIND DEFCONSTANT ;; DEFINE-DECL-KIND LTP/COMMON:DEFCONSTANT* ;; ) (define-decl-kind defun () (:parse-signature (name args &rest decls-docs) (let (docs type-decls values-decl parser-context ftype-types) (labels ((duplicate-err (kind init subsq) (error "~<Duplicate ~A for ~S ~ defun signature.~>~< Initial: ~S>~< Second: ~S~>" kind name init subsq)) (unrecognized-err (spec) (error "~<Unrecognized ~S parameter: ~S~>" context spec)) (add-type-decl (decl) (destructuring-bind (kwd type &rest args) decl (declare (ignore kwd)) (dolist (a args) ;; FIXME - does not check for duplicates, here (push (cons a type) type-decls)))) (find-type-decl (name) (assoc name type-decls :test #'eq)) (add-ftype-elt (elt) (npushl elt ftype-types)) (find-keyword-parm (spec) (let ((first (car spec))) (etypecase first (symbol first) (cons (cadr first))))) (find-keyword-key (spec) (let ((first (car spec))) (etypecase first (symbol (intern (symbol-name first) a (mk-lf (find-package :keyword)))) (cons (car first)))))) (dolist (elt decls-docs) (etypecase elt (string (cond (docs (duplicate-err "documentation strings" docs elt)) (t (setq docs elt)))) (cons (case (car elt) (type (add-type-decl elt)) (values (cond (values-decl (duplicate-err "values declarations" values elt)) (t (setq values-decl elt)) )))))) ;; iterate across ARGS to match type decls for FTYPE decl (dolist (elt args) (etypecase elt (symbol (cond ((position (the symbol elt) (the cons lambda-list-keywords) :test #'eq) (setq parser-context elt) (add-ftype-elt elt)) (t (let ((typ (find-typ-decl elt))) (add-ftype-elt (if typ (cdr typ) t)))))) (cons ;; assumption: ELT represents an &OPTIONAL, &KEY, or &AUX parameter ;; ;; NB: Convenience for &KEY type decls in signtaures (case context (&optional (let ((typ (find-type-decl (car elt)))) (add-ftype-elt (if typ (cdr typ) t)))) (&key (let* ((param (find-keyword-param elt)) (kwd (find-keyword-key elt)) (typ (find-type-decl param))) (add-ftype-elt (list kwd (if typ (cdr typ) t))))) (&aux (let ((typ (find-type-decl (car elt)))) (add-type-elt (if typ (cdr typ) t)))) (t (unrecognized-err elt)))))) (unless values-decl (setq values-decl (mk-lf (quote (values t &optional))))) ;; ... and define - see TBD_TEST for DEFSIGNATURE, below (make-function-signature 'defun name args ftype-types values-decl docs)))) #+TBD (:unparse-declarations ...) ;; NB: Still need to "Wire" each implementation signature, ;; feature-set, and implementation form together for each signature in ;; each context ;; - cf. SIGNATURE-IMPL-FEATURE-SET ;; and also DEFIMPLEMENTATION (:parse-implementation (name args &rest forms) (declare (ignore args forms)) ;; &PUNTING - return a value suitable as an SXHASH key (cons 'defun name))) #+TBD (define-decl-kind defvar () (:parse-signature (name &rest decls-docs) ) (:parse-implementation (name &optional (init init-p) docs) )) #+TBD (defun parse-declaration-signature (form &optional (context *section*)) ;; TBD: May be reuesd in DEFSIGNATURE and DEFIMPLEMENTATION (labels ((parse-decl-docs (form) ) (add-decl (name &rest info) ;; per *SECTION* )) (destructuring-bind (kind name &rest info) form (ecase kind ((defun defun*) (make-function-signature kind name ...parse-info...) ) ((defvar defconstant defconstant* defparameter) (make-variable-signature kind name ...parse-info...) ) ;; ...other-handler... in CONTEXT )))) #+THISv1 ;; syntax TBD (defmacro declare-section (section-name form)) ;; ^ declare a build-time section by section name .. TBD FORM #+THISv1 (defmacro define-feature-set (name expr)) ;; ^ declare a build-time feature-set ;; ;; - TBD impl-section+ forms to a feature-set, for purpose of sytems review #+TBD (defmacro defsection (name ....) ;; vis a vis *CONTEXT* ;; ;; see also: Knuth's WEB ) (defmacro defsignature ((&optional (context *context)) expr) ) ;; ^ declare a build-time signature ... #+TBD (defmacro signature-declaim (signature &optional (whence *context*)) ) #+TBD_TEST (defsignature () (defun frob-signature (a &key ((:b %b) nil) (c nil c-p) &rest %other &aux (other (when %other (coerce %other 'simple-vector)))) (values t &optional) (type fixnum a %b c) (type list %other) (type (or simple-vector null) other) "frob-signature function description")) (defmacro defimplementation ((when-features &optional (context *context*)) expr) ;; ... binding the result of the evaluation of EXPR to its parsed EXPR name, ;; under *CONTEXT* .. during compile?? ;; ... Otherwise only returning the result of the evaluation of EXPR? ) #+TBD_TEST (defsignature (#.+implementation+) (defun frob-signature (a &key ((:b %b) 0) (c 0 c-p) &rest %other &aux (other (when %other (coerce %other 'simple-vector)))) (list (+ a (/ %b c)) other))) #+TBD (defun clear-impl-section-table ()) ;; ^ begining at +null-impl-section+, conduct a depth-first traversal ;; to DEALLOCATE-IMPL-SECTION, thus freeing each decl, impl object ;; for purpose of GC #+TBD_TESTS (setq *context* (define-feature-set +thunk-1+)) #+TBD_TESTS (defsignature () (defconstant +global-thunk+)) #+TBD_TESTS (defsignature () (defconstant +global-unthunk+)) #+TBD_TESTS (defimplementation ((:context #.(feature-set (quote +thunk-1+))) (:case (get-impl-symbol))) (defconstant* +global-thunk+ "Some well-known impl-specific symbol")) #+TBD_TESTS (deportable-validate :context '+thunk-1 :case (get-impl-symbol) :behavior error) ;; ... #+THISv1 (defmacro fs (name)) ;; ^ dereference a build-time feature-set by name #+TBD (defun parse-definition-signature (form &optional (context *section*))) #+THISv1 (defmacro defportable-define (section feature-set eval-form)) ;; ^ evaluate EVAL-FORMS as a build-time section IFF FEATURE-SET ;; denotes a "True" feature set #+TBD (defmacro defportable-validate (section &optional (policy :warn))) ;; ^ emit any warnings/errors - per TBD policy - for any elements of the ;; named section that are not defined in the implementation.
17,367
Common Lisp
.lisp
458
29.733624
102
0.580459
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
f2a4c1935276116c298bbb7cdf07206f0ef43a5ae9a1344d3c324afafeb4ff40
29,288
[ -1 ]
29,289
common-impl-type.lisp
thinkum_ltp-main/src/main/lsp/impl/common-impl-type.lisp
;; common-impl-type.lisp - Implementation Support for Type Sys. Reflection, SBCL ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp/common/mop) #+TBD (defsignature defun type-defined-p (spec) (:parameters type-designator) (:values boolean &optional) (:documentation "Return a boolean value indicating whether the expression SPEC denotes a type description, as per all named and derived type definitions and class definitions in the null lexical environment")) #+SBCL (defun type-defined-p (spec) (declare (type type-designator) (values boolean &optional)) ;; NB: Operates on the null lexical environment, intrinsically (cond ((classp spec) ;; TBD - Verify this onto applications, across implementations (class-finalized-p spec)) (t ;; Initial Prototype, NB (let ((impl-ctype (sb-kernel:specifier-type spec))) (not (typep impl-ctype 'sb-kernel:unknown-type)))))) ;; (type-defined-p (make-symbol "Frob")) ;; => NIL ;; TBD ... recursive processing for TYPE-DEFINED-P ;; (type-defined-p `(or ,(make-symbol "Frob") string)) ;; =(??)=> T ;; Not ideal for applications, NB
1,675
Common Lisp
.lisp
39
39
80
0.635583
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
2dcd05d4b7321d555a3e39bb61a1435a31ac7dd34f150a027992882db37c56bb
29,289
[ -1 ]
29,290
sstor-enum.lisp
thinkum_ltp-main/src/main/lsp/stor/sstor-enum.lisp
(in-package #:ltp/common) ;; NB: Concerning development of the storage protocol ;; and subsequent applications, refer to ;; ltp-main:src/main/lsp/stor/README.md (defpackage #:ltp/common/mop/enum (:use #:ltp/common/singleton #:ltp/common/mop #:ltp/common #:cl)) (in-package #:ltp/common/mop/enum) ;; ^ tmp location for this src ;; -- ENUM extension onto LTP SINGLETON ;; FIXME: Move this to a separate source file; ;; consider defining this in LTP itself (defgeneric %storage-context-members (enum)) (defgeneric (setf %storage-context-members) (new enum)) (defclass enum () ;; FIXME: Provide a guard (mutex e.g) onto the %MEMBERS buffer ;; ;; Use R/W mutexes, when such an interface is provided by the ;; implementation - e.g in CCL ((%members ;; access varies depending on the subclass, for each of DYNAMIC-ENUM ;; and STATIC-ENUM classes ;; ;; should not be unbound in implementation classes :type sequence) (member-class :initarg :member-class ;; :access :read-only ;; should not be unbound :type class-designator) (member-key-slot :initarg :member-key-slot ;; :access :read-only ;; should not be unbound :type symbol) (member-key-accessor :initarg :member-key-accessor ;; :access :read-only ;; should not be unbound :type function) (member-find-function :initarg :member-find-function ;; :access :read-only ;; should not be unbound :type function) )) (defmethod shared-initialize :around ((instance enum) slots &rest initargs &key (members nil memp) (%members nil %memp) &allow-other-keys) (declare (ignore instance slots initargs)) ;; In effect, validate INITARGS before dispatching to primary method (when (and memp %memp) (simple-program-error "~<Conflicting initialization arguments:~>~< ~s (value ~s)~>~ ~< and ~s (value ~s)~>" :members members :%members members)) (call-next-method)) ;; -- (defclass dynamic-enum (enum) ;; Assumption: Static ENUM definitions may be initialized once, then ;; would be read-only ;; ;; FIXME: Ensure such a semantics, for the ENUM %MEMBER slot of a ;; STATIC-ENUM class ((member-register-function ;; :access :read-only ;; may be unbound :initarg :member-register-function :type function) (member-remove-function ;; :access :read-only ;; may be unbound :initarg :member-remove-function :type function))) (defclass array-storage-context () ((%members :type array))) (defclass expandable-vector-storage-context (array-storage-context) ((%members :initarg :%members :accessor %storage-context-members ;; see also: :SYNCHRONIZE (NB) ;; :synchronize (:read :write) :type (array t (*))))) (defmethod initialize-storage ((context expandable-vector-storage-context)) (unless (slot-boundp context '%members) (setf (%storage-context-members context) (make-array 8 :fill-pointer 0))) (values context)) ;; -- Dynamic Deallocation for Storage Objects (defgeneric storage-empty-object (storage #+NIL context)) ;; cf. DEALLOCATE-STORAGE (defgeneric deallocate-storage (obj #+NIL context) ;; NB: This assumes that every reachable object within OBJ can be ;; destructively modified. As such, this does not operate on ;; implementation classes. ;; ;; FIXME This does not operate onto any manner of portable reference ;; pointers, in Common Lisp (:method ((buff null)) ;; no-op (values)) (:method ((buff cons)) ;; NB: does not perform any circular list detection. ;; ;; Any calling program should ensure that there are no circular ;; lists in the respective OBJ (deallocate-storage (cdr buff)) (setf (cdr buff) nil) (deallocate-storage (car buff)) (setf (car buff) nil) (values t)) (:method ((buff simple-string)) ;; no-op (values)) (:method ((buff simple-bit-vector)) ;; no-op (values)) #++NIL (:method ((buff vector)) (multiple-value-prog1 (call-next-method) (when (array-has-fill-pointer-p buff) (setf (fill-pointer buff) 0)))) #+NIL (:method ((buff array)) (dotimes (n (apply #'* (array-dimensions buff)) (values t)) (deallocate-storage (row-major-aref buff n)) (setf (row-major-aref buff n) (storage-empty-object buff #+NIL context)))) (:method ((buff fixnum)) ;; no-op (values)) (:method ((buff complex)) ;; portably, no-op [FIXME] (values)) (:method ((buff symbol) #+NIL (context t)) ;; NO-OP in this context [PROTOTYPE] (values)) #+NIL (:method ((buff symbol)) ;;; FIXME - limit this onto a specific context ;; ;; NB: This will not affect any existing references to a symbol (unintern buff) (values t))) ;; (deallocate-storage (make-array 10 :fill-pointer 10) nil) ;; -- (defmethod close-storage ((context expandable-vector-storage-context)) (cond ((slot-boundp context '%members) (deallocate-storage (%storage-context-members context) #+NIL context) (slot-makunbound context '%members) (values t)) (t (values)))) (defclass simple-dynamic-enum (expandable-vector-storage-context dynamic-enum) ()) (defmethod shared-initialize ((instance simple-dynamic-enum) slots &rest initargs &key (members nil memp) (%members nil %memp) &allow-other-keys) (let (initargs-updated) (macrolet ((next-method () `(cond (initargs-updated (apply #'call-next-method instance slots initargs)) (t (call-next-method)))) (update (arg value) `(prog1 (setf (getf initargs ,arg) ,value) (setq initargs-updated t)))) (when memp (when %memp (simple-program-error "~<Conflicting initialization arguments:~>~< ~s (value ~s)~>~ ~< and ~s (value ~s)~>" :members members :%members members)) ;; ensure that an appropriate adjustable vector is created for the ;; provided :members value (let ((len (length members))) (update :%members (make-array len :element-type t :initial-contents members :fill-pointer len)))) (next-method)))) (defgeneric enum-members (enum) (:method ((enum simple-dynamic-enum)) (when (slot-boundp enum '%members) (coerce (the (array t (*)) (%storage-context-members enum)) 'list)))) (defgeneric (setf enum-members) (new-value enum) (:method ((new-value list) (enum simple-dynamic-enum)) (setf (enum-members enum) (coerce (the list new-value) 'simple-vector))) (:method ((new-value vector) (enum simple-dynamic-enum)) (cond ((array-has-fill-pointer-p new-value) (setf (%storage-context-members enum) new-value)) (t (let ((len (length new-value))) (setf (%storage-context-members enum) (make-array len :element-type t :fill-pointer len :initial-contents new-value))))))) (declaim (ftype (function (t) (values list &optional)) enum-members)) (declaim (ftype (function (sequence t) (values sequence &optional)) (setf enum-members))) ;; ^ FIXME limit FTYPE arg-type decls onto defined methods, once declared (eval-when () ;; TD: Instance tests - DYNAMIC-ENUM Initialization, Accessors (defparameter *enum* (make-instance 'dynamic-enum :members (list "A" "B" "C" "D"))) (enum-members *enum*) (%storage-context-members *enum*) (vector-push-extend "E" (%storage-context-members *enum*)) (enum-members *enum*) (setf (enum-members *enum*) (reverse (enum-members *enum*))) (enum-members *enum*) (let* ((buf (%storage-context-members *enum*)) (n (length buf)) (newbuf (make-array n :element-type t :fill-pointer n :initial-contents (nreverse buf)))) (values (setf (enum-members *enum*) newbuf) (eq (%storage-context-members *enum*) newbuf))) ;; last value => T ) ;; ---- #+NIL ;; simple example NB (defsingleton dynamic-enum-class (dynamic-enum) ()) ;; -- (defclass static-enum (enum) ()) (defclass simple-vector-storage-context (array-storage-context) ;; NB: Leaving the semantics undefined for INITIALIZE-STORAGE ;; of a SIMPLE-VECTOR-STORAGE-CONTEXT ;; ;; Similarly, for CLOSE-STORAGE ((%members :accessor %storage-context-members ;; :read-only t :type simple-vector))) (defclass simple-static-enum (simple-vector-storage-context static-enum) ()) (defmethod shared-initialize ((instance simple-static-enum) slots &rest initargs &key (members nil memp) #+NIL (%members nil %memp) &allow-other-keys) (let (initargs-updated) (macrolet ((next-method () `(cond (initargs-updated (apply #'call-next-method instance slots initargs)) (t (call-next-method)))) (update (arg value) `(prog1 (setf (getf initargs ,arg) ,value) (setq initargs-updated t)))) (when memp ;; ensure that an appropriate simple vector is created for the ;; provided :members value (update :%members (coerce members 'simple-vector))) (next-method)))) (defmethod enum-members ((enum simple-static-enum)) (when (slot-boundp enum '%members) (coerce (the simple-vector (%storage-context-members enum)) 'list))) ;; TD: Instance tests - STATIC-ENUM Initialization, Accessors ;; ---- #+NIL ;; simple example NB (defsingleton static-enum-class (static-enum) ()) ;; NB ;; (class-finalized-p (find-class 'static-enum-class)) ;; => T ;; -- (eval-when () (defmacro define-singleton-enum (name (&rest supertypes) (&rest slots) (&rest decls) &rest params) ;; API Constructor Macro ;; Notes ;; ;; - Params: Syntax ;; ;; - Refer to direct slot definitions of the classes ;; ENUM and DYNAMIC-ENUM. Excepting the slot definition for the ;; %MEMBERS slot, those class direct slots' other initialization ;; aruments may be provided via the PARAMS section of this macro. ;; ;; - Furthermore - NB: DEFINE-SINGLETON-ENUM somewhat like DEFSTRUCT ;; (:CONC-SUFFIX &optional <NAME>) ;; (:RESISTER-CONC-NAME &optional <NAME>) ;; (:FIND-CONC-NAME &optional <NAME>) ;; (:REMOVE-CONC-NAME &optional <NAME>) ;; ;; NB: It would be an error to specify a (:CONC-SUFFIX) with null ;; <NAME> and -- in the same DEFINE-SINGLETON-ENUM -- null <NAME> ;; for any one or more of the :RESISTER-CONC-NAME, :FIND-CONC-NAME ;; and :REMOVE-CONC-NAME options in PARAMS ;; NB: This macro will destructively modify a copy of PARAMS (let ((%params (copy-list params)) conc-suffix reg-prefix reg-name find-prefix find-name remove-prefix remove-name ;; subclasses ) (macrolet ((pop-param (name) `(let ((n (position (quote ,name) %params :key #'car :test #'eq))) (cond (n (let ((p (nth n params))) (setq params (delete p %params :test #'eq)) (values p))) (t (values nil)))))) ;; replace nested MV GET-ONE-PARAM calls with POP-PARAM (labels ((ensure-symbol-name (name) (etypecase name (string name) (symbol (symbol-name name))))) (setq conc-suffix (pop-param conc-suffix)) (let* ((conc-rest (cdr conc-suffix)) (%conc-suffix (cond ((and conc-suffix conc-rest) (destructuring-bind (suffix &rest n-a) conc-rest (when n-a (simple-program-error "~<Extraneous information ~ in DEFINE-SINGLETON-ENUM~>~< (:CONC-SUFFIX . ~S)~>" conc-rest)) (when suffix (ensure-symbol-name suffix)))) (conc-suffix ;; i.e (:CONC-SUFFIX) ;; => do not define any default enum accessors ;; NB: Ssame effect as (:CONC-SUFFIX NIL) (values nil)) (t (setq conc-suffix (concatenate 'simple-string "-" (symbol-name name))))))) (labels ((mk-default-name (prefix) (cond (%conc-suffix (intern (concatenate 'simple-string (symbol-name prefix) %conc-suffix))) (t (intern (symbol-name prefix)))))) (setq reg-form (pop-suffix register-function)) (unless reg-form (setq reg-form (mk-default-name '#:register))) (cond ((and regp (listp reg-form) (listp (cadr reg-form)))) ;; ^ no-op - interpret value as an implicit defun form ((and regp (null reg-form))) ;; ^ no-op - do not define or store a :register-function (reg-form ;; ^ function name ;; create implicit defun (??) [TBD] (NB At least, store ref to ;; fn - may be forward-referenced) (??) #+TD ;; TBD: DEFUN in the macroexpansion ? (let ((reg-lambda (compute-default-registration-lambda ...))) (setq reg-form `(,name ,@(cdr reg-lamba)))))) (setq find-form (pop-param :find-function)) (unless find-form (setq find-form (mk-default-name '#:find))) (setq remove-form (pop-param :remove-function)) (unless remove-form ;; FIXME: This REMOVE name with null CONC-SUFFIX ;; -- i.e in params (:CONC-SUFFIX) -- would typically ;; override CL:REMOVE. This may typically represent ;; an unwanted side effect of the evaluation. ;; ;; Using a prefix #:DELETE would not improve the ;; matter, ;; ;; As unlikely as (:CONC-SUFFIX) in PARAMS may be, it ;; should be more carefully addressed - in the ;; interest of portable systems programming. ;; ;; Consider adding to the PARAMS syntax: ;; (:RESISTER-CONC-NAME &optional <NAME>) ;; (:FIND-CONC-NAME &optional <NAME>) ;; (:REMOVE-CONC-NAME &optional <NAME>) (setq remove-form (mk-default-name '#:remove))) ;; (compute-default-remove-lambda ...) ;; TBD: for each SPEC in DECLS: Process SPEC via method ;; dispatch (??) Note, hoewver, that this would serve to ;; require that at least one class would be defined for that ;; specialization, before this macro is evaluated in the ;; compiler environment. This, at least, would serve to allow ;; for an extensible protocol for handlign the CDR of each ;; SPEC in a syntax specific to the individual enumerated type `(eval-when (:compile-toplevel :load-toplevel :execute) (defabstract ,name (,@supertypes) (,@slots) ,@params) ;; ... defsingleton for each SPEC in DECLS ... ;; ... decls (FTYPE) and defuns for each enum access ;; function (register, find, remove) ;; return the defined class )))))))) ;; #+NIL ;; (eval-when () ;; enum-proto.lisp - Basic prototyping/Proof of concept ;; -- Implementation Notes ;; ;; NB: As something of a quirk for a purpose of simplifying the ;; implementation, the following prototype uses a SINGLETON semantics ;; for enum container storage. ;; ;; That may be as to denote: The enum storage object -- typically ;; denoted, in the prototype below, as 'whence' -- the storaage object ;; is represented by a singleton class. Although the singleton class ;; protocol is, at this time, still in a state of revision -- namely, ;; in that the exact MAKE-INSTANCE semantics have yet to be completely ;; defined for SINGLETON classes -- this, at persent, will serve to ;; allow for only one storage per class. ;; ;; In further development of this protocol -- towards a manner of an ;; extensible, template-oriented, prototype -- the WHENCE object, as ;; well as any number of accessor functions and types specified below, ;; should be -- in effect -- parameterized, within the corresponding ;; template. ;; ;; ;; In a manner principally independent of the protocol extension onto ;; SINGLETON, this protocol may serve to permit for method definitions ;; and dispatching onto the enum storage class itself, e.g TRIVIAL-ENUM. ;; ;; Regardless, this local object storage and access protocol is ;; implemented with principally non-polymorphic functions. ;; ;; -- Design Notes ;; ;; In a subsequent revision, a semantics may be defined for specifying ;; how any subtypes of an ENUM implementation are to regard any ;; objects as may be, in effect, iherited onto any one or more ENUM ;; supertypes and corresponding implementation objects. Towards an ;; application of such an extension, one might note - in particular - ;; the peculiarities of object import semantics in MOF and UML, such ;; as may be summarized approximately: Prototype on import. ;; ;; ;; The SINGLETON extension onto ENUM has been defined in a manner such ;; as to ensure that the ENUM type and ENUM storage objects -- for any ;; single ENUM type -- are represented, in each, by the same object. ;; ;; The protocol, as illustrated below, utilizes an intermediate ENUM ;; member type, such that an ENUM type is -- in effect -- closed onto. (deftype name () 'symbol) (defclass tenum-member () ;; Trivial Enum Member - or TEM ;; NB IMPL - DEFSINGLETON & ENUM KEY INITARG ((name :initarg :name :type name :reader tenum-member-name))) (defun* make-tem (name) (declare (type symbol name) (values tenum-member &optional)) (values (make-instance 'tenum-member :name name))) (deftype if-exists-symbol () '(member :override :error :ignore nil)) (deftype not-found-symbol () '(member :error :ignore nil)) ;; FIXME - With the present design of DEFSINGLETON, it may be - in ;; effect - impossible to define an initialization method onto the ;; singleton instance itself, without first defining the singleton's ;; class as a forward-referenced class. Once the class is defined, any ;; further initialization methods may be unused. ;; FROB - NB affects all DYNAMIC-ENUM (FIXME) (defmethod shared-initialize :after ((instance dynamic-enum) slots &rest initargs &key &allow-other-keys) (declare (ignore initargs)) (when (or (eq slots t) (and (consp slots) (find '%members slots :test #'eq))) (unless (slot-boundp instance '%members) (setf (slot-value instance '%members) (make-array 8 :fill-pointer 0 :adjustable t))))) ;; (shared-initialize (find-class 'trivial-enum) t) ;;(macroexpand-1 (quote (defsingleton trivial-enum (simple-dynamic-enum) () #+TD (:member-key-test . eq) ;; FIXME/API Design - The following two slots, in effect, will limit ;; the possible applications of this protocol to the domain of CLOS ;; standard objects. (:member-class . tenum-member) (:member-key-slot . name) #+TD (:conc-suffix . #:-tem) ) ;; (class-finalized-p (find-class 'trivial-enum)) ;; => T ;;)) ;; FIXME: Initialize %members slot for TRIVIAL-ENUM ;; (cannot be done via shared-initialize, in this configuration) ;; NB: ;; (typep (find-class 'trivial-enum) 'dynamic-enum) ;; => T ;; (enum-members (find-class 'trivial-enum)) ;; => NIL ;; supported now, subsequent of the DEFSINGLETON update (defun* position-of-tem (name &optional (not-found :error)) ;; NB: This function should operate onto a recursive read/write ;; lock - such that may already be held for :write when this ;; function is reached. If the lock is not already held for :write ;; then it should be captured for :read within this function (declare (type name name) (type not-found-symbol not-found) (values (or array-dim null) &optional)) (let* ((whence (find-class 'trivial-enum)) (buf (%storage-context-members whence)) (n (position name (the vector buf) :key #'tenum-member-name))) (declare (dynamic-extent whence)) (cond (n (values n)) (not-found (ecase not-found (:error (error "No item found for name ~s in ~s" name whence)) ((:ignore nil) (values nil)))) (t (values nil))))) (defun* find-tem (name &optional (not-found :error)) ;; NB: This function should operate onto a recursive read/write ;; lock - such that may already be held for :write when this ;; function is reached. If the lock is not already held for :write ;; then it should be captured for :read within this function (declare (type name name) (type not-found-symbol not-found) (values (or tenum-member null) boolean &optional)) (let* ((whence (find-class 'trivial-enum)) (buf (%storage-context-members whence)) (n (position-of-tem name not-found))) (declare (dynamic-extent whence)) (cond (n (values (aref (the vector buf) n) t)) (not-found (ecase not-found (:error (error "No item found for name ~s in ~s" name whence)) (:ignore (values nil nil)))) (t (values nil nil))))) (defun* register-tem-1 (obj &optional (if-exists :error)) ;; NB: This function should operate onto a recursive read/write ;; lock, ensuring that the lock is held for :write throughout this ;; and any local, dispatching function - including POSITION-OF-TEM (declare (type tenum-member obj) (if-exists-symbol if-exists) (values (or tenum-member null) &optional)) (let* ((whence (find-class 'trivial-enum)) (buf (%storage-context-members whence))) (declare (dynamic-extent whence)) (labels ((dispatch-reg-new () ;; FIXME When Debug - Emit a signal here (vector-push-extend obj buf) (values obj)) (dispatch-override (n) ;; FIXME When Debug - Emit a signal here (setf (aref buf n) obj) (values obj)) (dispatch-ignore () ;; FIXME When Debug - Emit a signal here (values nil))) (let* ((name (tenum-member-name obj)) (n (position-of-tem name nil)) (mem (when n (aref buf n)))) (cond ((and n (not (eq mem obj))) (ecase if-exists (:error ;; NB: Could use CERROR (error "~<Attempted to register duplicate item ~s~> ~< for name ~s~>~< as registered for ~s~>~< in ~s~>" obj name mem whence)) (:override (dispatch-override n)) ((:ignore nil) ;; no-op - other obj MEM already registered (dispatch-ignore)))) (n (dispatch-ignore)) ;; no-op - OBJ already registered (t (dispatch-reg-new))))))) (defun register-tem (name &optional (if-exists :error)) ;; NB: hold a recursive write lock for WHENCE ;; (declare ...) ;; NB IF-EXISTS semantics - :OVERRIDE :ERROR :IGNORE (labels ((dispatch-reg () (let ((obj (make-tem name))) (register-tem-1 obj :override)))) (let* ((whence (find-class 'trivial-enum)) (n (position-of-tem name nil))) (declare (dynamic-extent whence)) (cond (n (ecase if-exists (:error (error "~<Attempted to register duplicate item~> ~< for name ~s~>~< in ~s~>" name whence)) ((:ignore nil) (values nil)) (:override (dispatch-reg)))) (t (dispatch-reg)))))) (defun remove-tem-1 (obj &optional (not-found :error) no-check) ;; NB: hold a recursive write lock for WHENCE ;; (declare ...) ;; NB Shared NOT-FOUND semantics w/ REMOVE-TEM (let* ((whence (find-class 'trivial-enum)) (buf (%storage-context-members whence))) (declare (dynamic-extent whence)) (labels ((dispatch-remove () (delete obj (the vector buf) :test #'eq))) (cond (no-check (dispatch-remove)) (t (ecase not-found (:error (let ((%obj (find obj buf :test #'eq))) (cond (%obj (dispatch-remove)) (t (error "No item ~S found in ~S" obj whence))))) ((:ignore nil) (dispatch-remove)))))))) (defun remove-tem (name &optional (not-found :error)) ;; NB: hold a recursive write lock for WHENCE ;; (declare ...) ;; NB NOT-FOUND semantics - ::ERROR IGNORE NIL (labels ((dispatch-remove (obj) (remove-tem-1 obj nil t))) (multiple-value-bind (%obj foundp) (find-tem name not-found) (cond (foundp (dispatch-remove %obj)) (t (values nil)))))) ;; T.D: enum-proto-test.lisp & AFFTA (eval-when () (defparameter *t1* (register-tem :tem-1)) (eq (tenum-member-name *t1*) :tem-1) (eq (find-tem :tem-1) *t1*) (defparameter *t2* (register-tem :tem-2)) (eq (find-tem :tem-2) *t2*) (remove-tem :tem-2) (remove-tem :tem-2 :ignore) (eq (find-tem :tem-1) *t1*) (defparameter *t3* (register-tem :tem-1)) ;; .. err (eq (find-tem :tem-1) *t1*) ;; => T (defparameter *t3* (register-tem-1 (make-tem :tem-1) :override)) (eq (find-tem :tem-1) *t3*) (%storage-context-members (find-class 'trivial-enum)) ) ;; )
27,652
Common Lisp
.lisp
673
31.506686
80
0.57776
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
5c9b87f55602227cb2eaf6742c7d7c2c73d572895514a58814e0ec48462e227f
29,290
[ -1 ]
29,291
iter.lisp
thinkum_ltp-main/src/main/lsp/stor/iter.lisp
;; iter.lisp - generalized formalisms for typed iteration ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation onto SB-THREAD ;; ;;------------------------------------------------------------------------------ (defpackage #:ltp/common/iter (:use #:ltp/common/mop #:ltp/common #:cl)) ;; NB: Towards further formalization in this API design, ;; furthermore with regards to storage object initialization, ;; refer to ltp-main:src/main/lsp/stor/README.md (in-package #:ltp/common/iter) ;; NB: Initial prototype - structure-object encapsulation for iterable storage (defstruct (iterable (:constructor)) (element-type t :type type-designator :read-only t)) (defstruct (sequence-iterable (:include iterable) (:constructor)) (members nil :type sequence)) ;; DNW .... (defstruct (vector-iterable (:include sequence-iterable) (:constructor)) #+FIXME (members #() :type vector)) (defstruct (simple-vector-iterable (:include vector-iterable) (:constructor %mk-simple-vector-iterable (element-type members))) #+FIXME (members #() :type '(simple-array * (*)))) (defun make-simple-vector-iterable (members &key (element-type t)) (%mk-simple-vector-iterable element-type (make-array (length members) :element-type (upgraded-array-element-type element-type) :initial-contents members))) ;; -------------------- ;; NB: Initial prototype for "iterable macros" (defmacro do-simple-vector-iterable ((s whence &optional returnv) &body forms) ;; NB: This simple protocol may not provide support for iterable type ;; elements to be declared in a manner as to be available to a ;; compilation environment -- juxtaposed to any finalized class, in ;; any implementation as onto a STANDARD-CLASS ;; ;; Regardless, there may remain a question as to how provide a type ;; declratoin for a static evaluable form, within a macroexpansion, ;; for any object that is not available until the macroexpansion is ;; evaluated. (with-symbols (%s %whence %typ %do-main %returnv %forms) ;; NB: ANSI CL is fairly not good at supporting templates for source forms ;; ;; CL Macro syntax may seem however more advanced than anything ;; available in the immediate syntax of CPP macro declarations. The ;; call-time evaluation of CL macros provides some particularly ;; quirky limitations, however. `(let* ((,%whence ,whence) ;; TBD: How to make the binding of %typ available at ;; compile time in a lexically scoped environment, ;; for any implementation inserting null-lexenv anywhere ;; arbitrarily ;; ;; define-compiler-macro does not in itself provide any ;; workaround for the intrinsic quirks/limitations of the ;; macroexpansion environment and subsequent breakage for ;; some not-evaluated-for-value forms (,%typ (iterable-element-type ,%whence))) (macrolet ((,%do-main ((,%s ,%whence ,%returnv) ,%forms) (with-symbols (%%whence %memb %len %n) `(let* ((,%%whence ,,%whence) (,%memb (simple-vector-iterable-members ,%%whence)) (,%len (length (the simple-vector ,%memb)))) (dotimes (,%n ,%len ,,%returnv) (let ((,,%s (svref ,%memb ,%n))) ;; NB: An operation on the class of ;; ,%WHENCE could seem to serve to work ;; around the limitations of the ;; macroexpansion evaluation environment, ;; with the following DECLARE form -- ;; except that the binding of ,%WHENCE may ;; be ignored by the compiler, even then, ;; in the macroexpansion. ;; ;; For purpoes of development in this ;; system, it might seem feasible to ;; orchestrate the production of the ;; evaluable form with a compiler ;; macro operating on the iterable ;; object itself, in production of the ;; macroexpansion to the compiler. However -- ;; beyond any merely syntactic ;; characteristics of the whole form ;; provided to the compiler macro -- the ;; implementation of such an approach may ;; serve to require an EVAL semantics on ;; the expression denoting the iterable ;; object - quite simply, evaluating it ;; independent of the environment finally ;; created by the compiler, moreover ;; independent of the enviornment in which ;; the form was initially conferred. ;; ;; Subsequently, perhaps the semantics of ;; CMUCL source tranform definitions may ;; seem somehow approachable for ;; consideration, alternate to any ;; limitations as would be imposed from the ;; creation of lexical environments in the ;; compiler itself. ;; ;; As it stands, this Lisp source code DNW: (declare (type ,(symbol-value (quote ,%typ)) ,,s)) ,@,%forms )))))) (,%do-main (,s ,%whence ,returnv) ,@forms))) )) (eval-when () (setq *break-on-signals* t) (let ((iter (make-simple-vector-iterable '(1 2 3) :element-type #-NIL t #+NIL '(mod 4))) (call-reg)) ;(macroexpand (quote (do-simple-vector-iterable (%elt iter (values call-reg t)) (npushl (expt %elt 2) call-reg)) ; )) ) ) ;; -------------------- (defun mk-iterable-macro-function (iterable) ;; easy enough to produce, may be non-trivial to bind for "Normal Evaluation" (with-symbols (args environment s whence returnv forms) (let* ((memb (simple-vector-iterable-members iterable)) (typ (array-element-type memb))) `(lambda (,args ,environment) ;; TBD WITH-ENV (PORTABLY) ;; For now, although this is probably not actually good - even when ;; the compiler produces this behavior after DEFMACRO (declare (ignore ,environment)) (destructuring-bind ((,s &optional ,returnv) &rest ,forms) ,args (with-symbols ( %memb %len %n) `(let* ((,%memb ,,memb) (,%len ,,(length memb))) (dotimes (,%n ,%len ,,returnv) (let ((,,s (svref ,%memb ,%n))) (declare (type ,,typ ,,s)) ,@,forms ))))))))) #+NIL (eval-when () (defparameter *v* (make-simple-vector-iterable '(1 2 3))) (defparameter *f* (mk-iterable-macro-function *v*)) (defparameter *expr* '((elt (values call-reg t)) (npushl (expt %elt 2) call-reg))) (funcall (coerce *f* 'function) *expr* nil) ;; (defmacro frob-iter ( ;; HOWTO / TBD ) ;; ------------------------------ (defstruct (list-iterable (:include sequence-iterable) (:constructor make-list-iterable (%members &key (element-type t) &aux (members (coerce %members 'list)))) (:constructor)) #+FIXME (members nil :type list)) #+TBD (defmacro do-list-iterable ((s whence &optional returnv) &body forms) ) ;; ------------------------------------------------------------ ;; NB: Initial prototype - standard-object encapsulation for iterable storage (defclass iterable-class (standard-class) ((member-element-type :type type-designator ;; :access (:read :bind) :initarg :member-element-type :initform t))) (defclass iterable-object () ()) (defclass sequence-iterable-object (iterable-object) ((members ;; FIXME Rename => storage :initarg :members :type sequence))) (defclass iterable-vector-class (standard-class) ((member-storage-element-type :type type-designator ;; :access (:read :bind) :initarg :member-storage-element-type :initform t))) (defclass vector-iterable-object (sequence-iterable-object) ((members :type (array * (*))))) (defclass simple-vector-iterable-object (vector-iterable-object) ((members ;; :access (:read :bind :unbind) ;; ^ NB: see ltp-main:src/main/lsp/base-class/README.md :type (simple-array * (*))))) (defclass list-iterable-object (sequence-iterable-object) ((members :type list))) (defgeneric mk-iterable (kind &key &allow-other-keys) (:method ((kind vector-iterable-object) &key members (element-type t) (storage-element-type element-type) &allow-other-keys) (let* ((len (length members)) (memb (make-array len :element-kind ;; FIXME: This API needs to be well documented: (storage-element-type (class-of kind)) :initial-contents members))) ;; NB: This uses any provided MEMBERS sequence as a manner of an ;; elements signature, when producing the actual storage vector ;; for the iterable )) ) ;; TBD - Storage Protocol & ITERABLE ;; ;; ENSURE-STORAGE-USING-CLASS (CLASS ITERABLE &OPTIONAL INITIAL-CONTENTS) ;; SHARED-INITIALIZE (ITERABLE T &REST INITARGS &KEY INITIAL-CONTENTS &ALLOW-OTHER-KEY ;; ;; [Re]Design LTP-Main ENUM onto ITERABLE-CLASS, ITERABLE-OBJECT ;; adding functions for storage onto symbolic enumeration member objects ;; TBD: HASHED-VECTOR-ITERABLE ;; NB: Onto SXHASH => NUMBER ;; ;; TBD: "Template-like" support for specifying "Where the SXHASH key is stored", ;; in extensions ;; ;; General usage case: Hash-Table-Like storage for large sets of ;; similarly typed values, indexed onto the SXHASH code computed for one ;; or more fields of each such value. ;; ;; See also: librdf; libxml2 XML Schema Datatypes support; .... #+ITERABLE-MAP-FUNCTION (defgeneric ensure-iterable-map-function (return-type iterable) ;; TBD: How to effectively parameterize the selection of a per-instance ;; static or per-class/instance-dynamic :policy for creation of the iterable ;; map function ;; NB: Revise the immediate API => MAP-ITERABLE-STATIC, MAP-ITERABLE-DYNAMIC ;; referring to annotations, subsq. ;; - ENSURE-ITERABLE-STATIC-MAP-FUNCTION ;; - ENSURE-ITERABLE-DYNAMIC-MAP-FUNCTION ;; ;; Note that any map-function being called exactly once may use a ;; static policy - it not differing substantially then, to the ;; :dynamic call case, in which some forms generally operating on the ;; individual iterable object would not be evaluated until the ;; function is called. Conceivably, the :static initialized iterator ;; function may serve to provide the compiler with an opportunity to ;; further optimize the function, in its compilation. (:method ((return-type t) (iterable simple-vector-iterable)) ;; TBD: Moving the following into a conventional function, e.g ;; ;; ENSURE-ITERABLE-STATIC-MAP-FUNCTION ;; such that may be cached per each instance, under its instance ;; values and class state at the time of the function's creation ;; ;; juxtaposed to a conventional function, e.g ;; ;; ENSURE-ITERABLE-DYNAMIC-MAP-FUNCTION ;; such that may be cached per each class, under that class' state at ;; the time of the function's creation ;; ;; Note that this differentiation may seem somewhat trivial for ;; iterable object and iterable class implementations not using ;; typed local sequence values for direct storage. Regardless, it ;; may be observed that this design may serve to provide an opportunity ;; for some optimizations of the compiled forms of functions ;; providing support for iterative generalized operations in the ;; :static case - while not, per se, preventing applications in the ;; :dynamic case ;; ;; TBD furthermore: Towards concepts of literate programming in a ;; system supporting annotation of project resources under an RDF, ;; TeX model - e.g using RDF for system reference informatoin, and TeX ;; for information pursuant towards presentation in visual ;; presentation systems -- if not as an intermediary, direct source ;; notation, pursuant to a methodology for deriving XML from ;; arbitrary resources annotated with a TeX notation -- moreover for ;; audal text-to-speech systems, beyond visual characteristics (per ;; se) of graphical resource hyperlinking systems. .... towards ;; which, a concept of a model-specific TeX environment may pertain ;; ;; -- towards generalized usage cases: ;; ;; - Systems Documentation ;; - Systems Review, Analysis, and QA - Support ;; - Reusability of Systems - as a singular topic, per se. ;; ;; ... as may entail some integration with existing source ;; documentation systems, e.g gtk-doc, Doxygen, etc. ;; ;; ... and the presentation environment. ;; ;; Context: CommonIDE, initially in implementation with generalized ;; wigets onto GTK+ (let* ((result-storage (mk-result-form return-type iterable)) (form (with-symbols (fn) `(lambda (,fn) (declare (type (function ,fn))) ;; NB: :STATIC storage for iterable-members, in this ;; prototype - an initial policy, pursuant of some ;; implicit assumptions with regards to applications ;; ;; also, static storage for the ephemeral result object ;; (such that should not be destructively modified by ;; any calling forms, as it may be reused across ;; subsequent calls to this function) ;; ;; Usage Cases e.g ;; ;; - Iterative operations onto static enumerated type ;; information - note that the caller-provided ;; function is not hard coded in the function ;; returned by the following. ;; ;; - Iterative operations onto static model ;; information - however generally as may subsume ;; operations onto enumerated type information - e.g ;; in applications for static model analysis ;; NB: MAP-INTO may seem superfluous if the RESULT-TYPE := NIL ;; ;; The implementation may handle that call-case, implicitly. (map-into ,result-storage ;; ^ NB: Static result value storage (may be NIL) ,(with-frob (elt) ;; NB: Additional wrapping for FN - to ;; provide existing information to the ;; compiler, as for the type of the ;; argument provided to the function FN, ;; assuming that the compiler may then be ;; be to provide additional optimizations ;; onto the call to FN itself. `(lambda (,elt) (declare (type ,elt ;; NB: This call would ;; be the same, across ;; static and dynamic ;; policies, as ;; annotated : ,(iterable-member-storage-element-type (class-of iterable)))) (funcall ,fn ,elt))) ;; NB: Static members storage: ,(iterable-members iterable)) (values ,result-storage))))) (values (compile* form)) ;; TBD - caching for iterable map functions ;; onto {(CLASS-OF ITERABLE), ITERABLE, RETURN-TYPE} ;; - Note static storage of iterable members sequences and result ;; sequences, in the function produced in the example above ;; TBD: MK-RESULT-FORM ;; TBD: MK-RESULT-FORM-USING-CLASS ;; TBD: ENSURE-ITERABLE-MAP-FUNCTION-USING-CLASS ))) ;; TBD: Beyond the singular specification of :static or :dynamic policy ;; for creation of iterator map functions, this system should endeavor ;; to support a broader facilitation of application of arbitrary system ;; optimization policies, e.g at scales of ;; ;; {project, {source-section, usage-case+}+} ;; ;; ... for any source section, whether or not implemented in a Common ;; Lisp language. ;; ;; ... presently, regardless of any concept of "Over-Optimization" (defgeneric map-iterable (fn iterable &key &allow-other-keys) ;; TBD API => map-iterable-dynamic (fn iterable) #-ITERABLE-MAP-FUNCTION ;; NB: Dynamic/Class-Specific Policy here (:method ((fn function) (iterable sequence-iterable-object) &key return-type &allow-other-keys) ;; NB: FN may assume its own element-type for the iterable ;; ;; NB: Special eval-case of RETURN-TYPE := NIL (map return-type fn (iterable-members iterable))) ;; TBD API => map-iterable-static (fn iterable) #+ITERABLE-MAP-FUNCTION ;; NB: Static/Instance or Dynamic/Class Policy for Creation and ;; Storage of the iterable map function as would be used internally, ;; within the following ;; ;; e.g: compute and apply a function singularly for mapping a function ;; onto the iterable's effective member objects - the function may be ;; compiled and subsequently cached, under any single manner of ;; application policy ;; ;; Note that the mapped function may exit non-locally. ;; ;; NB: The iterator function must apply the mapped function in a ;; reentrant manner. ;; ;; NB: Under a static policy, the result returned by the following may ;; be stored locally to the iterable-map-function, i.e the iterator ;; function and - as such - should not be destructively modified. ;; (:method ((fn function) (iterable iterable-object) &key return-type &allow-other-keys) (funcall (the function (ensure-iterable-map-function return-type iterable)) fn)) ) (validate-class iterable-class) ;; ------------------------------ #+NIL (defun* map-iterable (fn iterable &optional (return-type t)) (declare (type function fn) (type iterable iterable) (values t &optional)) (let ((memb (etypecase iterable (sequence-iterable (sequence-iterable-members iterable)))) ... )))
20,097
Common Lisp
.lisp
435
35.783908
86
0.587833
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
8e1140ede229aeddf081a141790e9a3c90b3128da04bdf9560cef78de25c8f81
29,291
[ -1 ]
29,292
ext-utils.lisp
thinkum_ltp-main/src/main/lsp/asdf/ext-utils.lisp
;; ext-utils.lisp - utilities onto ASDF ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Interface and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp-asdf-utils) (deftype component-designator () '(or string symbol component)) ;;; * Component Condition Types (define-condition component-condition () ((component :initarg :component :reader component-condition-component))) (define-condition component-location-condition () ((location :initarg :location :reader component-location-condition-location))) (define-condition component-not-found (program-error component-condition component-location-condition) () (:report (lambda (c s) (format s "Location ~S does not contain a component ~S" (component-location-condition-location c) (component-condition-component c))))) ;; (error 'component-not-found :component "FOO" :location "BAR") (define-condition system-not-found (program-error component-condition component-location-condition) () (:default-initargs :location asdf::*source-registry*) (:report (lambda (c s) (format s "Source registry ~S does not contain a system ~S" (component-location-condition-location c) (component-condition-component c))))) ;;; * Interfaces onto ASDF Component Search (macrolet ((frob-c (component location errp) (with-gensym (%c %comp %loc %ep) `(let* ((,%comp ,component) (,%loc ,location) (,%ep ,errp) (,%c (find-component ,%loc ,%comp))) (cond (,%c (values ,%c)) (,%ep (error 'component-not-found :location ,%loc :component ,%comp)) (t (values nil))))))) (defgeneric find-component* (component location &optional errorp) ;; NOTE: The order of arguments in this function ;; differs from that in ASDF:FIND-COMPONENT (:method (component (path cons) &optional (errorp t)) (frob-c component path errorp)) (:method (component (location module) &optional (errorp t)) (frob-c component location errorp)) (:method (component (location string) &optional (errorp t)) (let ((sys (find-component* location nil errorp))) (when sys (frob-c component sys errorp)))) (:method (system (location null) &optional (errorp t)) (let ((s (find-system system nil))) (cond (s (values s)) (errorp (error 'system-not-found :component system)) (t (values nil))))))) ;;; Test forms ;; (find-component* '#:foobarquux nil) ;; ;; (find-component* "asdf-utils" "info.metacommunity.cltl.utils") ;; ;; (find-component* "line" '("garnet-bitmaps" "garnetdraw")) (defun find-system* (name &optional (errorp t)) (declare (type component-designator name) (values (or component null))) (values (find-component* name nil errorp))) ;; (find-system* "mcclim")
3,266
Common Lisp
.lisp
85
34.152941
80
0.652628
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
6d59267cdc0c3a8140a1bc232d5ac65ad7afbcc8fb3cb41014e06b8c28de05e7
29,292
[ -1 ]
29,293
ltp-asdf-utils-package.lisp
thinkum_ltp-main/src/main/lsp/asdf/ltp-asdf-utils-package.lisp
;; ext-pkg.lisp - defpackage for ASDF extensions [MCi] ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:cl-user) (defpackage #:ltp-asdf-utils (:use #:ltp-utils #:asdf #:cl) (:shadowing-import-from #:asdf/find-system #:register-system ) (:export #:component-designator #:component-condition #:component-condition-component #:component-location-condition #:component-location-condition-location #:system-not-found #:find-component* #:find-system* ;;; moved into ../utils/defsys-ex.lisp ;; #:resource ;; #:resource-file ;; #:resource-module ;; #:resource-system #:alias-system-alias-to #:alias-system #:make-alias-system #:register-alias-system ))
1,222
Common Lisp
.lisp
40
27.225
80
0.609548
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
141fab90d2d84c8bee6404d843493b37ea673e7b07da868a4f624406b7e299b3
29,293
[ -1 ]
29,294
ext-alias.lisp
thinkum_ltp-main/src/main/lsp/asdf/ext-alias.lisp
;; ext-alias.lisp - system aliasing extension for ASDF ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Interface and Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp-asdf-utils) (defgeneric alias-system-alias-to (system)) (defgeneric (setf alias-system-alias-to) (component system)) (defclass alias-system (system*) ((alias-to ;; source of alias - should denote an existing system definition :initarg :alias-to :type (or simple-string symbol component) :accessor alias-system-alias-to))) (defmethod print-object ((object alias-system) stream) (print-unreadable-object (object stream :type t) (format stream "~S => ~S" (component-name object) (alias-system-alias-to object)))) (defun make-alias-system (to from) (let* ((%to (coerce-name to)) (%from (coerce-name from))) (make-instance 'alias-system :name %to :alias-to %from))) (defun register-alias-system (to from) (let* ((s (make-alias-system to from))) (register-system s))) (defmethod operate :around ((operation operation) (component alias-system) &rest args &key &allow-other-keys) (let* ((to (alias-system-alias-to component)) (%to (etypecase to (component to) (t (find-system to))))) ;; FIXME This does not perform output-file aliasing for 'TO' under 'COMPONENT' (cond (args (apply #'operate operation %to args)) (t (operate operation %to)))))
1,948
Common Lisp
.lisp
45
37.733333
82
0.611287
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
c56897441f827ba96fbd38ab51fb921db1f9f2da0847bbb0a7fd700ac2a3c5f8
29,294
[ -1 ]
29,295
ext-star.lisp
thinkum_ltp-main/src/main/lsp/asdf/ext-star.lisp
;; ext-star.lisp - platform-specific subclasses for components ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Interface and implementation ;; ;;------------------------------------------------------------------------------ (in-package #:ltp-asdf-utils) (defclass component* (component) ()) (defclass module* (component* module) ()) (defclass system* (component* system) ;; cf. :CLASS initarg to DEFSYSTEM ()) (defvar *component*) (defvar *operation*) (defmethod operate :around ((operation operation) (component component*) &key &allow-other-keys) ;; make OPERATION and COMPONENT avaialble to more specialized methods (let ((*component* component) (*operation* operation)) (call-next-method)))
1,153
Common Lisp
.lisp
29
35.793103
80
0.60644
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
d16fa5659dc88d3cd0747f27a46b155ee71077c4fc212504f7be8080eb5c0986
29,295
[ -1 ]
29,296
buffer.lisp
thinkum_ltp-main/src/sandbox/buffer/buffer.lisp
;; an early prototype for a generic buffering library ;; ;; abandoned due to generic complexity, 25 Dec 2015 (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :exeucte) #+asdf (asdf:operate 'asdf:load-op '#:bordeaux-threads) (defpackage #:buffer (:use #:libfoo #:bt #:cl) (:export ) ;; ... ) ) (in-package #:buffer) (defgeneric buffer-contents (buffer)) (defgeneric (setf buffer-contents) (new-contents buffer)) (defgeneric buffer-element-type (buffer)) (defgeneric buffer-test-function (buffer)) (defgeneric (setf buffer-test-function) (new-test-function buffer)) (defgeneric buffer-lock (buffer)) (defclass buffer () ;; encapsulation of: ;; 1) a buffer contents object, e.g. an adjustable array ;; 2) a test function, encapsulating a key function such as for FIND-IF ((contents :initarg :contents :accessor buffer-contents) (element-type :initform t :initarg :element-type ;; :type libfoo:type-designator :reader buffer-element-type) (test-function :initarg :test-function :type function :accessor buffer-test-function) (lock :initarg :lock ;; :type lock ;; TO DO : Portable 'lock' type in Bordeaux Threadds (PATCH) :reader buffer-lock ;; TO DO: Modal locks for BT ))) (defun slot-initialize-p (name instance slots) ;; UTIL ;; Utility for conditional slot value initialization (declare (type symbol name) (type (or cons boolean) slots) (values boolean &optional)) (and (cond ((consp slots) (and (member name (the cons slots) :test #'eq) (values t))) ((eq slots t) (values t)) (t (values nil))) ;; check that the slot has not been already bound to a value (not (slot-boundp name instance)))) ;; (slot-initialize-p 'print-object ... t) ;; (slot-initialize-p 'print-object ... '(print-object format)) ;; (slot-initialize-p 'print-object ... '(format)) (defmethod shared-initialize :around ((instance buffer) slots &rest initargs &key test-function lock &allow-other-keys) (let (args-updated-p) (when (and test-function (not (functionp test-function))) ;; ensure test-function is a function (let ((f (coerce test-function 'function))) (setf (getf initargs :test-function) f) (setq args-udpated-p t))) (when (slot-initialize-p 'lock instance slots) (let ((lock (make-lock (format nil "buffer-lock ~A" instance)))) (setf (getf initargs :lock) lock) (setq args-updated-p t))) (when (next-method-p) (cond (args-updated-p (apply #'call-next-method instance slots initargs)) (t (call-next-method)))))) (defmacro with-locked-buffer ((buffer #+modal-locks &optional #+modal-locks mode) &body body) (let ((%lock (gensym "%lock-"))) `(let ((,%lock (buffer-lock ,buffer))) (with-lock-held (,%lock #+modal-locks :mode #+modal-locks ,mode) ,@body )))) (defgeneric make-buffer-find-function (buffer)) (defgeneric buffer-find (key buffer &optional errorp) (:method (key (buffer buffer) &optional (errorp t)) (with-locked-buffer (buffer #+modal-locks :mode #+modal-locks :read) (funcall (buffer-find-function buffer) key errorp) ))) (defgeneric make-buffer-push-function (buffer)) (defgeneric buffer-push (object buffer) (:method (object (buffer buffer)) (with-locked-buffer (buffer #+modal-locks :mode #+modal-locks :write) (funcall (buffer-push-function buffer) object) ))) (defgeneric make-buffer-remove-function (buffer)) (defgeneric buffer-remove (key buffer) (:method (key (buffer buffer)) (with-locked-buffer (buffer #+modal-locks :mode #+modal-locks :write) (funcall (buffer-remove-function buffer) key) ))) (defclass sequence-buffer (buffer) ((contents :type sequence))) (defgeneric buffer-unbound-marker (buffer)) (defclass vector-buffer (sequence-buffer) ;; Prototype : advise.lisp ((contents :type vector) (unbound-marker :initarg :unbound-marker :reader buffer-unbound-marker))) ;; (declare (type array-dimension-designator %buffer-expand%)) ;; FIXME : IMPORT (defvar %buffer-expand% 8) (defmethod shared-initialize :around ((instance vector-buffer) slots &rest initargs &key (unbound-marker nil unbound-marker-p) &allow-other-keys) (declare (ignore unbound-marker)) (let (args-updated-p) (when (and (not unbound-marker-p) (slot-initialize-p 'unbound-marker instance slots)) (setf (getf initargs :unbound-marker) (allocate-instance (class-of instance))) (setq args-updated-p t)) (when (next-method-p) (cond (args-updated-p (apply #'call-next-method instance slots initargs)) (call-next-method))) (when (slot-initialize-p 'contents instance slots) (let ((v (make-array %buffer-expand% :element-type (buffer-element-type instance) :fill-pointer 0 :initial-element (buffer-unbound-marker instance) :adjustable t))) (setf (buffer-contents instance) v))))) ;; (defmethod make-buffer-find-function ((buffer vector-buffer)) ;; (let ((test (buffer-test-function buffer)) ;; (unbound (buffer-unbound-marker buffer))) ;; `(lambda (object &optional (errorp t)) ;; (or (find-if ,test (the vector (buffer-contents buffer)) ;; )))) (defmethod make-buffer-remove-function ((buffer vector-buffer)) (let ((test (buffer-test-function buffer)) (not-found (gensym "%not-found-"))) `(lambda (key &optional (errorp t)) (delete-if ,test (the vector (buffer-contents buffer))))))
6,237
Common Lisp
.lisp
154
32.181818
80
0.612823
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
34257f1c726a451e8f5f9ae60d69ba888a2b6bd58d5e4f750707027173a0e303
29,296
[ -1 ]
29,297
eval-proto.lisp
thinkum_ltp-main/src/sandbox/testkit/eval-proto.lisp
(defmacro eval-when-test ((&rest specifers) &body body &enviroment environment) ;; Synopsis / Overview: ;; Generalization of eval-when semmantics onto, in manner, "DevOps" Processes ;; ;; Synopsis / Application: ;; Provide a simple semantics for developing "Inline Test" forms ;; within Common Lisp source files. Provide a structural method for ;; application of inline tests during normal software system build ;; processes. May be integrated with pkgsrc port build automation [pkgsrc] ;; ;; Notes ;; - pkgsrc mk-files - Ports mk-files - TEST_DEPENDS ;; - pkgsrc build sytstem parameters - PKGSRC_RUN_TEST ;; - pkgsrc mk-files - pkgsrc 'test' Makefile target ;; - pkgsrc guide [pkgsrc] edn. 2017/07/30 ;; - s. 17.13, "The test phase" - denoted "TODO" ;; - s. III, "The pkgsrc infrastructure internals" ;; - s. 25, "Regression tests" - per the pkgtools/pkg_regress port ;; - NB port pkgtools/pkg_regress; test categorization in pkgsrc ;; (and/or for the pkg_regress port); "regress" test category ;; - See also: FreeBSD port mk-files ) ;; TBD: ;; - Test Specifiers - Syntax and Application Behaviors ;; - Test Naming ;; - Test Grouping ;; - Test Evaluation Constraints ;; - Code Evaluation Phase (onto ANSI CL vis. standard syntax and ;; behaviors of CL:EVAL-WHEN) ;; - Test Code Constraint onto Dependent Tests ;; (when-success/when-fail) ;; - Test Component Dependencies ;; - "Test Harness" Intrgration onto ASDF - Dependency Management? ;; - Test Definition, Eval, and Reporting - Procedural Model ;; - This topic representing the "Bread and Butter" of the "Test ;; Harness," in applications ;; - Test Definition ;; - Inline Test Definition ;; - Test Defintion in External File ;; - Test Definition in Runtime Application Code Generation ;; - "Test Harness" Intrgration onto ASDF - Test Declaration in ;; System Definition ;; - Test Orchestration ;; - "Test Harness" Intrgration onto ASDF - ASDF:TEST-OP ;; - Test Activation ;; - Test Monitoring ;; - Test Reporting ;; - Report Generation ;; - Report Publishing ;; ;; - NST - API; Ports
2,259
Common Lisp
.lisp
52
40.673077
80
0.66818
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
807e32145116ea9810fa12cdbe119975f6f60c144c42496e042883c0ca1eec34
29,297
[ -1 ]
29,298
model-prototype.lisp
thinkum_ltp-main/src/sandbox/uri-impl/model-prototype.lisp
(in-package #:cl-user) (defclass model-class (standard-class) ;; TBD: Model [property] ()) (defclass abstract-model-class (model-class) ()) (defclass element (#+NIL metaclass) ;; protocol class - cf. UML ;; see e.g http://www.uml-diagrams.org/namespace.html () (:metaclass abstract-model-class)) (defclass named-element (element) ((name :initarg :name :type simple-string :accessor named-element-name)) (:metaclass abstract-model-class)) (defclass namespace (named-element) () (:metaclass abstract-model-class))
553
Common Lisp
.lisp
20
24.6
55
0.711027
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
702b7828f5b1ad1c20d5eb8a18eb231af1adfa0b973180d64e439df4932fe3c7
29,298
[ -1 ]
29,299
uri-prototype.lisp
thinkum_ltp-main/src/sandbox/uri-impl/uri-prototype.lisp
(in-package #:cl-user) ;; Generic Identifier Class Model (defclass identifier () ()) (defclass identifier-kind (standard-class) ()) ;; Identifier Class Registry (defconstant %ident-cache-extent% 8) (declaim (type (array ident-kind (*)) %ident)) (defvar %ident% (make-array %ident-cache-extent% :element-type 'idenifier-kind :adjustable t :fill-pointer 0)) (defun find-identifier-kind-using-class (name &optional errorp) (declare (type symbol name) (values (or identifier-kind null) boolean)) (let ((inst (find name %ident% :key #'class-name :test #'eq))) (cond (inst (values inst t)) (errorp (error "Identifier kind not found: ~A" name)) (t (values nil nil))))) (defun register-identifier-kind (kind) (declare (type identifier-kind kind) (vaules identifier array-dimension-designator)) (let* ((name (class-name kind)) (offset (position name %iden% :key #'class-name :test #'eq))) (cond ((and offset (eq (aref %ident% offset) kind))) ;; no-op (offset (style-warning "....") (setf (aref %ident% offset) kind)) (t (vector-push-extend kind %ident% %ident-cache-extent%))) (values kind offset))) (defun unregister-identifier-kind (kind) (declare (type identifier-kind kind)) ) ;; URI, URI-SCHEME (defclass uri (identifier) ()) (defgeneric uri-scheme-name (object)) (defgeneric (setf uri-scheme-name) (new-value object)) (defclass uri-scheme (identifier-kind) ((name :initarg :scheme-name :accessor uri-scheme-name :type simple-base-string))) (defgeneric uri-scheme (object) (:method ((object uri)) (class-of objec))) (defgeneric (setf uri-scheme) (new-value object) (:method ((new-value uri-scheme) (object uri)) (change-class object (class-name new-value)))) ;; URN, URN-NAMESPACE (defclass urn (uri) ()) (defgeneric urn-namespace-name (object)) (defgeneric (setf urn-namespace-name) (new-value object)) (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant +urn-scheme-name+ (cond ((boundp '+urn-scheme-name+) (symbol-value '+urn-scheme-name+)) (t (coerce "urn" 'simple-base-string))))) (defclass urn-namespace (uri-scheme) ((ns-name :initarg :ns-name :accessor urn-namespace-name)) (:deault-initargs :scheme-name #.+urn-scheme-name+)) (defmethod (setf uri-scheme-name) (new-value (object urn-namespace)) (cond ((string-equal new-value #.+urn-scheme-name+) ;; return the exact string object (uri-scheme object)) (t (simple-program-error "Unable to set URI-SCHEME ~s for namespace ~S" new-value object))))
2,750
Common Lisp
.lisp
80
29.2875
68
0.658425
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
e1035698f1e170cf1cdc17c8b6638eb914bf186fdd22efe258656a24e820954d
29,299
[ -1 ]
29,300
resolver.lisp
thinkum_ltp-main/src/sandbox/name-resolver/resolver.lisp
(in-package #:cl-user) ;; cf. CORBA Naming Service 1.3 (2004) #| Commentary: FELDSPAR IDL mapping for Common Lisp The following source code proposes a representation for IDL in Common Lisp, alternate to the conventional IDL to Lisp mapping. TO DO: * Implement, Test, and Document the following prototype forms * "Case collapsing" for names: CORBA specifications indicate that IDL names must be compared in a case sensitive manner, but that it constitutes a name collision when names are equivalent without regards to case conversion. In order to provide a facility for memoization of string values in a compatible string comparison function, this implementation provides the `IDL-NAME-FLATTENED` slot on the class `IDL-DEFINITION`. The value of IDL-NAME-FLATTENED slot is generated automatically as a STRING-UPCASE version of the :IDL-NAME initialization argument value, during SHARED-INITIALIZE of an IDL-DEFINITION (TO DO: Updated flatened name value during SETF SLOT-VALUE IDL-DEFINITION IDL-NAME) * Sidebar: Slot-value locking, Modal (read/write) slot-value locking, and WITH-SLOT-LOCKED macro implementations Ideally, in a multithreaded programming environment, it would "Just work out" that an object's slot values would never be concurrently read and modified in separate threads, in any manner that would produce an inconsistency between values respectively read and written in separate threads - as whether for 'atomic' slot values or slot values backed with a sequence type 'backing store'. Hypothetically, a CORBA application implementing a dynamic invocation interface (DII) may endeavor to set a CORBA interface's 'name' value from a thread A, in such a manner that would produce a multiprocessing race condition if the same interface's 'name' value is being 'read' in a thread B. Hypothetically, furthermore, a CORBA name service may endeavor to resolve a name M avaialble in a naming context N in a thread A, while the same name M is being removed from N in a thread B, again such that would produduce a multiprocessing race condition. Such conditions at least logically interfere with a deterministic model of a program's execution. In a practical regards, such conditions may ever serve to present a practial dificulty wiht regards to profiling and debugging of a production system. For any single object that may be accessible within multiple threads, ostensibly any single slot value of the object may be accessed likewise from multiple threads - as regardless of the slot definition allocation for the slot value. As an extension onto the metaobject protocol, a methodology may be defined in which any single slot or set of slots may be locked from a single thread - whether locked in a manner as to allow concurrent reads but block conncurrent writes, or locked exclusively, as in a manner to block conccurent reads and writes - as regardless of the allocation of the slot's definition and slot value. A manner of consideration may be developed as about the allocation of the 'lock' objects for such an extension. For instance: * if a slot definition is 'class' allocated, any lock applied for accessing the slot's value may be stored in reference to the class of the slot's allocation - whether stored in a slot value on the class definition itself, or optinally stored in a property value defined onto the class' symbolic class name. * if a slot definition is 'instance' allocated, any lock applied for accessing the slot's value should be stored in reference to any single instance in which the slot would be accessed * for instance allocated slots, for each slot that is defined as to be "lockable", the slot definition for the respective slot may be defined as to contain an adjustable array of instances and corresponding, implementation-specific lock objects. For each instance whose slot value must be locked, for a duration - whether locked in a 'read' or exclusive 'write' mode - the instance may be added to the array, together with a freshly allocated, implementation-specific 'lock' object - the 'lock' being initialized originally for a 'read' or 'write' modality in the duration, onto the respective instance. Effectively, the instance containing the slot definition would provide the key onto the table as such - such that may be compared with a direct EQ comparison, without immediate reference to a hashing algorithm. * for class allocated slots, for each slot that is defined as to be 'lockable', the class definition itself may be modified so as to contain a "cache" as that would store an implementation-specific lock object for any duration in which the respective class allocated slot is being accessed. * Whether for class allocated or instance allocated slot value locking, a "locks pool" may be developed - perhaps, in a manner functionally analogous to a network service thread pool, but producing implementation-specific 'lock' objects rather than implementation-specific 'thread' objects, as, objects allocated in the respective lock pooling implementation. For most instances, it may be possible to prevent that a new lock object would have to be created in the respective host operating system kernel, for each instance in which a lock must be allocated as so. * For instance-allocated "Lockable slots", in a MOP implementation, ostensibly a new set of direct and efective slot definition classes may be deined, togehter with a set of methods specialized such as to lock an instance's slot value for concurrent "read" from within SLOT-VALUE-USING-CLASS and to lock the slot value against concurrent "read" or "Write" from within (SETF SLOT-VALUE-USING-CLASS). Of course, each respective lock-holding form should unwind appropriately on any event of an unexpected situation - releasing any lock held, in such event. * Slot value "Lockability" may be specified by the systems programmer, in definitions of each individual class. Ostensibly, any slot whose value may be logically accessed from concurrent threads, within an application, should be defined as to be 'lockable', with the implemenation then providing an automatic 'locking' during slot value access. * Ostensibly, a slot value locking protocol may find an application in data services providing concurrent access to individual data objects in Common Lisp. * Name equivalence onto definition kinds - symbols, strings, and IDL string tranformation to/from symbol names - refer to existing binding specs. * Implementation onto existing CORBA IDL "basic types" * IDL string => CL:SIMPLE-BASE-STRING (if all of ISO-8559-1 is in the SIMPLE-BASE-STRING value space, else => SIPLE-STRING) unless application deems other than 'simple strings' * IDL wstring => CL:SIMPLE-STRING unless application deems otherwise * Integrate with existing CLORB IDL Parser * Integrate with CORBA DII IDL * Integrate with any existing DII services in CLORB * "Publish" * "Next Milestone" |# #| NOTES: FELDSPAR Name Resolver Implementation * TO DO: Design for platform-agnostic integration w/ POSIX interfaces onto 1) networking services at OSI Layers 1..7, 2) user credential services available on-host; 3) implementationd after POSIX 1003.1e; 4) filesystem services ... referencing initially a FreeBSD 10.2 kernel and userspace utilities * CosFileTransfer/EntryName (wstring) and CosFileTransfer/EntryPath (sequence of EntryName), CosFileTransfer/DirEntrySeq (used in DirEntryIterator) ... woul be accessed via interfaces defined in the CosFileTransfer module, in an implementation of the same. It would provie a logical extension onto CosFileTransfer, if to provide an alternate file name resolution service via CosNaming - moreover would serve to require some manner of object casting, for application of any object reutrned by the 'resolve' function in CosNaing, if applied onto objects defined principally in a CosFileTransfer interface. * In the Common Lisp API, define procedures for automatically deriving a name component's 'name kind' value from the class of the object to which the name compinent resolves * Case study: Resolving name components w/ same 'name' but differing 'kind' in a single naming context * Case study: Naming context as a VFS directory service (filename type as name 'kind') * Case study: Naming contexts and name objects onto an interface to an Augeaus configuration editor service |# #+:FELDSPAR (defclass idl-definition-kind (standard-class) ()) #+:FELDSPAR (defgeneric definition-idl-name (definition)) #+:FELDSPAR (defgeneric (setf definition-idl-name) (new-name definition)) #+:FELDSPAR (defclass definition-container () ()) #+:FELDSPAR (declaim (type *definition* definition-container)) #+:FELDSPAR (defvar *definition* (make-root-definition-container)) #+:FELDSPAR (deftype definition-name () '(or simple-string symbol)) #+:FELDSPAR (defun definition-name-equal (n1 n2) (declare (type definition-name n1 n2) (values boolean &optional)) ) #+:FELDSPAR (defun find-definition-using-name (name container &optional (errorp t)) (declare (type idl-name name) (values (or definition-container null) &optional)) (let ((inst (find name (container-definitions *container*) :key #'definition-idl-name :test #'definition-name-equal ))) (cond (inst (values inst)) (errorp (error 'the-not-found-error :name name :container container)) (t (values nil))))) #+:FELDSPAR (defmacro in-definition (name) (let ((%inst (gensym "%inst-")) (%name (gensym "%name-"))) `(let* ((,%name (quote ,name)) (,%inst (find-definition-using-name ,%name *definition*))) (setq *sontainer* ,%inst)))) #+:FELDSPAR (defgeneric module-name-prefix (module)) #+:FELDSPAR (defgeneric (setf module-name-prefix) (new-prefix module)) #+:FELDSPAR (defclass idl-definition () ((idl-name :initarg :idl-name ;; FIXME: VALIDATE VALUE SYNTAX DURING INITIALIZE/SET :type simple-string :accessor definition-idl-name) (idl-name-flattened ;; "Case collapsed" form of IDL-NAME :initarg :idl-name-adjused :type simple-string :accessir definition-idl-name-flattened) (container :type definition-container :accessor definition-container) (version ;; cf. "#prgma version" :initarg :version ;; FIXME: VALIDATE VALUE SYNTAX DURING INITIALIZE/SET :type simple-base-string :accessor definition-version) (repository-id ;; FIXME: VALIDATE VALUE SYNTAX DURING SET ;; cf. "#pragma id" if explicitly set, ;; otherwise computed from container, version :initarg :repository-id :accessor definition-repository-id ))) #+:FELDSPAR (defun write-default-repository-id (instance stream) (declare ((type idl-definition instance) (type stream stream))) (cond ((slot-boundp instance 'container) (write-repository-id (definition-container instance) stream) (write-char #\/ stream)) (t (write-string "IDL:" stream) (when (slot-boundp instance 'prefix) (write-string (module-name-prefix instance) stream) (write-char #\/ stream)))) (write-string (definition-idl-name instance) stream) (when (slot-boundp instance 'version) (write-char #\: stream) (write-string (the simple-base-sring (definition-version instance)) stream))) #+:FELDSPAR (defmethod shared-initialize :around ((instance idl-definition) slots &rest initargs &key idl-name &allow-other-keys) (let (args-updated-p) (when idl-name (let ((simple (simplify-string idl-name))) (unless (eq simple idl-name) (setf (getf initargs :idl-name) simple) (setq args-updated-p t))) (when (or (eq slots t) (and (consp slots) (member 'idl-name-flattened (the cons slots) :test #'eq))) (setf (getf initargs :idl-name-flattened) (string-upcase (the simple-string idl-name))) (setq arg-updated-p t))) (when (next-method-p) (cond (args-updated-p (apply #'call-next-method instance slots initargs)) (t (call-next-method)))) (when (and (not (boundp instance 'repository-id)) (or (eq slots t) (and (consp slots) (member 'repository-id (the cons slots) :test #'eq)))) (with-slot-locked (instance repository-id :write) ;; complex initform : repository-id - ;; FIXME: FOR CLASSES, DO AFTER FINALIZE-CLASS ? (let ((str (make-string-output-stream :element-type 'base-char))) (write-default-repository-id instance stream) (setf (definition-repository-id instance) (get-output-stream-string str))))))) #+:FELDSPAR (defun write-repository-id (instance stream) (declare ((type idl-definition instance) (type stream stream))) (cond ((slot-boundp instance 'repository-id) (write-string (definition-repository-id instance) stream)) ;; should not ever be reached, except during instance init: (t (write-default-repository-id instance stream)))) #+:FELDSPAR (defclass module-definition (definition-container idl-definition) ((name-prefix ;; cf. "#pragma prefix" :initarg :prefix :accessor module-name-prefix)) (:idl "module") (:metaclass idl-definition-kind)) #+:FELDSPAR (defclass idl-structural-definition (idl-definition) ;; protocol class, i.e. mixin (#+TO-DO (members ...) ;; TO DO: Validate member add/remove ;; * no module definitions in interface definitions ;; * no method definitions in module definitions )) #+:FELDSPAR (defclass struct-definition (idl-structural-definition) () (:idl "struct") (:metaclass idl-definition-kind)) #+:FELDSPAR (defclass interface-definition (definition-container idl-structural-definition) () (:idl "interface") (:metaclass idl-definition-kind) ) #+:FELDSPAR (defclass type-definition (idl-definition) ;: TO DO: Define each core (?) CORBA IDL type as a TYPE-DEFINITION ((is-a :initarg :is-a :accessor type-definition-is-a :type type-definition)) (:idl "typedef") (:metaclass idl-definition-kind)) #+:FELDSPAR (defclass enum-definition (idl-definition) () (:idl "enum") (:metaclass idl-definition-kind)) #+:FELDSPAR (defclass sequence-type-definition (idl:typedef) ((element-type :iniarg :element-type :type idl:typedef :accessor sequence-element-type )) (:idl "sequence") ;; parse of: "typedef sequence" (:metaclass idl-definition-kind)) #+:FELDSPAR (defmacro defmodule (name &rest args)) #+:FELDSPAR (defmacro defidl-type (name &rest args) ;; "typedef" or "typdef sequence" ) #+:FELDSPAR (defmacro defidl-enum (name &rest args)) #+:FELDSPAR (defmacro defidl-exception (name &rest args)) ;; - Naming Service #+:FELDSPAR (defmodule naming (:idl #:|CosNaming|) (:prefix "omg.org") (:version "1.3") ;; i.e has repository identifier "IDL:omg.org/CosNaming:1.3" ) #+FELDSPAR (:in-definition naming) #+:FELDSPAR (defidl-type id-string (:idl "Istring") (:is-a idl:string) ) (defgeneric ncomponent-id (name-component)) (defgeneric (setf ncomponent-id) (new-id name-component)) (defgeneric nc-name (name-component)) (defgeneric (setf nc-name) (new-name name-component)) (defclass ncomponent () ;; NameComponent ((id :initarg :id :type #+:FELDSPAR id-string #-:FELDSPAR simple-string :accessor ncomponent-id #+:FELDSPAR :idl #+:FELDSPAR "id" ) (kind :initarg :kind :type #+:FELDSPAR id-string #-:FELDSPAR simple-string :accessor ncomponent-kind #+:FELDSPAR :idl #+:FELDSPAR "kind" ) ) #+:FELDSPAR (:metaclass idl:struct) #+:FELDSPAR (:idl "NameComponent") ) #+:FELDSPAR (defidl-type name (:idl "Name") (:is-a (idl:sequence ncomponent))) #+FELDSPAR (defidl-enum binding-type ((:name-object :idl "nobject") (:name-context :idl "ncontext"))) (defclass name-binding () ;; NameComponent ((name ;; should be of type "NameComponent" - cf. 1.3 spec ;; but was originally identified as being of type 'name' ;; and thus will be a name of length 1, indefinitely :initarg :name :type #+:FELDSPAR name #-:FELDSPAR simple-string :accessor name-binding-name #+:FELDSPAR :idl #+:FELDSPAR "binding_name" ) (binding-type ;; used for binding-list, iterator-next-element, iterator-next-elements ;; not same as ../NameComponent/kind ;; TBD: Mapping from NAME-BINDING-TYPE to each of NAME-DIRECTORY, NAME-OBJECT ;; e.g (defun CLASS-FOR-BINDING-TYPE ...) ;; (defun BINDING-TYPE-FOR-CLASS ...) :initarg :binding-type :type #+:FELDSPAR binding-type #-:FELDSPAR simple-string :accessor name-binding-type #+:FELDSPAR :idl #+:FELDSPAR "binding_type" ) (object ;; IMPLEMENTATION SLOT :initarg :object :accessor name-binding-object :documentation "An object to which the name-binding resolves, when evaluated See also: * `binding-type' [type] * `context-resolve' [function]") ) #+:FELDSPAR (:metaclass idl:struct) #+:FELDSPAR (:idl "Binding") ) (defclass name-directory (name-binding) ;; IMPLEMENTATIOM CLASS () #+FELDSPAR (:default-initargs :binding-type :name-context )) (defclass name-object (name-binding) ;; IMPLEMENTATIOM CLASS () #+FELDSPAR (:default-initargs :binding-type :name-object )) ;; ... #+:FELDSPAR (defidl-type binding-list (:idl "BindingList") (:is-a (idl:sequence name-binding))) (defclass naming-context () () #+:FELDSPAR (:metaclass idl:interface) #+:FELDSPAR (:idl "NamingContext") ) #+FELDSPAR (in-definition naming-context) #+FELDSPAR (defidl-enum not-found-reason ((:missing-node :idl "missing_node") (:not-context :idl "not_context") (:not-object :idl "not_object")) ) #+FELDSPAR (defidl-exception not-found () ((why :initarg :why :type not-found-why :reader not-found-why :idl "why" ) (rest-of-name :initarg :rest-of-name :type name :idl "rest_of_name" )) ) #+FELDSPAR (defidl-exception cannot-proceed () ;; FIXME: Extend his exception type in implementations ???? ((context :initarg :context :type naming-context :idl "cxt") (rest-of-name :initarg :rest-of-name :type name :idl "rest_of_name") ) ) #+FELDSPAR (defidl-exception invalid-name () ) #+FELDSPAR (defidl-exception already-bound () ) #+FELDSPAR (defidl-exception not-empty () ) (defgeneric context-bind (context name obj) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl :void "bind" ((:in "Name" "n") (:in "Object" "obj")) :raises (not-found cannot-proceed invalid-name already-bound))) (defgeneric context-rebind (context name obj) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl-lambda :void "rebind" ((:in "Name" "n") (:in "Object" "obj")) :raises (not-found cannot-proceed invalid-name))) (defgeneric context-bind-context (context name context) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl :void "bind_context" ((:in "Name" "n") (:in "NamingContext" "nc")) :raises (:not-found cannot-proceed invalid-name already-bound))) (defgeneric context-rebind-context (context name context) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl :void "rebind_context" ((:in "Name" "n") (:in "NamingCotext")) :raises (not-found cannot-proceed invalid-name))) (defgeneric context-resolve (context name) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl :object "resolve" ((:in "Name" "n")) :raises (not-found cannot-proceed invalid-name)) #+TO-DO (:method ((context ...) (name ...)) (let* ((the-first (the-sequence-first name)) (the-rest (the-sequence-rest name)) ;; find-the-name may throw-the-idl-exception not-found (the-inst (find-the-name the-fist context))) (unless (the-syntax-ok the-first) ;; syntax for the-first : name must be non-zero in length ;; and must conform to other implementation-specific ;; restrictions - e.g. constraints on network inteface names, etc (throw-the-idl-exception 'invalid-name ... )) (cond ((and the-inst the-rest) (context-resolve the-inst the-rest)) (the-inst (values the-inxt)) (t (throw-the-idl-exception 'not-found :instance context :why :missing-node :rest-of-name the-rest )))))) (defgeneric context-unbind (context name) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl :object "unbind" ((:in "Name" "n")) :raises (not-found cannot-proceed invalid-name))) (defgeneric context-make-context (context) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl naming-context "new_context")) (defgeneric context-bind-new-context (context name) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl naming-context "bind_new_context" (:in "Name" "n") :raises (not-found already-bound cannot-proceed invalid-name) )) (defgeneric context-destroy (context) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl :void "destroy" :raises (not-empty))) (defgeneric context-list-elements (context) #+:FELDSPAR (:generic-function-class idl-interface-function) #+:FELDSPAR (:idl :void "list" ((:in (unsigned long) "how_many") (:out binding-list "bl") (:out binding-iterator "bi")))) ;; (defclass binding-iterator () ;; () ;; #+:FELDSPAR (:metaclass idl:interface) ;; #+:FELDSPAR (:idl "BindingIterator") ;; ) ;; #+FELDSPAR ;; (:in-definition binding-iterator) ;; (defgeneric iterator-next-element (iterator binding-wrapper) ;; #+:FELDSPAR ;; (:generic-function-class idl-interface-function) ;; #+:FELDSPAR ;; (:idl :boolean "next_one" ((:out binding "b")))) ;; (defgeneric iterator-next-elements (iterator count list-wrapper) ;; #+:FELDSPAR ;; (:generic-function-class idl-interface-function) ;; #+:FELDSPAR ;; (:idl :boolean "next_n" ((:in (unsigned long) "how_many") ;; (:out binding-list "bl")))) ;; (defgeneric iterator-destroy (iterator) ;; #+:FELDSPAR ;; (:generic-function-class idl-interface-function) ;; #+:FELDSPAR ;; (:idl :void "destroy")) ;; ;; Not addressed : ;; ;; "IDL:omg.org/CosNaming:1.3/NamingContextExt" (TO DO) ;; ---- OLD NOTES #+NIL-PROTOTYPE (defun resolve-name (name) ;; Name kinds - an initial thesis ;; ;; 1. encoded name value ;; ;; a value (typically encoded with a string or other sequence ;; kind) representing a structured name, such that the the name ;; may be parsed to an implementation-specific decoded form ;; ;; e.g. URI, IOR, OID value ;; ;; applications: ;; - URI, IOR, and OIDs may be written to or read from a ;; stream, in certain network protocols ;; ;; 2. encoded object identifier ;; ;; a value that may be evaluated in a specific name context, ;; such as to retrieve an object not equivalent to the original ;; value ;; ;; e.g ;; ;; - Common Lisp variable value, for a Common Lisp symbol ;; evaluated onto the Common Lisp symbol value namespace ;; ;; - Common Lisp function definition, for a Common Lisp symbol ;; resolved onto the Common Lisp function namespace (excluding ;; SETF functions or other CONS-named functions) ;; ;; - Common Lisp class definition, for a Common Lispy symbo ;; resolved onto the Common Lisp classes namespace ;; ;; - CORBA object, broadly, for a CORBA IOR resolved to a CORBA ;; object definition ;; ;; - a STELLA qualified name - { <module name>, <symbol name> } ;; with <module name> being a sequence of module names ;; delimited with "/" characters (multiple-value-bind (prefix str) (split-string-1 #\: name) (resolve-name-using-resolver str (find-name-resolver prefix)))) #+NIL-PROTOTYPE (defun evaluate-name (name) ;; ... ) #| Towards a methodology for name resolution in Common Lisp programs e.g. in-naming-contet "/naming" asdf:<asdf-system-name> stella:sys:<stella-system-name> stella:mod:<stella-module-name> ;; tbd: memoization of system cardinal modules java:<java-class-name> ;; cf CL+J ldd:<shared-library-name> ;; cf. CFFI informative fudge: uri:<uri-scheme-name>:<scheme-specific-part> urn:<urn-namespace-name>:<namespace-specific-part> |#
26,421
Common Lisp
.lisp
681
32.975037
83
0.677533
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
005d0598ca3f5843f4fabfd06565c778f63e639391c3ef506bf802ba8bb19c8d
29,300
[ -1 ]
29,301
advise.lisp
thinkum_ltp-main/src/sandbox/portable-advise/advise.lisp
;; advise.lisp - portable reflective value wrapping for Common Lisp functions (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage #:reflexion (:use ;; #:libfoo #:cl ) (:export #:defadvise #:unadvise ))) ;; EVAL-WHEN (in-package #:reflexion) (deftype function-name () ;; also defined in libfoo '(or symbol (cons symbol t))) ;; trivial portable prototype of an 'advise' interface (defstruct (advise-record (:conc-name #:advised-) (:constructor make-advise-record (name kind env original-function))) (original-function #'(lambda () (error "Default advised-original-function")) :type function) ;; NB: no portable 'environment' type. ;; 'env' slot may only be useful for debugging (kind 'defun :type (member defun defmacro)) (env nil) (name #:unnamed :type function-name)) (define-condition advise-condition () ((name :initarg :name :reader advise-condition-name))) (define-condition already-advised (program-error advise-condition) () (:report (lambda (c s) (format s "Already advised: ~s" (advise-condition-name c))))) (define-condition not-advised (program-error advise-condition) () (:report (lambda (c s) (format s "Not advised: ~s" (advise-condition-name c))))) (defconstant %advise-expand% 8) (defconstant %advise-unbound% (cond ((boundp '%advise-unbound%) (symbol-value '%advise-unbound%)) ;; NB: Non-sandard : ALLOCATE-INSTANCE on STRUCTURE-CLASS (t (let ((inst (allocate-instance (find-class 'advise-record)))) (setf (advised-name inst) (gensym "%unbound-")))))) (defvar %advise-rec% (make-array %advise-expand% :element-type 'advise-record :adjustable t :initial-element %advise-unbound% :fill-pointer 0)) (defun get-advise (name env &optional (errorp t)) (declare (type function-name name) (ignore env) ;; FIXME (values (or null advise-record))) ;; FIXME: lock %ADVISE-REC% (READ, NON-RECURSIVE) in this function (labels ((test (a b) (etypecase a (symbol (and (symbolp b) (eq a b))) (cons (and (consp b) (test (car a) (car b)) (test (cdr a) (cdr b))))))) ;; (test '(a a) '(a b)) ;; => NIL ;; (test '(a a) '(a a)) ;; => T ;; (test '(a a a) '(a a b)) ;; => NIL ;; (test '(a a b) '(a a b)) ;; => T (let ((o (find name %advise-rec% :test (etypecase name (symbol #'eq) (cons #'test)) :key #'advised-name))) (cond (o (values o)) (errorp (error 'not-advised :name name)) (t (values nil nil)))))) (defun register-advise (name kind env form) ;; FIXME: lock %ADVISE-REC% (WRITE) in this function (let ((adv (get-advise name env nil))) (cond ((and adv (not (eq form (advised-original-function adv)))) (error 'already-advised :name name)) (t (let ((adv (make-advise-record name kind env form))) (vector-push-extend adv %advise-rec% %advise-expand%) (values adv)))))) (defun unregister-advise (name env) ;; FIXME: lock %ADVISE-REC% (WRITE) in this function (let ((adv (get-advise name env nil))) (cond (adv (setf %advise-rec% (delete adv %advise-rec% :test #'eq)) (values adv)) (t (error 'not-advised :name name))))) (defmacro defadvise (name lambda &key before after &environment env) ;; FIXME: This does not destructure LAMBDA for the BEFORE, AFTER functions, ;; and neither for the call to the advised macro function. (let ((%name (gensym "%name-")) (%env (gensym "%env-")) (%form (gensym "%form-")) (%kind (gensym "%kind-")) ) ;; FIXME: Difficuly to properly deconstruct DEFMETHOD LAMBDA for ;; bindings in the BEFORE, AFTER functions ;; see also: alexandria.0.dev:parse-ordinary-lambda-list `(let* ((,%name (quote ,name)) (,%env ,env) (,%kind 'defun) (,%form (or (let ((,%form (macro-function ,%name ,%env))) ;; FIXME: THIS might not always "work out" (when ,%form (setq ,%kind 'defmacro) (eval (function-lambda-expression ,%form)))) (fdefinition ,%name) (error "No macro function and no function defined for name ~S" ,%name)))) (register-advise ,%name ,%kind ,%env ,%form) (macrolet ((do-def () `(,%kind ,name ,lambda ,@(when before `((funcall (lambda () ,before )))) (unwind-protect , (ecase ,%kind (defmacro (eval (funcall (eval ,%form) ;; FIXME : ,LAMBDA NOT RIGHT HERE ????? ,%env))) (defun (funcall ,%form THE-FANCY-ARGS-LIST))) ,@(when after `((funcall (lambda () ,after)))))))) (do-def))))) (defmacro unadvise (name &environment env) (let ((%name (gensym "%name-")) (%adv (gensym "%adv-")) (%kind (gensym "%kind-")) (%fn (gensym "%fn-"))) `(let* ((,%name (quote ,name)) (,%adv (unregister-advise ,%name ,env)) (,%kind (advised-kind ,%adv)) (,%fn (advised-original-function ,%adv))) ;; FIXME: MACRO (ecase ,%kind (defmacro (setf (macro-function ,%name) ,%fn)) (defun (setf (fdefinition ,%name) ,%fn))) (compile ,%name ,%fn) (values ,%fn)))) #| (defmacro frob-trace (ctrl &rest args) `(progn (write-char #\Newline *trace-output*) (format *trace-output* ,ctrl ,@args) (write-char #\Newline *trace-output*) (finish-output *trace-output*))) (defmacro quux (arg) `(progn (frob-trace "GOT ARG QUUX ~S" ,arg) (list :quux ,arg))) #+test (quux 5) (macroexpand (quote (defadvise quux (%arg) :before (lambda (%argtoo) (frob-trace "GOT ARGTOO BEFORE ~s" %argtoo)) :after (lambda (%argtoo) (frob-trace "GOT ARGTOO AFTER ~s" %argtoo)) ) )) #+test (quux 12) ;; ^FIXME: *trace-output* shows order of eval: :BEFORE, :AFTER, :DURING (unadvise quux) #+test (quux 28) |# ;; Prototypes #+NIL (defmacro compute-defkind (name &environment env) ;; endeavor to compute a discrete 'kind' of a function's definition ;; ;; NB: This does not compute 'definitino source kind' - e.g. ;; whether a function is defined of an accessor, constructor, or ;; other non-DEFUN source - such that may serve to require an ;; implementation-specific reflection, and may require more than ;; only a function's name, to compute. (let ((%name (gensym "%name-")) (%env (gensym "%env-")) (%fn (gensym "%fn-"))) `(let ((,%name (quote ,name)) (,%env ,env)) (declare (type (or symbol (cons symbol t)) ,%name)) (cond ((macro-function ,%name ,%env) (values 'defmacro)) ((and (consp ,%name) (eq (car ,%name) 'setf)) ;; ?? (values 'defsetf)) ((and (consp ,%name) (eq (car ,%name) 'lambda)) ;; ?? (values 'lambda)) (t (let ((,%fn (fdefinition ,%name))) (typecase ,%fn (generic-function (values 'defgeneric)) (standard-object ;; funcallable-standard-object portably ;; ?? (values 'defclass)) (function (values 'defun)) (t (values :unknown)))))))))
8,251
Common Lisp
.lisp
221
27.248869
84
0.525334
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
ee7405c68502650ef4204ac122a399e921a7835a339ea7097ec1f86e44f87086
29,301
[ -1 ]
29,302
module-asdf.lisp
thinkum_ltp-main/src/sandbox/impl-utils/impl-utils-sbcl/module-asdf.lisp
;; module-asdf.lisp - Provide SBCL contrib systems via ASDF, for REQUIRE ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2018 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial API and implementation ;; ;;------------------------------------------------------------------------------ (defun module-provide-sbcl-contrib-asdf (name &optional (noerror t)) ;; NB: Mostly portable - should be OK to compile and load this ;; defun, even when ASDF is not loaded ;; * Overview ;; ;; This function allows for loading SBCL contrib systems via ASDF, ;; independent of the configuration of ASDF system paths. When an SBCL ;; contrib system is available as an ASDF system definition via the ;; logical pathname "sys:contrib;<name>;<name>.asd" then that system ;; definition will be loaded and the corresponding system <name> will ;; be used for an ASDF LOAD-OP onto the ASDF PERFORM method. The ;; system definition will be returned. ;; ;; Otherwise, when evaluated via SBCL REQUIRE, the value NIL will be ;; returned. ;; ;; This function may be evaluated independent of ASDF REQUIRE. In ;; such instances, the optional NOERROR argument may be provided with a ;; nil value. If a system definition cannot be located at the ;; specified pathname and NOERROR is nil, then an error of type ;; SIMPLE-ERROR will be be produced. If NOERROR is true - as per the ;; default behavior of this function - and a system definition cannot ;; be located at the specified pathname. then NIL will be returned. ;; ;; ;; * Configuration ;; ;; This function requires that the SBCL image will have been ;; configured for logical pathnames under "sys:contrib;" such as for ;; the sb-posix system, "sys:contrib;sb-posix;sb-posix.asd". The SBCL ;; installation may have been automatically configured for this ;; logical pathname, in many conventional installations. ;; ;; ;; * Installation ;; ;; This function may be defined within in an ASDF user-init file e.g ;; with a UNIX system pathname ~/.sbclrc ;; ;; In the following example, it's assumed that ASDF either has been ;; loaded into the running Lisp image, or may be loaded independent of ;; this function definition, using SBCL REQUIRE ;; ;; Example: ;; ;; ;; (when (progn (require '#:asdf) (find-package '#:asdf)) ;; ;; <function body> ;; ;; (eval-when (:load-toplevel :execute) ;; (setq sb-ext:*module-provider-functions* ;; (pushnew 'module-provide-sbcl-contrib-asdf ;; sb-ext:*module-provider-functions*)))) ;; ;; ;; Subsequently, the following form should evaluate successfully: ;; ;; (require '#:sb-posix) ;; ;; ;; Notes ;; ;; Sometimes, an SBCL contrib system may not have been successfully ;; installed with SBCL -- such as may occur when the compilation ;; failed one or more tests, such as may coincide with any undefined ;; references during sb-grovel for the sb-posix system, in some SBCL ;; builds. ;; ;; When the original source code for any single SBCL contrib system is ;; available at a known pathname, on the installation host, then -- ;; concerning this method of using an ASDF PERFORM operation to ;; compile and load the original contrib system -- this function may ;; serve to provide a manner of an expedient utility for compiling ;; and loading the original source code for the respective contrib ;; system. (let* ((syspath (format nil "sys:contrib;~a;~a.asd" name name)) ;; NB: The following will ignore errors in logical pathname ;; translation, such that the Lisp may not be able to detect ;; trivially (sysdef-path (ignore-errors (probe-file syspath)))) (cond (sysdef-path (let* ((asdf-pkg (or (find-package '#:asdf) noerror (error "ASDF not loaded?"))) (*package* asdf-pkg)) (when asdf-pkg ;; NB: In loading the system definition directly, this ;; function may be used independent of any system pathname ;; configuration in ASDF (load sysdef-path) (block load-op-x (flet ((symbol-ref (name) ;; for compile/load time safety w/o ASDF (declare (type symbol name)) (or (find-symbol (symbol-name name) asdf-pkg) (and noerror (return-from load-op-x nil)) (progn (error "Symbol ~s not found in ~s" name asdf-pkg))))) (let ((sysdef (funcall (symbol-ref '#:find-system) name nil))) (when sysdef (funcall (symbol-ref '#:operate) (symbol-ref '#:load-op) sysdef) ;; return the system definition from within REQUIRE sysdef)))) ))) (noerror nil) (t (error "No system definition found for module ~s at ~s" name syspath))))) ;; Local Variables: ;; ispell-buffer-session-localwords: ("funcall" "init" "noerror" "pathname" "pathnames" "posix" "progn" "pushnew" "sb" "sbcl" "sbclrc" "setq" "sys" "sysdef" "syspath" "toplevel") ;; End:
5,747
Common Lisp
.lisp
131
36.541985
178
0.614151
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
298772cd6b6427f18f478fc28cf530e2e0ffc6f49c6c474b36a3317a9342dbe7
29,302
[ -1 ]
29,303
file.lisp
thinkum_ltp-main/src/template/cltl/file.lisp
;; %%BASENAME%% - %%SYNOPSIS%% ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) %%YEAR%% %%WHOM%% and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: %%WHOM%% - Initial API and implementation ;; ;;------------------------------------------------------------------------------ ;; ;; DESCRIPTION ;; ;; %%SOURCEDESC%% ;; ;; SEE ALSO ;; ;; %%SEEALSO%% ;; (in-package %%PACKAGE%%)
655
Common Lisp
.lisp
22
28.681818
80
0.52057
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
546c1d028565101b9801b986062e2bf0ab6519dd1a3db7278a3f630d797c5f06
29,303
[ -1 ]
29,304
file_copynotice.lisp
thinkum_ltp-main/src/template/cltl/file_copynotice.lisp
;;------------------------------------------------------------------------------ ;; ;; Copyright (c) %%YEAR%% %%WHOM%% and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: %%WHOM%% - Initial API and implementation ;; ;;------------------------------------------------------------------------------
523
Common Lisp
.lisp
11
46.454545
80
0.511719
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
36c4ab53ef48e30df93f7adb25abf0de76c4e534e1958d91d00abceaf7e2f60e
29,304
[ -1 ]
29,305
ltp-base-class-acc.asd
thinkum_ltp-main/src/main/lsp/base-class/ltp-base-class-acc.asd
;; ltp-base-class-fdef.asd - Function Definitions after DEFSTRUCT -*-lisp-*- ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial implementation ;; ;;------------------------------------------------------------------------------ ;; (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage #:ltp-common-system ;; note package reuse - package ltp-common-system (:use #:asdf #:cl))) (in-package #:ltp-common-system) (defsystem #:ltp-base-class-acc :license "spdx:EPL-1.0" :depends-on (#:ltp-common-mop #:ltp-common) :components ((:file "acc-package") (:file "acc-gen" :depends-on ("acc-package")) ))
1,058
Common Lisp
.asd
28
34.785714
80
0.588465
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
6bc052bf9a4368dfeb6a8b08a5c28aeaa94f699f50a65f53ad2928d4da51cb51
29,305
[ -1 ]
29,306
ltp-common.asd
thinkum_ltp-main/src/main/lsp/common/ltp-common.asd
;; ltp-common.asd - generic utilitiess system, LTP -*-lisp-*- ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial implementation ;; ;;------------------------------------------------------------------------------ ;; ;; DESCRIPTION ;; ;; A generic utilities system, providing a number of reusable forms for ;; Common Lisp progrms. The types of forms provided in this system ;; include: ;; ;; - Functions ;; - Macros ;; - Type Definitions ;; - Condition Types ;; ;; SEE ALSO ;; ;; * CLOCC [Project] ;; * Alexandria [Project] (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage #:ltp-common-system ;; note package reuse - package ltp-common-system (:use #:asdf #:cl))) (in-package #:ltp-common-system) (defsystem #:ltp-common :description "Generic utilities for programming with Common Lisp" :version "2.0" ;; FIXME update for MCi (deprecation) => [TL] LTP (adoption) ;; :homepage TBD :license "spdx:EPL-1.0" :components ((:file "common-package") (:file "common-macro" :depends-on ("common-package")) (:file "common-type" :depends-on ("common-package" "common-lambda")) (:file "common-clos" :depends-on ("common-macro")) (:file "common-fn" :depends-on ("common-package" "common-lambda")) (:file "common-condition" :depends-on ("common-package")) (:file "common-stream" :depends-on ("common-package" "common-lambda")) (:file "common-opt" :depends-on ("common-package")) (:file "common-misc" :depends-on ("common-macro" "common-stream" "common-fn" ;; FUNCTION-DESIGNATOR "common-condition" "common-lambda" "common-opt" ;; WITH-OPTIMIZATION )) (:file "common-sym" :depends-on ("common-lambda" )) (:file "common-print" :depends-on ("common-misc" "common-fn" "common-lambda" "common-sym" ;; SYMBOL-STATUS )) (:file "common-seq" :depends-on ("common-macro")) (:file "common-list" ;; NB was common-seq.lisp, common-vec.lisp, common-string.lisp :depends-on ("common-macro")) (:file "common-vec" :depends-on ("common-macro" "common-lambda" "common-seq" ;; NB DO-MAPPED reimpl of DO-VECTOR )) (:file "common-string" :depends-on ("common-macro" "common-type" "common-misc" "common-lambda" "common-opt" ;; WITH-TAIL-RECURSION [TBD] )) (:file "common-reader" :depends-on ("common-type" "common-stream")) (:file "common-lambda" :depends-on ("common-macro" ;; DEFCONSTANT* "common-list" ;; NPUSHL "common-condition" ;; SIMPLE-STYLE-WARNING )) ))
3,448
Common Lisp
.asd
97
27.402062
80
0.541342
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
2bf079d7d8cd0ea6dd01d85baa5dbd08a2f20f9d258057d2cec0a8a1732997df
29,306
[ -1 ]
29,307
ltp-common-mop.asd
thinkum_ltp-main/src/main/lsp/mop/common/ltp-common-mop.asd
;; ltp-common-mop.asd -*- lisp -*- ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (unless (find-package '#:ltp-common-system) (defpackage #:ltp-common-system ;; note package reuse - package is defined originally in ltp-common.asd (:use #:asdf #:cl)))) (in-package #:ltp-common-system) (defsystem #:ltp-common-mop ;; :description "" :version "1.0" ;; :homepage TBD :license "spdx:EPL-1.0" :depends-on (#:ltp-common #:closer-mop ) :components ((:file "common-mop-package") ;; c2mop integration (:file "mop-utils" ;; validate-[super]class (convenience macro) :depends-on ("common-mop-package")) (:file "finalize" :depends-on ("common-mop-package")) ))
1,344
Common Lisp
.asd
34
35.647059
80
0.568688
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
227dda52f8729b669701532fba702c2314d3abddcf4fd4aba77ac70c4950a250
29,307
[ -1 ]
29,308
ltp-common-singleton.asd
thinkum_ltp-main/src/main/lsp/mop/singleton/ltp-common-singleton.asd
;; ltp-common-mop.asd -*- lisp -*- ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2019 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (unless (find-package '#:ltp-common-system) (defpackage #:ltp-common-system ;; note package reuse - package is defined originally in ltp-common.asd (:use #:asdf #:cl)))) (in-package #:ltp-common-system) (defsystem #:ltp-common-singleton ;; :description "" :version "1.0" ;; :homepage TBD :license "spdx:EPL-1.0" :depends-on (#:ltp-common-mop #:closer-mop #:ltp-common ) :components ((:file "singleton") ))
1,165
Common Lisp
.asd
31
33.83871
80
0.552702
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
a8ff5b78f100194e62223eb39286b5e1b61a41cf94c795b3a452574997fadeec
29,308
[ -1 ]
29,310
ltp-asdf-utils.asd
thinkum_ltp-main/src/main/lsp/asdf/ltp-asdf-utils.asd
;; ltp-asdf-utils.asd - LTP utilties for ASDF system definitions -*-lisp-*- ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) 2014-2017 Sean Champ and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: Sean Champ - Initial Implementation ;; ;;------------------------------------------------------------------------------ (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage #:ltp-utils-system ;; note package reuse - package ltp-utils-system (:use #:asdf #:cl))) (in-package #:ltp-utils-system) (defsystem #:ltp-asdf-utils ;; :description "" :version "1.0" ;; :homepage TBD :license "spdx:EPL-1.0" :depends-on (#:ltp-utils) :components ((:file "ltp-asdf-utils-package") (:file "ext-utils" :depends-on ("ltp-asdf-utils-package")) (:file "ext-star" :depends-on ("ltp-asdf-utils-package")) (:file "ext-alias" :depends-on ("ext-star")) ))
1,223
Common Lisp
.asd
33
33.909091
80
0.589873
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
1057364641356c5f75b32b05cce6214b447414f0d1fcafc8df3278acf63f7ffd
29,310
[ -1 ]
29,316
doclifter_gendocs.sh
thinkum_ltp-main/doc/docbook/ltp-eo/doclifter_gendocs.sh
#!/usr/bin/env bash set -e ## -- DOCLIFTER=/usr/local/bin/doclifter ## -- THIS=$(basename "$0") HERE=$(dirname $(readlink -f "$0")) msg() { echo "#-- ${THIS}: $@" } fail() { msg "$@" 1>&2 exit } fail_doc_not_found(){ fail "Not found: $@" } ## -- ROFF="" for DOCSPEC in "$@"; do SECTION=${DOCSPEC##*:} REFNAME=${DOCSPEC%:*} msg "Resolving ${REFNAME}(${SECTION}) from ${DOCSPEC}" SRCMAN=$(man -w "${SECTION}" "${REFNAME}" || fail_doc_not_found "${DOCSPEC} => ${REFNAME}(${SECTION})") msg "Resolved to ${SRCMAN}" ## NB: This assumes that the manual page is gzipped - should dispach on filename #msg "Copying ${SRCMAN} to ${HERE}" msg "Unpacking ${SRCMAN} to ${FNAME}" FNAME=$(basename ${SRCMAN}) FNAME=${FNAME%.gz} zcat "${SRCMAN}" > "${PWD}/${FNAME}" ROFF="${ROFF} ${FNAME}" done ## FIXME - prefer mandoc -T html ## e.g mandoc -T html dlopen.3 ## b.c it does not add the strange "@GLUE@" token as in dlopen.3.xml msg "Running doclifter" ${DOCLIFTER} -ww -x -h doclifter.hints ${ROFF}
1,048
Common Lisp
.cl
39
24.179487
82
0.612513
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
b185fdd7996e2699b415f74b37ee6e3c253c0a3078c4bb67b121233efb17dfdc
29,316
[ -1 ]
29,368
file.el
thinkum_ltp-main/src/template/elisp/file.el
;; %%BASENAME%% - %%SYNOPSIS%% ;;------------------------------------------------------------------------------ ;; ;; Copyright (c) %%YEAR%% %%WHOM%% and others. All rights reserved. ;; ;; This program and the accompanying materials are made available under the ;; terms of the Eclipse Public License v1.0 which accompanies this distribution ;; and is available at http://www.eclipse.org/legal/epl-v10.html ;; ;; Contributors: %%WHOM%% - Initial API and implementation ;; ;;------------------------------------------------------------------------------ ;; ;; DESCRIPTION ;; ;; %%SOURCEDESC%% ;; ;; SEE ALSO ;; ;; %%SEEALSO%% ;; (eval-when-compile (require 'cl)) (eval-when () ) ;; E.W
690
Common Lisp
.l
24
27.541667
80
0.52259
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
fab93cb5e9099130d08bcfb04ff2dbae35e1b65f8546da091f18558cb1e4bc90
29,368
[ -1 ]
29,371
rtld.1.xml
thinkum_ltp-main/doc/docbook/ltp-eo/rtld.1.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- lifted from mdoc+troff by doclifter --> <refentry xmlns='http://docbook.org/ns/docbook' version='5.0' xml:lang='en' xml:id='doclifter-rtld1'> <!-- Copyright (c) 1995 Paul Kranenburg All rights reserved. --> <!-- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgment: This product includes software developed by Paul Kranenburg. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission --> <!-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> <!-- $FreeBSD: stable/11/libexec/rtld&bsol;-elf/rtld.1 325409 2017&bsol;-11&bsol;-04 22:23:41Z bdrewery $ --> <refmeta> <refentrytitle>RTLD</refentrytitle> <manvolnum>1</manvolnum> </refmeta> <refnamediv xml:id='doclifter-purpose'> <refname>ld-elf.so.1</refname> <!-- NB: Doclifter added a @GLUE@ token to the initial refname. That was removed, in this text. The following were transposed from the original rtld.1 --> <refname>ld.so</refname> <refname>rtld</refname> <refpurpose> run-time link-editor </refpurpose> </refnamediv> <!-- body begins here --> <refsect1 xml:id='doclifter-description'><title>DESCRIPTION</title> <para>The <command remap='Nm'> ld-elf.so.1,</command> utility is a self-contained shared object providing run-time support for loading and link-editing shared objects into a process' address space. It is also commonly known as the dynamic linker. It uses the data structures contained within dynamically linked programs to determine which shared libraries are needed and loads them using the <citerefentry><refentrytitle>mmap</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call.</para> <para>After all shared libraries have been successfully loaded, <command remap='Nm'> ld-elf.so.1,</command> proceeds to resolve external references from both the main program and all objects loaded. A mechanism is provided for initialization routines to be called on a per-object basis, giving a shared object an opportunity to perform any extra set-up before execution of the program proper begins. This is useful for C++ libraries that contain static constructors.</para> <para>When resolving dependencies for the loaded objects, <command remap='Nm'> ld-elf.so.1,</command> translates dynamic token strings in rpath and soname. If the <option>-z origin</option> option of the static linker was set when linking the binary, the token expansion is performed at the object load time, see <citerefentry><refentrytitle>ld</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The following strings are recognized now:</para> <variablelist remap='Bl -tag -width .Pa $PLATFORM'> <varlistentry> <term><filename>$ORIGIN</filename></term> <listitem> <para>Translated to the full path of the loaded object.</para> </listitem> </varlistentry> <varlistentry> <term><filename>$OSNAME</filename></term> <listitem> <para>Translated to the name of the operating system implementation.</para> </listitem> </varlistentry> <varlistentry> <term><filename>$OSREL</filename></term> <listitem> <para>Translated to the release level of the operating system.</para> </listitem> </varlistentry> <varlistentry> <term><filename>$PLATFORM</filename></term> <listitem> <para>Translated to the machine hardware platform.</para> </listitem> </varlistentry> </variablelist> <para>The <command remap='Nm'> ld-elf.so.1,</command> utility itself is loaded by the kernel together with any dynamically-linked program that is to be executed. The kernel transfers control to the dynamic linker. After the dynamic linker has finished loading, relocating, and initializing the program and its required shared objects, it transfers control to the entry point of the program. The following search order is used to locate required shared objects:</para> <orderedlist remap='Bl -enum -offset indent -compact'> <listitem> <para><constant>DT_RPATH</constant> of the referencing object unless that object also contains a <constant>DT_RUNPATH</constant> tag</para> </listitem> <listitem> <para><constant>DT_RPATH</constant> of the program unless the referencing object contains a <constant>DT_RUNPATH</constant> tag</para> </listitem> <listitem> <para>Path indicated by <envar>LD_LIBRARY_PATH</envar> environment variable</para> </listitem> <listitem> <para><constant>DT_RUNPATH</constant> of the referencing object</para> </listitem> <listitem> <para>Hints file produced by the <citerefentry><refentrytitle>ldconfig</refentrytitle><manvolnum>8</manvolnum></citerefentry> utility</para> </listitem> <listitem> <para>The <filename>/lib</filename> and <filename>/usr/lib</filename> directories, unless the referencing object was linked using the &ldquo;Fl z Ar nodefaultlib&rdquo; option</para> </listitem> </orderedlist> <para>The <command remap='Nm'> ld-elf.so.1,</command> utility recognizes a number of environment variables that can be used to modify its behaviour. On 64-bit architectures, the linker for 32-bit objects recognizes all the environment variables listed below, but is being prefixed with <envar>LD_32_</envar>, for example: <envar>LD_32_TRACE_LOADED_OBJECTS</envar>.</para> <variablelist remap='Bl -tag -width .Ev LD_LIBMAP_DISABLE'> <varlistentry> <term><envar>LD_DUMP_REL_POST</envar></term> <listitem> <para>If set, <command remap='Nm'> ld-elf.so.1,</command> will print a table containing all relocations after symbol binding and relocation.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_DUMP_REL_PRE</envar></term> <listitem> <para>If set, <command remap='Nm'> ld-elf.so.1,</command> will print a table containing all relocations before symbol binding and relocation.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_LIBMAP</envar></term> <listitem> <para>A library replacement list in the same format as <citerefentry><refentrytitle>libmap.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>. For convenience, the characters ' = ' and ' , ' can be used instead of a space and a newline. This variable is parsed after <citerefentry><refentrytitle>libmap.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, and will override its entries. This variable is unset for set-user-ID and set-group-ID programs.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_LIBMAP_DISABLE</envar></term> <listitem> <para>If set, disables the use of <citerefentry><refentrytitle>libmap.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> and <envar>LD_LIBMAP</envar>. This variable is unset for set-user-ID and set-group-ID programs.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_ELF_HINTS_PATH</envar></term> <listitem> <para>This variable will override the default location of &ldquo;hints&rdquo; file. This variable is unset for set-user-ID and set-group-ID programs.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_LIBRARY_PATH</envar></term> <listitem> <para>A colon separated list of directories, overriding the default search path for shared libraries. This variable is unset for set-user-ID and set-group-ID programs.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_LIBRARY_PATH_RPATH</envar></term> <listitem> <para>If the variable is specified and has a value starting with any of &acute;y&acute;, &acute;Y&acute; or &acute;1&acute; symbols, the path specified by <envar>LD_LIBRARY_PATH</envar> variable is allowed to override the path from <constant>DT_RPATH</constant> for binaries which does not contain <constant>DT_RUNPATH</constant> tag. For such binaries, when the variable <envar>LD_LIBRARY_PATH_RPATH</envar> is set, &ldquo;Fl z Ar nodefaultlib&rdquo; link-time option is ignored as well.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_PRELOAD</envar></term> <listitem> <para>A list of shared libraries, separated by colons and/or white space, to be linked in before any other shared libraries. If the directory is not specified then the directories specified by <envar>LD_LIBRARY_PATH</envar> will be searched first followed by the set of built-in standard directories. This variable is unset for set-user-ID and set-group-ID programs.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_LIBRARY_PATH_FDS</envar></term> <listitem> <para>A colon separated list of file descriptor numbers for library directories. This is intended for use within <citerefentry><refentrytitle>capsicum</refentrytitle><manvolnum>4</manvolnum></citerefentry> sandboxes, when global namespaces such as the filesystem are unavailable. It is consulted just after LD_LIBRARY_PATH. This variable is unset for set-user-ID and set-group-ID programs.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_BIND_NOT</envar></term> <listitem> <para>When set to a nonempty string, prevents modifications of the PLT slots when doing bindings. As result, each call of the PLT-resolved function is resolved. In combination with debug output, this provides complete account of all bind actions at runtime. This variable is unset for set-user-ID and set-group-ID programs.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_BIND_NOW</envar></term> <listitem> <para>When set to a nonempty string, causes <command remap='Nm'> ld-elf.so.1,</command> to relocate all external function calls before starting execution of the program. Normally, function calls are bound lazily, at the first call of each function. <envar>LD_BIND_NOW</envar> increases the start-up time of a program, but it avoids run-time surprises caused by unexpectedly undefined functions.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_TRACE_LOADED_OBJECTS</envar></term> <listitem> <para>When set to a nonempty string, causes <command remap='Nm'> ld-elf.so.1,</command> to exit after loading the shared objects and printing a summary which includes the absolute pathnames of all objects, to standard output.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_TRACE_LOADED_OBJECTS_ALL</envar></term> <listitem> <para>When set to a nonempty string, causes <command remap='Nm'> ld-elf.so.1,</command> to expand the summary to indicate which objects caused each object to be loaded.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_TRACE_LOADED_OBJECTS_FMT1</envar></term> <term> <envar>LD_TRACE_LOADED_OBJECTS_FMT2</envar></term> <listitem> <para>When set, these variables are interpreted as format strings a la <citerefentry><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry> to customize the trace output and are used by <citerefentry><refentrytitle>ldd</refentrytitle><manvolnum>1</manvolnum></citerefentry> <option>-f</option> option and allows <citerefentry><refentrytitle>ldd</refentrytitle><manvolnum>1</manvolnum></citerefentry> to be operated as a filter more conveniently. If the dependency name starts with string <filename>lib</filename>, <envar>LD_TRACE_LOADED_OBJECTS_FMT1</envar> is used, otherwise <envar>LD_TRACE_LOADED_OBJECTS_FMT2</envar> is used. The following conversions can be used:</para> <variablelist remap='Bl -tag -width 4n'> <varlistentry> <term><literal>%a</literal></term> <listitem> <para>The main program's name (also known as &ldquo;__progname&rdquo;).</para> </listitem> </varlistentry> <varlistentry> <term><literal>%A</literal></term> <listitem> <para>The value of the environment variable <envar>LD_TRACE_LOADED_OBJECTS_PROGNAME</envar>. Typically used to print both the names of programs and shared libraries being inspected using <citerefentry><refentrytitle>ldd</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para> </listitem> </varlistentry> <varlistentry> <term><literal>%o</literal></term> <listitem> <para>The library name.</para> </listitem> </varlistentry> <varlistentry> <term><literal>%p</literal></term> <listitem> <para>The full pathname as determined by <command remap='Nm'> ld-elf.so.1,</command> library search rules.</para> </listitem> </varlistentry> <varlistentry> <term><literal>%x</literal></term> <listitem> <para>The library's load address.</para> </listitem> </varlistentry> </variablelist> <para>Additionally, ' &bsol;n ' and ' &bsol;t ' are recognized and have their usual meaning.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_UTRACE</envar></term> <listitem> <para>If set, <command remap='Nm'> ld-elf.so.1,</command> will log events such as the loading and unloading of shared objects via <citerefentry><refentrytitle>utrace</refentrytitle><manvolnum>2</manvolnum></citerefentry>.</para> </listitem> </varlistentry> <varlistentry> <term><envar>LD_LOADFLTR</envar></term> <listitem> <para>If set, <command remap='Nm'> ld-elf.so.1,</command> will process the filtee dependencies of the loaded objects immediately, instead of postponing it until required. Normally, the filtees are opened at the time of the first symbol resolution from the filter object.</para> </listitem> </varlistentry> </variablelist> </refsect1> <refsect1 xml:id='doclifter-direct_execution_mode'><title>DIRECT EXECUTION MODE</title> <para><command remap='Nm'> ld-elf.so.1,</command> is typically used implicitly, loaded by the kernel as requested by the <constant>PT_INTERP</constant> program header of the executed binary. <productname>FreeBSD</productname> also supports a direct execution mode for the dynamic linker. In this mode, the user explicitly executes <command remap='Nm'> ld-elf.so.1,</command> and provides the path of the program to be linked and executed as an argument. This mode allows use of a non-standard dynamic linker for a program activation without changing the binary or without changing the installed dynamic linker. Execution options may be specified.</para> <para>The syntax of the direct invocation is <filename>/libexec/ld-elf.so.1</filename> <option>-f</option> <replaceable>fd</replaceable> <option>-p</option> <option>--</option> <filename>image_path</filename> <replaceable>image</replaceable> <replaceable>arguments</replaceable></para> <para>The options are:</para> <variablelist remap='Bl -tag -width indent'> <varlistentry> <term><option>-f</option> <replaceable>fd</replaceable></term> <listitem> <para>File descriptor <replaceable>fd</replaceable> references the binary to be activated by <command remap='Nm'> ld-elf.so.1,</command> It must already be opened in the process when executing <command remap='Nm'> ld-elf.so.1,</command> If this option is specified, <replaceable>image_path</replaceable> is only used to provide the <varname>argv[0]</varname> value to the program.</para> </listitem> </varlistentry> <varlistentry> <term><option>-p</option></term> <listitem> <para>If the <filename>image_path</filename> argument specifies a name which does not contain a slash &ldquo;Li /&rdquo; character, <command remap='Nm'> ld-elf.so.1,</command> uses the search path provided by the environment variable <constant>PATH</constant> to find the binary to execute.</para> </listitem> </varlistentry> <varlistentry> <term><option>--</option></term> <listitem> <para>Ends the <command remap='Nm'> ld-elf.so.1,</command> options. The argument following <option>--</option> is interpreted as the path of the binary to execute.</para> </listitem> </varlistentry> </variablelist> <para>In the direct execution mode, <command remap='Nm'> ld-elf.so.1,</command> emulates verification of the binary execute permission for the current user. This is done to avoid breaking user expectations in naively restricted execution environments. The verification only uses Unix <constant>DACs</constant>, ignores <constant>ACLs</constant>, and is naturally prone to race conditions. Environments which rely on such restrictions are weak and breakable on their own.</para> </refsect1> <refsect1 xml:id='doclifter-files'><title>FILES</title> <variablelist remap='Bl -tag -width .Pa /var/run/ld-elf32.so.hints -compact'> <varlistentry> <term><filename>/var/run/ld-elf.so.hints</filename></term> <listitem> <para>Hints file.</para> </listitem> </varlistentry> <varlistentry> <term><filename>/var/run/ld-elf32.so.hints</filename></term> <listitem> <para>Hints file for 32-bit binaries on 64-bit system.</para> </listitem> </varlistentry> <varlistentry> <term><filename>/etc/libmap.conf</filename></term> <listitem> <para>The libmap configuration file.</para> </listitem> </varlistentry> <varlistentry> <term><filename>/etc/libmap32.conf</filename></term> <listitem> <para>The libmap configuration file for 32-bit binaries on 64-bit system.</para> </listitem> </varlistentry> </variablelist> </refsect1> <refsect1 xml:id='doclifter-see_also'><title>SEE ALSO</title> <para><citerefentry><refentrytitle>ld</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>ldd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>capsicum</refentrytitle><manvolnum>4</manvolnum></citerefentry>, <citerefentry><refentrytitle>elf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, <citerefentry><refentrytitle>libmap.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, <citerefentry><refentrytitle>ldconfig</refentrytitle><manvolnum>8</manvolnum></citerefentry></para> </refsect1> </refentry>
18,434
Common Lisp
.l
511
34.996086
109
0.791832
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
5121015a0ab3933e601b0482aea013d1bf2194e982f48a27a2c3aad92c112db0
29,371
[ -1 ]
29,372
ld.1.xml
thinkum_ltp-main/doc/docbook/ltp-eo/ld.1.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- lifted from pod2man+man+troff by doclifter --> <refentry xmlns='http://docbook.org/ns/docbook' version='5.0' xml:lang='en' xml:id='doclifter-ld1'> <refentryinfo><date>2010-10-30</date></refentryinfo> <refmeta> <refentrytitle>LD</refentrytitle> <manvolnum>1</manvolnum> <refmiscinfo class='date'>2010-10-30</refmiscinfo> <refmiscinfo class='source'>binutils-2.17.50</refmiscinfo> <refmiscinfo class='manual'>GNU Development Tools</refmiscinfo> </refmeta> <refnamediv> <refname>ld</refname> <refpurpose>The GNU linker</refpurpose> </refnamediv> <!-- body begins here --> <refsynopsisdiv xml:id='doclifter-synopsis'> <cmdsynopsis> <command>ld</command> <arg choice='opt'><replaceable>options</replaceable></arg> <arg choice='plain' rep='repeat'><replaceable>objfile</replaceable></arg> </cmdsynopsis> </refsynopsisdiv> <refsect1 xml:id='doclifter-description'><title>DESCRIPTION</title> <para><indexterm><primary>Header</primary><secondary>DESCRIPTION</secondary></indexterm> <emphasis role='strong' remap='B'>ld</emphasis> combines a number of object and archive files, relocates their data and ties up symbol references. Usually the last step in compiling a program is to run <emphasis role='strong' remap='B'>ld</emphasis>.</para> <para><emphasis role='strong' remap='B'>ld</emphasis> accepts Linker Command Language files written in a superset of <?troff ps -1?>AT&amp;T<?troff ps 0?>'s Link Editor Command Language syntax, to provide explicit and total control over the linking process.</para> <para>This man page does not describe the command language; see the <emphasis role='strong' remap='B'>ld</emphasis> entry in <emphasis remap='CW'>`info'</emphasis> for full details on the command language and on other aspects of the <?troff ps -1?>GNU<?troff ps 0?> linker.</para> <para>This version of <emphasis role='strong' remap='B'>ld</emphasis> uses the general purpose <?troff ps -1?>BFD<?troff ps 0?> libraries to operate on object files. This allows <emphasis role='strong' remap='B'>ld</emphasis> to read, combine, and write object files in many different formats---for example, <?troff ps -1?>COFF<?troff ps 0?> or <emphasis remap='CW'>`a.out'</emphasis>. Different formats may be linked together to produce any available kind of object file.</para> <para>Aside from its flexibility, the <?troff ps -1?>GNU<?troff ps 0?> linker is more helpful than other linkers in providing diagnostic information. Many linkers abandon execution immediately upon encountering an error; whenever possible, <emphasis role='strong' remap='B'>ld</emphasis> continues executing, allowing you to identify other errors (or, in some cases, to get an output file in spite of the error).</para> <para>The <?troff ps -1?>GNU<?troff ps 0?> linker <emphasis role='strong' remap='B'>ld</emphasis> is meant to cover a broad range of situations, and to be as compatible as possible with other linkers. As a result, you have many choices to control its behavior.</para> </refsect1> <refsect1 xml:id='doclifter-options'><title>OPTIONS</title> <para><indexterm><primary>Header</primary><secondary>OPTIONS</secondary></indexterm> The linker supports a plethora of command-line options, but in actual practice few of them are used in any particular context. For instance, a frequent use of <emphasis role='strong' remap='B'>ld</emphasis> is to link standard Unix object files on a standard, supported Unix system. On such a system, to link a file <emphasis remap='CW'>`hello.o'</emphasis>:</para> <literallayout remap='Vb'> ld -o &lt;output&gt; /lib/crt0.o hello.o -lc </literallayout> <!-- remap='Ve' --> <para>This tells <emphasis role='strong' remap='B'>ld</emphasis> to produce a file called <emphasis remap='I'>output</emphasis> as the result of linking the file <emphasis remap='CW'>`/lib/crt0.o'</emphasis> with <emphasis remap='CW'>`hello.o'</emphasis> and the library <emphasis remap='CW'>`libc.a'</emphasis>, which will come from the standard search directories. (See the discussion of the <emphasis role='strong' remap='B'>-l</emphasis> option below.)</para> <para>Some of the command-line options to <emphasis role='strong' remap='B'>ld</emphasis> may be specified at any point in the command line. However, options which refer to files, such as <emphasis role='strong' remap='B'>-l</emphasis> or <emphasis role='strong' remap='B'>-T</emphasis>, cause the file to be read at the point at which the option appears in the command line, relative to the object files and other file options. Repeating non-file options with a different argument will either have no further effect, or override prior occurrences (those further to the left on the command line) of that option. Options which may be meaningfully specified more than once are noted in the descriptions below.</para> <para>Non-option arguments are object files or archives which are to be linked together. They may follow, precede, or be mixed in with command-line options, except that an object file argument may not be placed between an option and its argument.</para> <para>Usually the linker is invoked with at least one object file, but you can specify other forms of binary input files using <emphasis role='strong' remap='B'>-l</emphasis>, <emphasis role='strong' remap='B'>-R</emphasis>, and the script command language. If <emphasis remap='I'>no</emphasis> binary input files at all are specified, the linker does not produce any output, and issues the message <emphasis role='strong' remap='B'>No input files</emphasis>.</para> <para>If the linker cannot recognize the format of an object file, it will assume that it is a linker script. A script specified in this way augments the main linker script used for the link (either the default linker script or the one specified by using <emphasis role='strong' remap='B'>-T</emphasis>). This feature permits the linker to link against a file which appears to be an object or an archive, but actually merely defines some symbol values, or uses <emphasis remap='CW'>`INPUT'</emphasis> or <emphasis remap='CW'>`GROUP'</emphasis> to load other objects. Note that specifying a script in this way merely augments the main linker script; use the <emphasis role='strong' remap='B'>-T</emphasis> option to replace the default linker script entirely.</para> <para>For options whose names are a single letter, option arguments must either follow the option letter without intervening whitespace, or be given as separate arguments immediately following the option that requires them.</para> <para>For options whose names are multiple letters, either one dash or two can precede the option name; for example, <emphasis role='strong' remap='B'>-trace-symbol</emphasis> and <emphasis role='strong' remap='B'>--trace-symbol</emphasis> are equivalent. Note---there is one exception to this rule. Multiple letter options that start with a lower case 'o' can only be preceded by two dashes. This is to reduce confusion with the <emphasis role='strong' remap='B'>-o</emphasis> option. So for example <emphasis role='strong' remap='B'>-omagic</emphasis> sets the output file name to <emphasis role='strong' remap='B'>magic</emphasis> whereas <emphasis role='strong' remap='B'>--omagic</emphasis> sets the <?troff ps -1?>NMAGIC<?troff ps 0?> flag on the output.</para> <para>Arguments to multiple-letter options must either be separated from the option name by an equals sign, or be given as separate arguments immediately following the option that requires them. For example, <emphasis role='strong' remap='B'>--trace-symbol foo</emphasis> and <emphasis role='strong' remap='B'>--trace-symbol=foo</emphasis> are equivalent. Unique abbreviations of the names of multiple-letter options are accepted.</para> <para>Note---if the linker is being invoked indirectly, via a compiler driver (e.g. <emphasis role='strong' remap='B'>gcc</emphasis>) then all the linker command line options should be prefixed by <emphasis role='strong' remap='B'>-Wl,</emphasis> (or whatever is appropriate for the particular compiler driver) like this:</para> <literallayout remap='Vb'> gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup </literallayout> <!-- remap='Ve' --> <para>This is important, because otherwise the compiler driver program may silently drop the linker options, resulting in a bad link.</para> <para>Here is a table of the generic command line switches accepted by the <?troff ps -1?>GNU<?troff ps 0?> linker:</para> <variablelist remap='IP'> <varlistentry> <term><emphasis role='strong' remap='B'>@</emphasis><emphasis remap='I'>file</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>@file</secondary></indexterm> Read command-line options from <emphasis remap='I'>file</emphasis>. The options read are inserted in place of the original @<emphasis remap='I'>file</emphasis> option. If <emphasis remap='I'>file</emphasis> does not exist, or cannot be read, then the option will be treated literally, and not removed.</para> <para>Options in <emphasis remap='I'>file</emphasis> are separated by whitespace. A whitespace character may be included in an option by surrounding the entire option in either single or double quotes. Any character (including a backslash) may be included by prefixing the character to be included with a backslash. The <emphasis remap='I'>file</emphasis> may itself contain additional @<emphasis remap='I'>file</emphasis> options; any such options will be processed recursively.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-a</emphasis><emphasis remap='I'>keyword</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-akeyword</secondary></indexterm> This option is supported for <?troff ps -1?>HP/UX<?troff ps 0?> compatibility. The <emphasis remap='I'>keyword</emphasis> argument must be one of the strings <emphasis role='strong' remap='B'>archive</emphasis>, <emphasis role='strong' remap='B'>shared</emphasis>, or <emphasis role='strong' remap='B'>default</emphasis>. <emphasis role='strong' remap='B'>-aarchive</emphasis> is functionally equivalent to <emphasis role='strong' remap='B'>-Bstatic</emphasis>, and the other two keywords are functionally equivalent to <emphasis role='strong' remap='B'>-Bdynamic</emphasis>. This option may be used any number of times.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-A</emphasis><emphasis remap='I'>architecture</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Aarchitecture</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--architecture=</emphasis><emphasis remap='I'>architecture</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--architecture=architecture</secondary></indexterm> <!-- PD --> In the current release of <emphasis role='strong' remap='B'>ld</emphasis>, this option is useful only for the Intel 960 family of architectures. In that <emphasis role='strong' remap='B'>ld</emphasis> configuration, the <emphasis remap='I'>architecture</emphasis> argument identifies the particular architecture in the 960 family, enabling some safeguards and modifying the archive-library search path.</para> <para>Future releases of <emphasis role='strong' remap='B'>ld</emphasis> may support similar functionality for other architecture families.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-b</emphasis> <emphasis remap='I'>input-format</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-b input-format</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--format=</emphasis><emphasis remap='I'>input-format</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--format=input-format</secondary></indexterm> <!-- PD --> <emphasis role='strong' remap='B'>ld</emphasis> may be configured to support more than one kind of object file. If your <emphasis role='strong' remap='B'>ld</emphasis> is configured this way, you can use the <emphasis role='strong' remap='B'>-b</emphasis> option to specify the binary format for input object files that follow this option on the command line. Even when <emphasis role='strong' remap='B'>ld</emphasis> is configured to support alternative object formats, you don't usually need to specify this, as <emphasis role='strong' remap='B'>ld</emphasis> should be configured to expect as a default input format the most usual format on each machine. <emphasis remap='I'>input-format</emphasis> is a text string, the name of a particular format supported by the <?troff ps -1?>BFD<?troff ps 0?> libraries. (You can list the available binary formats with <emphasis role='strong' remap='B'>objdump -i</emphasis>.)</para> <para>You may want to use this option if you are linking files with an unusual binary format. You can also use <emphasis role='strong' remap='B'>-b</emphasis> to switch formats explicitly (when linking object files of different formats), by including <emphasis role='strong' remap='B'>-b</emphasis> <emphasis remap='I'>input-format</emphasis> before each group of object files in a particular format.</para> <para>The default format is taken from the environment variable <emphasis remap='CW'>`GNUTARGET'</emphasis>.</para> <para>You can also define the input format from a script, using the command <emphasis remap='CW'>`TARGET'</emphasis>;</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-c</emphasis> <emphasis remap='I'>MRI-commandfile</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-c MRI-commandfile</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--mri-script=</emphasis><emphasis remap='I'>MRI-commandfile</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--mri-script=MRI-commandfile</secondary></indexterm> <!-- PD --> For compatibility with linkers produced by <?troff ps -1?>MRI<?troff ps 0?>, <emphasis role='strong' remap='B'>ld</emphasis> accepts script files written in an alternate, restricted command language, described in the <?troff ps -1?>MRI<?troff ps 0?> Compatible Script Files section of <?troff ps -1?>GNU<?troff ps 0?> ld documentation. Introduce <?troff ps -1?>MRI<?troff ps 0?> script files with the option <emphasis role='strong' remap='B'>-c</emphasis>; use the <emphasis role='strong' remap='B'>-T</emphasis> option to run linker scripts written in the general-purpose <emphasis role='strong' remap='B'>ld</emphasis> scripting language. If <emphasis remap='I'>MRI-cmdfile</emphasis> does not exist, <emphasis role='strong' remap='B'>ld</emphasis> looks for it in the directories specified by any <emphasis role='strong' remap='B'>-L</emphasis> options.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-d</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-d</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-dc</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-dc</secondary></indexterm></para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-dp</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-dp</secondary></indexterm> <!-- PD --> These three options are equivalent; multiple forms are supported for compatibility with other linkers. They assign space to common symbols even if a relocatable output file is specified (with <emphasis role='strong' remap='B'>-r</emphasis>). The script command <emphasis remap='CW'>`FORCE_COMMON_ALLOCATION'</emphasis> has the same effect.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-e</emphasis> <emphasis remap='I'>entry</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-e entry</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--entry=</emphasis><emphasis remap='I'>entry</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--entry=entry</secondary></indexterm> <!-- PD --> Use <emphasis remap='I'>entry</emphasis> as the explicit symbol for beginning execution of your program, rather than the default entry point. If there is no symbol named <emphasis remap='I'>entry</emphasis>, the linker will try to parse <emphasis remap='I'>entry</emphasis> as a number, and use that as the entry address (the number will be interpreted in base 10; you may use a leading <emphasis role='strong' remap='B'>0x</emphasis> for base 16, or a leading <emphasis role='strong' remap='B'>0</emphasis> for base 8).</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--exclude-libs</emphasis> <emphasis remap='I'>lib</emphasis><emphasis role='strong' remap='B'>,</emphasis><emphasis remap='I'>lib</emphasis><emphasis role='strong' remap='B'>,...</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--exclude-libs lib,lib,...</secondary></indexterm> Specifies a list of archive libraries from which symbols should not be automatically exported. The library names may be delimited by commas or colons. Specifying <emphasis remap='CW'>`--exclude-libs ALL'</emphasis> excludes symbols in all archive libraries from automatic export. This option is available only for the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker and for <?troff ps -1?>ELF<?troff ps 0?> targeted ports. For i386 <?troff ps -1?>PE<?troff ps 0?>, symbols explicitly listed in a .def file are still exported, regardless of this option. For <?troff ps -1?>ELF<?troff ps 0?> targeted ports, symbols affected by this option will be treated as hidden.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-E</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-E</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--export-dynamic</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--export-dynamic</secondary></indexterm> <!-- PD --> When creating a dynamically linked executable, add all symbols to the dynamic symbol table. The dynamic symbol table is the set of symbols which are visible from dynamic objects at run time.</para> <para>If you do not use this option, the dynamic symbol table will normally contain only those symbols which are referenced by some dynamic object mentioned in the link.</para> <para>If you use <emphasis remap='CW'>`dlopen'</emphasis> to load a dynamic object which needs to refer back to the symbols defined by the program, rather than some other dynamic object, then you will probably need to use this option when linking the program itself.</para> <para>You can also use the dynamic list to control what symbols should be added to the dynamic symbol table if the output format supports it. See the description of <emphasis role='strong' remap='B'>--dynamic-list</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-EB</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-EB</secondary></indexterm> Link big-endian objects. This affects the default output format.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-EL</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-EL</secondary></indexterm> Link little-endian objects. This affects the default output format.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-f</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-f</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--auxiliary</emphasis> <emphasis remap='I'>name</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--auxiliary name</secondary></indexterm> <!-- PD --> When creating an <?troff ps -1?>ELF<?troff ps 0?> shared object, set the internal <?troff ps -1?>DT_AUXILIARY<?troff ps 0?> field to the specified name. This tells the dynamic linker that the symbol table of the shared object should be used as an auxiliary filter on the symbol table of the shared object <emphasis remap='I'>name</emphasis>.</para> <para>If you later link a program against this filter object, then, when you run the program, the dynamic linker will see the <?troff ps -1?>DT_AUXILIARY<?troff ps 0?> field. If the dynamic linker resolves any symbols from the filter object, it will first check whether there is a definition in the shared object <emphasis remap='I'>name</emphasis>. If there is one, it will be used instead of the definition in the filter object. The shared object <emphasis remap='I'>name</emphasis> need not exist. Thus the shared object <emphasis remap='I'>name</emphasis> may be used to provide an alternative implementation of certain functions, perhaps for debugging or for machine specific performance.</para> <para>This option may be specified more than once. The <?troff ps -1?>DT_AUXILIARY<?troff ps 0?> entries will be created in the order in which they appear on the command line.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-F</emphasis> <emphasis remap='I'>name</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-F name</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--filter</emphasis> <emphasis remap='I'>name</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--filter name</secondary></indexterm> <!-- PD --> When creating an <?troff ps -1?>ELF<?troff ps 0?> shared object, set the internal <?troff ps -1?>DT_FILTER<?troff ps 0?> field to the specified name. This tells the dynamic linker that the symbol table of the shared object which is being created should be used as a filter on the symbol table of the shared object <emphasis remap='I'>name</emphasis>.</para> <para>If you later link a program against this filter object, then, when you run the program, the dynamic linker will see the <?troff ps -1?>DT_FILTER<?troff ps 0?> field. The dynamic linker will resolve symbols according to the symbol table of the filter object as usual, but it will actually link to the definitions found in the shared object <emphasis remap='I'>name</emphasis>. Thus the filter object can be used to select a subset of the symbols provided by the object <emphasis remap='I'>name</emphasis>.</para> <para>Some older linkers used the <emphasis role='strong' remap='B'>-F</emphasis> option throughout a compilation toolchain for specifying object-file format for both input and output object files. The <?troff ps -1?>GNU<?troff ps 0?> linker uses other mechanisms for this purpose: the <emphasis role='strong' remap='B'>-b</emphasis>, <emphasis role='strong' remap='B'>--format</emphasis>, <emphasis role='strong' remap='B'>--oformat</emphasis> options, the <emphasis remap='CW'>`TARGET'</emphasis> command in linker scripts, and the <emphasis remap='CW'>`GNUTARGET'</emphasis> environment variable. The <?troff ps -1?>GNU<?troff ps 0?> linker will ignore the <emphasis role='strong' remap='B'>-F</emphasis> option when not creating an <?troff ps -1?>ELF<?troff ps 0?> shared object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-fini</emphasis> <emphasis remap='I'>name</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-fini name</secondary></indexterm> When creating an <?troff ps -1?>ELF<?troff ps 0?> executable or shared object, call <?troff ps -1?>NAME<?troff ps 0?> when the executable or shared object is unloaded, by setting <?troff ps -1?>DT_FINI<?troff ps 0?> to the address of the function. By default, the linker uses <emphasis remap='CW'>`_fini'</emphasis> as the function to call.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-g</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-g</secondary></indexterm> Ignored. Provided for compatibility with other tools.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-G</emphasis><emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Gvalue</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--gpsize=</emphasis><emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--gpsize=value</secondary></indexterm> <!-- PD --> Set the maximum size of objects to be optimized using the <?troff ps -1?>GP<?troff ps 0?> register to <emphasis remap='I'>size</emphasis>. This is only meaningful for object file formats such as <?troff ps -1?>MIPS<?troff ps 0?> <?troff ps -1?>ECOFF<?troff ps 0?> which supports putting large and small objects into different sections. This is ignored for other object file formats.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-h</emphasis><emphasis remap='I'>name</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-hname</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-soname=</emphasis><emphasis remap='I'>name</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-soname=name</secondary></indexterm> <!-- PD --> When creating an <?troff ps -1?>ELF<?troff ps 0?> shared object, set the internal <?troff ps -1?>DT_SONAME<?troff ps 0?> field to the specified name. When an executable is linked with a shared object which has a <?troff ps -1?>DT_SONAME<?troff ps 0?> field, then when the executable is run the dynamic linker will attempt to load the shared object specified by the <?troff ps -1?>DT_SONAME<?troff ps 0?> field rather than the using the file name given to the linker.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-i</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-i</secondary></indexterm> Perform an incremental link (same as option <emphasis role='strong' remap='B'>-r</emphasis>).</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-init</emphasis> <emphasis remap='I'>name</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-init name</secondary></indexterm> When creating an <?troff ps -1?>ELF<?troff ps 0?> executable or shared object, call <?troff ps -1?>NAME<?troff ps 0?> when the executable or shared object is loaded, by setting <?troff ps -1?>DT_INIT<?troff ps 0?> to the address of the function. By default, the linker uses <emphasis remap='CW'>`_init'</emphasis> as the function to call.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-l</emphasis><emphasis remap='I'>namespec</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-lnamespec</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--library=</emphasis><emphasis remap='I'>namespec</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--library=namespec</secondary></indexterm> <!-- PD --> Add the archive or object file specified by <emphasis remap='I'>namespec</emphasis> to the list of files to link. This option may be used any number of times. If <emphasis remap='I'>namespec</emphasis> is of the form <emphasis remap='I'>:filename</emphasis>, <emphasis role='strong' remap='B'>ld</emphasis> will search the library path for a file called <emphasis remap='I'>filename</emphasis>, otherise it will search the library path for a file called <emphasis remap='I'>libnamespec.a</emphasis>.</para> <para>On systems which support shared libraries, <emphasis role='strong' remap='B'>ld</emphasis> may also search for files other than <emphasis remap='I'>libnamespec.a</emphasis>. Specifically, on <?troff ps -1?>ELF<?troff ps 0?> and SunOS systems, <emphasis role='strong' remap='B'>ld</emphasis> will search a directory for a library called <emphasis remap='I'>libnamespec.so</emphasis> before searching for one called <emphasis remap='I'>libnamespec.a</emphasis>. (By convention, a <emphasis remap='CW'>`.so'</emphasis> extension indicates a shared library.) Note that this behavior does not apply to <emphasis remap='I'>:filename</emphasis>, which always specifies a file called <emphasis remap='I'>filename</emphasis>.</para> <para>The linker will search an archive only once, at the location where it is specified on the command line. If the archive defines a symbol which was undefined in some object which appeared before the archive on the command line, the linker will include the appropriate file(s) from the archive. However, an undefined symbol in an object appearing later on the command line will not cause the linker to search the archive again.</para> <para>See the <emphasis role='strong' remap='B'>-(</emphasis> option for a way to force the linker to search archives multiple times.</para> <para>You may list the same archive multiple times on the command line.</para> <para>This type of archive searching is standard for Unix linkers. However, if you are using <emphasis role='strong' remap='B'>ld</emphasis> on <?troff ps -1?>AIX<?troff ps 0?>, note that it is different from the behaviour of the <?troff ps -1?>AIX<?troff ps 0?> linker.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-L</emphasis><emphasis remap='I'>searchdir</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Lsearchdir</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--library-path=</emphasis><emphasis remap='I'>searchdir</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--library-path=searchdir</secondary></indexterm> <!-- PD --> Add path <emphasis remap='I'>searchdir</emphasis> to the list of paths that <emphasis role='strong' remap='B'>ld</emphasis> will search for archive libraries and <emphasis role='strong' remap='B'>ld</emphasis> control scripts. You may use this option any number of times. The directories are searched in the order in which they are specified on the command line. Directories specified on the command line are searched before the default directories. All <emphasis role='strong' remap='B'>-L</emphasis> options apply to all <emphasis role='strong' remap='B'>-l</emphasis> options, regardless of the order in which the options appear.</para> <para>If <emphasis remap='I'>searchdir</emphasis> begins with <emphasis remap='CW'>`='</emphasis>, then the <emphasis remap='CW'>`='</emphasis> will be replaced by the <emphasis remap='I'>sysroot prefix</emphasis>, a path specified when the linker is configured.</para> <para>The default set of paths searched (without being specified with <emphasis role='strong' remap='B'>-L</emphasis>) depends on which emulation mode <emphasis role='strong' remap='B'>ld</emphasis> is using, and in some cases also on how it was configured.</para> <para>The paths can also be specified in a link script with the <emphasis remap='CW'>`SEARCH_DIR'</emphasis> command. Directories specified this way are searched at the point in which the linker script appears in the command line.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-m</emphasis><emphasis remap='I'>emulation</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-memulation</secondary></indexterm> Emulate the <emphasis remap='I'>emulation</emphasis> linker. You can list the available emulations with the <emphasis role='strong' remap='B'>--verbose</emphasis> or <emphasis role='strong' remap='B'>-V</emphasis> options.</para> <para>If the <emphasis role='strong' remap='B'>-m</emphasis> option is not used, the emulation is taken from the <emphasis remap='CW'>`LDEMULATION'</emphasis> environment variable, if that is defined.</para> <para>Otherwise, the default emulation depends upon how the linker was configured.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-M</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-M</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--print-map</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--print-map</secondary></indexterm> <!-- PD --> Print a link map to the standard output. A link map provides information about the link, including the following:</para> <itemizedlist remap='IP+bullet'> <listitem override='bullet'> <para>Where object files are mapped into memory.</para> </listitem> <listitem override='bullet'> <para>How common symbols are allocated.</para> </listitem> <listitem override='bullet'> <para>All archive members included in the link, with a mention of the symbol which caused the archive member to be brought in.</para> </listitem> <listitem override='bullet'> <para>The values assigned to symbols.</para> <para>Note - symbols whose values are computed by an expression which involves a reference to a previous value of the same symbol may not have correct result displayed in the link map. This is because the linker discards intermediate results and only retains the final value of an expression. Under such circumstances the linker will display the final value enclosed by square brackets. Thus for example a linker script containing:</para> <literallayout remap='Vb'> foo = 1 foo = foo * 4 foo = foo + 8 </literallayout> <!-- remap='Ve' --> <para>will produce the following output in the link map if the <emphasis role='strong' remap='B'>-M</emphasis> option is used:</para> <literallayout remap='Vb'> <funcsynopsis> <funcsynopsisinfo> 0x00000001 foo = 0x1 [0x0000000c] foo = (foo * 0x4) [0x0000000c] foo = (foo + 0x8) </funcsynopsisinfo> </funcsynopsis> </literallayout> <!-- remap='Ve' --> <para>See <emphasis role='strong' remap='B'>Expressions</emphasis> for more information about expressions in linker scripts.</para> </listitem> </itemizedlist> <!-- .RS 4 .RE --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-n</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-n</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--nmagic</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--nmagic</secondary></indexterm> <!-- PD --> Turn off page alignment of sections, and mark the output as <emphasis remap='CW'>`NMAGIC'</emphasis> if possible.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-N</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-N</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--omagic</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--omagic</secondary></indexterm> <!-- PD --> Set the text and data sections to be readable and writable. Also, do not page-align the data segment, and disable linking against shared libraries. If the output format supports Unix style magic numbers, mark the output as <emphasis remap='CW'>`OMAGIC'</emphasis>. Note: Although a writable text section is allowed for PE-COFF targets, it does not conform to the format specification published by Microsoft.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-omagic</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-omagic</secondary></indexterm> This option negates most of the effects of the <emphasis role='strong' remap='B'>-N</emphasis> option. It sets the text section to be read-only, and forces the data segment to be page-aligned. Note - this option does not enable linking against shared libraries. Use <emphasis role='strong' remap='B'>-Bdynamic</emphasis> for this.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-o</emphasis> <emphasis remap='I'>output</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-o output</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--output=</emphasis><emphasis remap='I'>output</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--output=output</secondary></indexterm> <!-- PD --> Use <emphasis remap='I'>output</emphasis> as the name for the program produced by <emphasis role='strong' remap='B'>ld</emphasis>; if this option is not specified, the name <emphasis remap='I'>a.out</emphasis> is used by default. The script command <emphasis remap='CW'>`OUTPUT'</emphasis> can also specify the output file name.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-O</emphasis> <emphasis remap='I'>level</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-O level</secondary></indexterm> If <emphasis remap='I'>level</emphasis> is a numeric values greater than zero <emphasis role='strong' remap='B'>ld</emphasis> optimizes the output. This might take significantly longer and therefore probably should only be enabled for the final binary.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-q</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-q</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--emit-relocs</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--emit-relocs</secondary></indexterm> <!-- PD --> Leave relocation sections and contents in fully linked executables. Post link analysis and optimization tools may need this information in order to perform correct modifications of executables. This results in larger executables.</para> <para>This option is currently only supported on <?troff ps -1?>ELF<?troff ps 0?> platforms.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--force-dynamic</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--force-dynamic</secondary></indexterm> Force the output file to have dynamic sections. This option is specific to VxWorks targets.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-r</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-r</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--relocatable</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--relocatable</secondary></indexterm> <!-- PD --> Generate relocatable output---i.e., generate an output file that can in turn serve as input to <emphasis role='strong' remap='B'>ld</emphasis>. This is often called <emphasis remap='I'>partial linking</emphasis>. As a side effect, in environments that support standard Unix magic numbers, this option also sets the output file's magic number to <emphasis remap='CW'>`OMAGIC'</emphasis>. If this option is not specified, an absolute file is produced. When linking C++; programs, this file <option>will not</option> resolve references to constructors; to do that, use <emphasis role='strong' remap='B'>-Ur</emphasis>.</para> <para>When an input file does not have the same format as the output file, partial linking is only supported if that input file does not contain any relocations. Different output formats can have further restrictions; for example some <emphasis remap='CW'>`a.out'</emphasis>-based formats do not support partial linking with input files in other formats at all.</para> <para>This option does the same thing as <emphasis role='strong' remap='B'>-i</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-R</emphasis> <emphasis remap='I'>filename</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-R filename</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--just-symbols=</emphasis><emphasis remap='I'>filename</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--just-symbols=filename</secondary></indexterm> <!-- PD --> Read symbol names and their addresses from <emphasis remap='I'>filename</emphasis>, but do not relocate it or include it in the output. This allows your output file to refer symbolically to absolute locations of memory defined in other programs. You may use this option more than once.</para> <para>For compatibility with other <?troff ps -1?>ELF<?troff ps 0?> linkers, if the <emphasis role='strong' remap='B'>-R</emphasis> option is followed by a directory name, rather than a file name, it is treated as the <emphasis role='strong' remap='B'>-rpath</emphasis> option.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-s</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-s</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--strip-all</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--strip-all</secondary></indexterm> <!-- PD --> Omit all symbol information from the output file.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-S</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-S</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--strip-debug</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--strip-debug</secondary></indexterm> <!-- PD --> Omit debugger symbol information (but not all symbols) from the output file.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-t</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-t</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--trace</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--trace</secondary></indexterm> <!-- PD --> Print the names of the input files as <emphasis role='strong' remap='B'>ld</emphasis> processes them.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-T</emphasis> <emphasis remap='I'>scriptfile</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-T scriptfile</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--script=</emphasis><emphasis remap='I'>scriptfile</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--script=scriptfile</secondary></indexterm> <!-- PD --> Use <emphasis remap='I'>scriptfile</emphasis> as the linker script. This script replaces <emphasis role='strong' remap='B'>ld</emphasis>'s default linker script (rather than adding to it), so <emphasis remap='I'>commandfile</emphasis> must specify everything necessary to describe the output file. If <emphasis remap='I'>scriptfile</emphasis> does not exist in the current directory, <emphasis remap='CW'>`ld'</emphasis> looks for it in the directories specified by any preceding <emphasis role='strong' remap='B'>-L</emphasis> options. Multiple <emphasis role='strong' remap='B'>-T</emphasis> options accumulate.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-dT</emphasis> <emphasis remap='I'>scriptfile</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-dT scriptfile</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--default-script=</emphasis><emphasis remap='I'>scriptfile</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--default-script=scriptfile</secondary></indexterm> <!-- PD --> Use <emphasis remap='I'>scriptfile</emphasis> as the default linker script.</para> <para>This option is similar to the <emphasis role='strong' remap='B'>--script</emphasis> option except that processing of the script is delayed until after the rest of the command line has been processed. This allows options placed after the <emphasis role='strong' remap='B'>--default-script</emphasis> option on the command line to affect the behaviour of the linker script, which can be important when the linker command line cannot be directly controlled by the user. (eg because the command line is being constructed by another tool, such as <emphasis role='strong' remap='B'>gcc</emphasis>).</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-u</emphasis> <emphasis remap='I'>symbol</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-u symbol</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--undefined=</emphasis><emphasis remap='I'>symbol</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--undefined=symbol</secondary></indexterm> <!-- PD --> Force <emphasis remap='I'>symbol</emphasis> to be entered in the output file as an undefined symbol. Doing this may, for example, trigger linking of additional modules from standard libraries. <emphasis role='strong' remap='B'>-u</emphasis> may be repeated with different option arguments to enter additional undefined symbols. This option is equivalent to the <emphasis remap='CW'>`EXTERN'</emphasis> linker script command.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Ur</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Ur</secondary></indexterm> For anything other than C++; programs, this option is equivalent to <emphasis role='strong' remap='B'>-r</emphasis>: it generates relocatable output---i.e., an output file that can in turn serve as input to <emphasis role='strong' remap='B'>ld</emphasis>. When linking C++; programs, <emphasis role='strong' remap='B'>-Ur</emphasis> <emphasis remap='I'>does</emphasis> resolve references to constructors, unlike <emphasis role='strong' remap='B'>-r</emphasis>. It does not work to use <emphasis role='strong' remap='B'>-Ur</emphasis> on files that were themselves linked with <emphasis role='strong' remap='B'>-Ur</emphasis>; once the constructor table has been built, it cannot be added to. Use <emphasis role='strong' remap='B'>-Ur</emphasis> only for the last partial link, and <emphasis role='strong' remap='B'>-r</emphasis> for the others.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--unique[=</emphasis><emphasis remap='I'><?troff ps -1?>SECTION<?troff ps 0?></emphasis><emphasis role='strong' remap='B'>]</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--unique[=SECTION]</secondary></indexterm> Creates a separate output section for every input section matching <emphasis remap='I'><?troff ps -1?>SECTION<?troff ps 0?></emphasis>, or if the optional wildcard <emphasis remap='I'><?troff ps -1?>SECTION<?troff ps 0?></emphasis> argument is missing, for every orphan input section. An orphan section is one not specifically mentioned in a linker script. You may use this option multiple times on the command line; It prevents the normal merging of input sections with the same name, overriding output section assignments in a linker script.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-v</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-v</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--version</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--version</secondary></indexterm></para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-V</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-V</secondary></indexterm> <!-- PD --> Display the version number for <emphasis role='strong' remap='B'>ld</emphasis>. The <emphasis role='strong' remap='B'>-V</emphasis> option also lists the supported emulations.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-x</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-x</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--discard-all</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--discard-all</secondary></indexterm> <!-- PD --> Delete all local symbols.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-X</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-X</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--discard-locals</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--discard-locals</secondary></indexterm> <!-- PD --> Delete all temporary local symbols. (These symbols start with system-specific local label prefixes, typically <emphasis role='strong' remap='B'>.L</emphasis> for <?troff ps -1?>ELF<?troff ps 0?> systems or <emphasis role='strong' remap='B'>L</emphasis> for traditional a.out systems.)</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-y</emphasis> <emphasis remap='I'>symbol</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-y symbol</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--trace-symbol=</emphasis><emphasis remap='I'>symbol</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--trace-symbol=symbol</secondary></indexterm> <!-- PD --> Print the name of each linked file in which <emphasis remap='I'>symbol</emphasis> appears. This option may be given any number of times. On many systems it is necessary to prepend an underscore.</para> <para>This option is useful when you have an undefined symbol in your link but don't know where the reference is coming from.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Y</emphasis> <emphasis remap='I'>path</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Y path</secondary></indexterm> Add <emphasis remap='I'>path</emphasis> to the default library search path. This option exists for Solaris compatibility.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-z</emphasis> <emphasis remap='I'>keyword</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-z keyword</secondary></indexterm> The recognized keywords are:</para> <variablelist remap='IP'> <varlistentry> <term><emphasis role='strong' remap='B'>combreloc</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>combreloc</secondary></indexterm> Combines multiple reloc sections and sorts them to make dynamic symbol lookup caching possible.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>defs</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>defs</secondary></indexterm> Disallows undefined symbols in object files. Undefined symbols in shared libraries are still allowed.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>execstack</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>execstack</secondary></indexterm> Marks the object as requiring executable stack.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>initfirst</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>initfirst</secondary></indexterm> This option is only meaningful when building a shared object. It marks the object so that its runtime initialization will occur before the runtime initialization of any other objects brought into the process at the same time. Similarly the runtime finalization of the object will occur after the runtime finalization of any other objects.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>interpose</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>interpose</secondary></indexterm> Marks the object that its symbol table interposes before all symbols but the primary executable.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>lazy</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>lazy</secondary></indexterm> When generating an executable or shared library, mark it to tell the dynamic linker to defer function call resolution to the point when the function is called (lazy binding), rather than at load time. Lazy binding is the default.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>loadfltr</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>loadfltr</secondary></indexterm> Marks the object that its filters be processed immediately at runtime.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>muldefs</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>muldefs</secondary></indexterm> Allows multiple definitions.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>nocombreloc</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>nocombreloc</secondary></indexterm> Disables multiple reloc sections combining.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>nocopyreloc</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>nocopyreloc</secondary></indexterm> Disables production of copy relocs.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>nodefaultlib</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>nodefaultlib</secondary></indexterm> Marks the object that the search for dependencies of this object will ignore any default library search paths.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>nodelete</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>nodelete</secondary></indexterm> Marks the object shouldn't be unloaded at runtime.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>nodlopen</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>nodlopen</secondary></indexterm> Marks the object not available to <emphasis remap='CW'>`dlopen'</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>nodump</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>nodump</secondary></indexterm> Marks the object can not be dumped by <emphasis remap='CW'>`dldump'</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>noexecstack</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>noexecstack</secondary></indexterm> Marks the object as not requiring executable stack.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>norelro</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>norelro</secondary></indexterm> Don't create an <?troff ps -1?>ELF<?troff ps 0?> <emphasis remap='CW'>`PT_GNU_RELRO'</emphasis> segment header in the object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>now</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>now</secondary></indexterm> When generating an executable or shared library, mark it to tell the dynamic linker to resolve all symbols when the program is started, or when the shared library is linked to using dlopen, instead of deferring function call resolution to the point when the function is first called.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>origin</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>origin</secondary></indexterm> Marks the object may contain <emphasis remap='CW'>$ORIGIN</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>relro</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>relro</secondary></indexterm> Create an <?troff ps -1?>ELF<?troff ps 0?> <emphasis remap='CW'>`PT_GNU_RELRO'</emphasis> segment header in the object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>max-page-size=</emphasis><emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>max-page-size=value</secondary></indexterm> Set the emulation maximum page size to <emphasis remap='I'>value</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>common-page-size=</emphasis><emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>common-page-size=value</secondary></indexterm> Set the emulation common page size to <emphasis remap='I'>value</emphasis>.</para> </listitem> </varlistentry> </variablelist> <blockquote remap='RS'> <para>Other keywords are ignored for Solaris compatibility. </para></blockquote> <!-- remap='RE' --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-(</emphasis> <emphasis remap='I'>archives</emphasis> <emphasis role='strong' remap='B'>-)</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-( archives -)</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--start-group</emphasis> <emphasis remap='I'>archives</emphasis> <emphasis role='strong' remap='B'>--end-group</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--start-group archives --end-group</secondary></indexterm> <!-- PD --> The <emphasis remap='I'>archives</emphasis> should be a list of archive files. They may be either explicit file names, or <emphasis role='strong' remap='B'>-l</emphasis> options.</para> <para>The specified archives are searched repeatedly until no new undefined references are created. Normally, an archive is searched only once in the order that it is specified on the command line. If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference. By grouping the archives, they all be searched repeatedly until all possible references are resolved.</para> <para>Using this option has a significant performance cost. It is best to use it only when there are unavoidable circular references between two or more archives.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--accept-unknown-input-arch</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--accept-unknown-input-arch</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-accept-unknown-input-arch</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-accept-unknown-input-arch</secondary></indexterm> <!-- PD --> Tells the linker to accept input files whose architecture cannot be recognised. The assumption is that the user knows what they are doing and deliberately wants to link in these unknown input files. This was the default behaviour of the linker, before release 2.14. The default behaviour from release 2.14 onwards is to reject such input files, and so the <emphasis role='strong' remap='B'>--accept-unknown-input-arch</emphasis> option has been added to restore the old behaviour.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--add-needed</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--add-needed</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-add-needed</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-add-needed</secondary></indexterm> <!-- PD --> This option affects the treatment of dynamic libraries from <?troff ps -1?>ELF<?troff ps 0?> <?troff ps -1?>DT_NEEDED<?troff ps 0?> tags in dynamic libraries mentioned on the command line after the <emphasis role='strong' remap='B'>--add-needed</emphasis> option. Normally, the linker will not copy a <?troff ps -1?>DT_NEEDED<?troff ps 0?> tags from each dynamic library to the produced output object. <emphasis role='strong' remap='B'>--add-needed</emphasis> makes linker to copy <?troff ps -1?>DT_NEEDED<?troff ps 0?> tags from all dynamic libraries mentioned after this flag. <emphasis role='strong' remap='B'>--no-add-needed</emphasis> restores the default behaviour.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--as-needed</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--as-needed</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-as-needed</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-as-needed</secondary></indexterm> <!-- PD --> This option affects <?troff ps -1?>ELF<?troff ps 0?> <?troff ps -1?>DT_NEEDED<?troff ps 0?> tags for dynamic libraries mentioned on the command line after the <emphasis role='strong' remap='B'>--as-needed</emphasis> option when <emphasis role='strong' remap='B'>--add-needed</emphasis> is in effect. In such a case <emphasis role='strong' remap='B'>--as-needed</emphasis> causes <?troff ps -1?>DT_NEEDED<?troff ps 0?> tags to only be emitted for libraries that satisfy some symbol reference from regular objects which is undefined at the point that the library was linked. <emphasis role='strong' remap='B'>--no-as-needed</emphasis> restores the default behaviour.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-assert</emphasis> <emphasis remap='I'>keyword</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-assert keyword</secondary></indexterm> This option is ignored for SunOS compatibility.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Bdynamic</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Bdynamic</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-dy</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-dy</secondary></indexterm></para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-call_shared</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-call_shared</secondary></indexterm> <!-- PD --> Link against dynamic libraries. This is only meaningful on platforms for which shared libraries are supported. This option is normally the default on such platforms. The different variants of this option are for compatibility with various systems. You may use this option multiple times on the command line: it affects library searching for <emphasis role='strong' remap='B'>-l</emphasis> options which follow it.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Bgroup</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Bgroup</secondary></indexterm> Set the <emphasis remap='CW'>`DF_1_GROUP'</emphasis> flag in the <emphasis remap='CW'>`DT_FLAGS_1'</emphasis> entry in the dynamic section. This causes the runtime linker to handle lookups in this object and its dependencies to be performed only inside the group. <emphasis role='strong' remap='B'>--unresolved-symbols=report-all</emphasis> is implied. This option is only meaningful on <?troff ps -1?>ELF<?troff ps 0?> platforms which support shared libraries.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Bstatic</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Bstatic</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-dn</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-dn</secondary></indexterm></para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-non_shared</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-non_shared</secondary></indexterm></para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-static</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-static</secondary></indexterm> <!-- PD --> Do not link against shared libraries. This is only meaningful on platforms for which shared libraries are supported. The different variants of this option are for compatibility with various systems. You may use this option multiple times on the command line: it affects library searching for <emphasis role='strong' remap='B'>-l</emphasis> options which follow it. This option also implies <emphasis role='strong' remap='B'>--unresolved-symbols=report-all</emphasis>. This option can be used with <emphasis role='strong' remap='B'>-shared</emphasis>. Doing so means that a shared library is being created but that all of the library's external references must be resolved by pulling in entries from static libraries.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Bsymbolic</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Bsymbolic</secondary></indexterm> When creating a shared library, bind references to global symbols to the definition within the shared library, if any. Normally, it is possible for a program linked against a shared library to override the definition within the shared library. This option is only meaningful on <?troff ps -1?>ELF<?troff ps 0?> platforms which support shared libraries.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Bsymbolic-functions</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Bsymbolic-functions</secondary></indexterm> When creating a shared library, bind references to global function symbols to the definition within the shared library, if any. This option is only meaningful on <?troff ps -1?>ELF<?troff ps 0?> platforms which support shared libraries.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--dynamic-list=</emphasis><emphasis remap='I'>dynamic-list-file</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--dynamic-list=dynamic-list-file</secondary></indexterm> Specify the name of a dynamic list file to the linker. This is typically used when creating shared libraries to specify a list of global symbols whose references shouldn't be bound to the definition within the shared library, or creating dynamically linked executables to specify a list of symbols which should be added to the symbol table in the executable. This option is only meaningful on <?troff ps -1?>ELF<?troff ps 0?> platforms which support shared libraries.</para> <para>The format of the dynamic list is the same as the version node without scope and node name. See <emphasis role='strong' remap='B'><?troff ps -1?>VERSION<?troff ps 0?></emphasis> for more information.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--dynamic-list-data</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--dynamic-list-data</secondary></indexterm> Include all global data symbols to the dynamic list.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--dynamic-list-cpp-new</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--dynamic-list-cpp-new</secondary></indexterm> Provide the builtin dynamic list for C++; operator new and delete. It is mainly useful for building shared libstdc++.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--dynamic-list-cpp-typeinfo</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--dynamic-list-cpp-typeinfo</secondary></indexterm> Provide the builtin dynamic list for C++; runtime type identification.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--check-sections</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--check-sections</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-check-sections</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-check-sections</secondary></indexterm> <!-- PD --> Asks the linker <emphasis remap='I'>not</emphasis> to check section addresses after they have been assigned to see if there are any overlaps. Normally the linker will perform this check, and if it finds any overlaps it will produce suitable error messages. The linker does know about, and does make allowances for sections in overlays. The default behaviour can be restored by using the command line switch <emphasis role='strong' remap='B'>--check-sections</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--cref</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--cref</secondary></indexterm> Output a cross reference table. If a linker map file is being generated, the cross reference table is printed to the map file. Otherwise, it is printed on the standard output.</para> <para>The format of the table is intentionally simple, so that it may be easily processed by a script if necessary. The symbols are printed out, sorted by name. For each symbol, a list of file names is given. If the symbol is defined, the first file listed is the location of the definition. The remaining files contain references to the symbol.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-define-common</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-define-common</secondary></indexterm> This option inhibits the assignment of addresses to common symbols. The script command <emphasis remap='CW'>`INHIBIT_COMMON_ALLOCATION'</emphasis> has the same effect.</para> <para>The <emphasis role='strong' remap='B'>--no-define-common</emphasis> option allows decoupling the decision to assign addresses to Common symbols from the choice of the output file type; otherwise a non-Relocatable output type forces assigning addresses to Common symbols. Using <emphasis role='strong' remap='B'>--no-define-common</emphasis> allows Common symbols that are referenced from a shared library to be assigned addresses only in the main program. This eliminates the unused duplicate space in the shared library, and also prevents any possible confusion over resolving to the wrong duplicate when there are many dynamic modules with specialized search paths for runtime symbol resolution.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--defsym</emphasis> <emphasis remap='I'>symbol</emphasis><emphasis role='strong' remap='B'>=</emphasis><emphasis remap='I'>expression</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--defsym symbol=expression</secondary></indexterm> Create a global symbol in the output file, containing the absolute address given by <emphasis remap='I'>expression</emphasis>. You may use this option as many times as necessary to define multiple symbols in the command line. A limited form of arithmetic is supported for the <emphasis remap='I'>expression</emphasis> in this context: you may give a hexadecimal constant or the name of an existing symbol, or use <emphasis remap='CW'>`+'</emphasis> and <emphasis remap='CW'>`-'</emphasis> to add or subtract hexadecimal constants or symbols. If you need more elaborate expressions, consider using the linker command language from a script. <emphasis remap='I'>Note:</emphasis> there should be no white space between <emphasis remap='I'>symbol</emphasis>, the equals sign ("<emphasis role='strong' remap='B'>=</emphasis>"), and <emphasis remap='I'>expression</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--demangle[=</emphasis><emphasis remap='I'>style</emphasis><emphasis role='strong' remap='B'>]</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--demangle[=style]</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-demangle</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-demangle</secondary></indexterm> <!-- PD --> These options control whether to demangle symbol names in error messages and other output. When the linker is told to demangle, it tries to present symbol names in a readable fashion: it strips leading underscores if they are used by the object file format, and converts C++; mangled symbol names into user readable names. Different compilers have different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler. The linker will demangle by default unless the environment variable <emphasis role='strong' remap='B'><?troff ps -1?>COLLECT_NO_DEMANGLE<?troff ps 0?></emphasis> is set. These options may be used to override the default.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--dynamic-linker</emphasis> <emphasis remap='I'>file</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--dynamic-linker file</secondary></indexterm> Set the name of the dynamic linker. This is only meaningful when generating dynamically linked <?troff ps -1?>ELF<?troff ps 0?> executables. The default dynamic linker is normally correct; don't use this unless you know what you are doing.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--fatal-warnings</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--fatal-warnings</secondary></indexterm> Treat all warnings as errors.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--force-exe-suffix</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--force-exe-suffix</secondary></indexterm> Make sure that an output file has a .exe suffix.</para> <para>If a successfully built fully linked output file does not have a <emphasis remap='CW'>`.exe'</emphasis> or <emphasis remap='CW'>`.dll'</emphasis> suffix, this option forces the linker to copy the output file to one of the same name with a <emphasis remap='CW'>`.exe'</emphasis> suffix. This option is useful when using unmodified Unix makefiles on a Microsoft Windows host, since some versions of Windows won't run an image unless it ends in a <emphasis remap='CW'>`.exe'</emphasis> suffix.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--gc-sections</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--gc-sections</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-gc-sections</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-gc-sections</secondary></indexterm> <!-- PD --> Enable garbage collection of unused input sections. It is ignored on targets that do not support this option. This option is not compatible with <emphasis role='strong' remap='B'>-r</emphasis> or <emphasis role='strong' remap='B'>--emit-relocs</emphasis>. The default behaviour (of not performing this garbage collection) can be restored by specifying <emphasis role='strong' remap='B'>--no-gc-sections</emphasis> on the command line.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--print-gc-sections</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--print-gc-sections</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-print-gc-sections</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-print-gc-sections</secondary></indexterm> <!-- PD --> List all sections removed by garbage collection. The listing is printed on stderr. This option is only effective if garbage collection has been enabled via the <emphasis role='strong' remap='B'>--gc-sections</emphasis>) option. The default behaviour (of not listing the sections that are removed) can be restored by specifying <emphasis role='strong' remap='B'>--no-print-gc-sections</emphasis> on the command line.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--help</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--help</secondary></indexterm> Print a summary of the command-line options on the standard output and exit.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--target-help</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--target-help</secondary></indexterm> Print a summary of all target specific options on the standard output and exit.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Map</emphasis> <emphasis remap='I'>mapfile</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Map mapfile</secondary></indexterm> Print a link map to the file <filename>mapfile</filename>. See the description of the <emphasis role='strong' remap='B'>-M</emphasis> option, above.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-keep-memory</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-keep-memory</secondary></indexterm> <emphasis role='strong' remap='B'>ld</emphasis> normally optimizes for speed over memory usage by caching the symbol tables of input files in memory. This option tells <emphasis role='strong' remap='B'>ld</emphasis> to instead optimize for memory usage, by rereading the symbol tables as necessary. This may be required if <emphasis role='strong' remap='B'>ld</emphasis> runs out of memory space while linking a large executable.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-undefined</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-undefined</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-z defs</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-z defs</secondary></indexterm> <!-- PD --> Report unresolved symbol references from regular object files. This is done even if the linker is creating a non-symbolic shared library. The switch <emphasis role='strong' remap='B'>--[no-]allow-shlib-undefined</emphasis> controls the behaviour for reporting unresolved references found in shared libraries being linked in.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--allow-multiple-definition</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--allow-multiple-definition</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-z muldefs</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-z muldefs</secondary></indexterm> <!-- PD --> Normally when a symbol is defined multiple times, the linker will report a fatal error. These options allow multiple definitions and the first definition will be used.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--allow-shlib-undefined</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--allow-shlib-undefined</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-allow-shlib-undefined</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-allow-shlib-undefined</secondary></indexterm> <!-- PD --> Allows (the default) or disallows undefined symbols in shared libraries. This switch is similar to <emphasis role='strong' remap='B'>--no-undefined</emphasis> except that it determines the behaviour when the undefined symbols are in a shared library rather than a regular object file. It does not affect how undefined symbols in regular object files are handled.</para> <para>The reason that <emphasis role='strong' remap='B'>--allow-shlib-undefined</emphasis> is the default is that the shared library being specified at link time may not be the same as the one that is available at load time, so the symbols might actually be resolvable at load time. Plus there are some systems, (eg BeOS) where undefined symbols in shared libraries is normal. (The kernel patches them at load time to select which function is most appropriate for the current architecture. This is used for example to dynamically select an appropriate memset function). Apparently it is also normal for <?troff ps -1?>HPPA<?troff ps 0?> shared libraries to have undefined symbols.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-undefined-version</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-undefined-version</secondary></indexterm> Normally when a symbol has an undefined version, the linker will ignore it. This option disallows symbols with undefined version and a fatal error will be issued instead.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--default-symver</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--default-symver</secondary></indexterm> Create and use a default symbol version (the soname) for unversioned exported symbols.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--default-imported-symver</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--default-imported-symver</secondary></indexterm> Create and use a default symbol version (the soname) for unversioned imported symbols.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-warn-mismatch</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-warn-mismatch</secondary></indexterm> Normally <emphasis role='strong' remap='B'>ld</emphasis> will give an error if you try to link together input files that are mismatched for some reason, perhaps because they have been compiled for different processors or for different endiannesses. This option tells <emphasis role='strong' remap='B'>ld</emphasis> that it should silently permit such possible errors. This option should only be used with care, in cases when you have taken some special action that ensures that the linker errors are inappropriate.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-warn-search-mismatch</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-warn-search-mismatch</secondary></indexterm> Normally <emphasis role='strong' remap='B'>ld</emphasis> will give a warning if it finds an incompatible library during a library search. This option silences the warning.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--no-whole-archive</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-whole-archive</secondary></indexterm> Turn off the effect of the <emphasis role='strong' remap='B'>--whole-archive</emphasis> option for subsequent archive files.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--noinhibit-exec</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--noinhibit-exec</secondary></indexterm> Retain the executable output file whenever it is still usable. Normally, the linker will not produce an output file if it encounters errors during the link process; it exits without writing an output file when it issues any error whatsoever.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-nostdlib</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-nostdlib</secondary></indexterm> Only search library directories explicitly specified on the command line. Library directories specified in linker scripts (including linker scripts specified on the command line) are ignored.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--oformat</emphasis> <emphasis remap='I'>output-format</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--oformat output-format</secondary></indexterm> <emphasis role='strong' remap='B'>ld</emphasis> may be configured to support more than one kind of object file. If your <emphasis role='strong' remap='B'>ld</emphasis> is configured this way, you can use the <emphasis role='strong' remap='B'>--oformat</emphasis> option to specify the binary format for the output object file. Even when <emphasis role='strong' remap='B'>ld</emphasis> is configured to support alternative object formats, you don't usually need to specify this, as <emphasis role='strong' remap='B'>ld</emphasis> should be configured to produce as a default output format the most usual format on each machine. <emphasis remap='I'>output-format</emphasis> is a text string, the name of a particular format supported by the <?troff ps -1?>BFD<?troff ps 0?> libraries. (You can list the available binary formats with <emphasis role='strong' remap='B'>objdump -i</emphasis>.) The script command <emphasis remap='CW'>`OUTPUT_FORMAT'</emphasis> can also specify the output format, but this option overrides it.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-pie</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-pie</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--pic-executable</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--pic-executable</secondary></indexterm> <!-- PD --> Create a position independent executable. This is currently only supported on <?troff ps -1?>ELF<?troff ps 0?> platforms. Position independent executables are similar to shared libraries in that they are relocated by the dynamic linker to the virtual address the <?troff ps -1?>OS<?troff ps 0?> chooses for them (which can vary between invocations). Like normal dynamically linked executables they can be executed and symbols defined in the executable cannot be overridden by shared libraries.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-qmagic</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-qmagic</secondary></indexterm> This option is ignored for Linux compatibility.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Qy</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Qy</secondary></indexterm> This option is ignored for <?troff ps -1?>SVR4<?troff ps 0?> compatibility.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--relax</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--relax</secondary></indexterm> An option with machine dependent effects. This option is only supported on a few targets.</para> <para>On some platforms, the <emphasis role='strong' remap='B'>--relax</emphasis> option performs global optimizations that become possible when the linker resolves addressing in the program, such as relaxing address modes and synthesizing new instructions in the output object file.</para> <para>On some platforms these link time global optimizations may make symbolic debugging of the resulting executable impossible. This is known to be the case for the Matsushita <?troff ps -1?>MN10200<?troff ps 0?> and <?troff ps -1?>MN10300<?troff ps 0?> family of processors.</para> <para>On platforms where this is not supported, <emphasis role='strong' remap='B'>--relax</emphasis> is accepted, but ignored.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--retain-symbols-file</emphasis> <emphasis remap='I'>filename</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--retain-symbols-file filename</secondary></indexterm> Retain <emphasis remap='I'>only</emphasis> the symbols listed in the file <filename>filename</filename>, discarding all others. <emphasis remap='I'>filename</emphasis> is simply a flat file, with one symbol name per line. This option is especially useful in environments (such as VxWorks) where a large global symbol table is accumulated gradually, to conserve run-time memory.</para> <para><emphasis role='strong' remap='B'>--retain-symbols-file</emphasis> does <emphasis remap='I'>not</emphasis> discard undefined symbols, or symbols needed for relocations.</para> <para>You may only specify <emphasis role='strong' remap='B'>--retain-symbols-file</emphasis> once in the command line. It overrides <emphasis role='strong' remap='B'>-s</emphasis> and <emphasis role='strong' remap='B'>-S</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-rpath</emphasis> <emphasis remap='I'>dir</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-rpath dir</secondary></indexterm> Add a directory to the runtime library search path. This is used when linking an <?troff ps -1?>ELF<?troff ps 0?> executable with shared objects. All <emphasis role='strong' remap='B'>-rpath</emphasis> arguments are concatenated and passed to the runtime linker, which uses them to locate shared objects at runtime. The <emphasis role='strong' remap='B'>-rpath</emphasis> option is also used when locating shared objects which are needed by shared objects explicitly included in the link; see the description of the <emphasis role='strong' remap='B'>-rpath-link</emphasis> option. If <emphasis role='strong' remap='B'>-rpath</emphasis> is not used when linking an <?troff ps -1?>ELF<?troff ps 0?> executable, the contents of the environment variable <emphasis remap='CW'>`LD_RUN_PATH'</emphasis> will be used if it is defined.</para> <para>The <emphasis role='strong' remap='B'>-rpath</emphasis> option may also be used on SunOS. By default, on SunOS, the linker will form a runtime search patch out of all the <emphasis role='strong' remap='B'>-L</emphasis> options it is given. If a <emphasis role='strong' remap='B'>-rpath</emphasis> option is used, the runtime search path will be formed exclusively using the <emphasis role='strong' remap='B'>-rpath</emphasis> options, ignoring the <emphasis role='strong' remap='B'>-L</emphasis> options. This can be useful when using gcc, which adds many <emphasis role='strong' remap='B'>-L</emphasis> options which may be on <?troff ps -1?>NFS<?troff ps 0?> mounted file systems.</para> <para>For compatibility with other <?troff ps -1?>ELF<?troff ps 0?> linkers, if the <emphasis role='strong' remap='B'>-R</emphasis> option is followed by a directory name, rather than a file name, it is treated as the <emphasis role='strong' remap='B'>-rpath</emphasis> option.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-rpath-link</emphasis> <emphasis remap='I'><?troff ps -1?>DIR<?troff ps 0?></emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-rpath-link DIR</secondary></indexterm> When using <?troff ps -1?>ELF<?troff ps 0?> or SunOS, one shared library may require another. This happens when an <emphasis remap='CW'>`ld -shared'</emphasis> link includes a shared library as one of the input files.</para> <para>When the linker encounters such a dependency when doing a non-shared, non-relocatable link, it will automatically try to locate the required shared library and include it in the link, if it is not included explicitly. In such a case, the <emphasis role='strong' remap='B'>-rpath-link</emphasis> option specifies the first set of directories to search. The <emphasis role='strong' remap='B'>-rpath-link</emphasis> option may specify a sequence of directory names either by specifying a list of names separated by colons, or by appearing multiple times.</para> <para>This option should be used with caution as it overrides the search path that may have been hard compiled into a shared library. In such a case it is possible to use unintentionally a different search path than the runtime linker would do.</para> <para>The linker uses the following search paths to locate required shared libraries:</para> <variablelist remap='IP'> <varlistentry> <term>1.</term> <listitem> <para>Any directories specified by <emphasis role='strong' remap='B'>-rpath-link</emphasis> options.</para> </listitem> </varlistentry> <varlistentry> <term>2.</term> <listitem> <para>Any directories specified by <emphasis role='strong' remap='B'>-rpath</emphasis> options. The difference between <emphasis role='strong' remap='B'>-rpath</emphasis> and <emphasis role='strong' remap='B'>-rpath-link</emphasis> is that directories specified by <emphasis role='strong' remap='B'>-rpath</emphasis> options are included in the executable and used at runtime, whereas the <emphasis role='strong' remap='B'>-rpath-link</emphasis> option is only effective at link time. Searching <emphasis role='strong' remap='B'>-rpath</emphasis> in this way is only supported by native linkers and cross linkers which have been configured with the <emphasis role='strong' remap='B'>--with-sysroot</emphasis> option.</para> </listitem> </varlistentry> <varlistentry> <term>3.</term> <listitem> <para>On an <?troff ps -1?>ELF<?troff ps 0?> system, if the <emphasis role='strong' remap='B'>-rpath</emphasis> and <emphasis remap='CW'>`rpath-link'</emphasis> options were not used, search the contents of the environment variable <emphasis remap='CW'>`LD_RUN_PATH'</emphasis>. It is for the native linker only.</para> </listitem> </varlistentry> <varlistentry> <term>4.</term> <listitem> <para>On SunOS, if the <emphasis role='strong' remap='B'>-rpath</emphasis> option was not used, search any directories specified using <emphasis role='strong' remap='B'>-L</emphasis> options.</para> </listitem> </varlistentry> <varlistentry> <term>5.</term> <listitem> <para>For a native linker, the contents of the environment variable <emphasis remap='CW'>`LD_LIBRARY_PATH'</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term>6.</term> <listitem> <para>For a native <?troff ps -1?>ELF<?troff ps 0?> linker, the directories in <emphasis remap='CW'>`DT_RUNPATH'</emphasis> or <emphasis remap='CW'>`DT_RPATH'</emphasis> of a shared library are searched for shared libraries needed by it. The <emphasis remap='CW'>`DT_RPATH'</emphasis> entries are ignored if <emphasis remap='CW'>`DT_RUNPATH'</emphasis> entries exist.</para> </listitem> </varlistentry> <varlistentry> <term>7.</term> <listitem> <para>The default directories, normally <filename>/lib</filename> and <filename>/usr/lib</filename>.</para> </listitem> </varlistentry> <varlistentry> <term>8.</term> <listitem> <para>For a native linker on an <?troff ps -1?>ELF<?troff ps 0?> system, if the file <filename>/etc/ld.so.conf</filename> exists, the list of directories found in that file.</para> </listitem> </varlistentry> </variablelist> <blockquote remap='RS'> <para>If the required shared library is not found, the linker will issue a warning and continue with the link. </para></blockquote> <!-- remap='RE' --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-shared</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-shared</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Bshareable</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Bshareable</secondary></indexterm> <!-- PD --> Create a shared library. This is currently only supported on <?troff ps -1?>ELF<?troff ps 0?>, <?troff ps -1?>XCOFF<?troff ps 0?> and SunOS platforms. On SunOS, the linker will automatically create a shared library if the <emphasis role='strong' remap='B'>-e</emphasis> option is not used and there are undefined symbols in the link.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--sort-common</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--sort-common</secondary></indexterm> This option tells <emphasis role='strong' remap='B'>ld</emphasis> to sort the common symbols by size when it places them in the appropriate output sections. First come all the one byte symbols, then all the two byte, then all the four byte, and then everything else. This is to prevent gaps between symbols due to alignment constraints.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--sort-section name</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--sort-section name</secondary></indexterm> This option will apply <emphasis remap='CW'>`SORT_BY_NAME'</emphasis> to all wildcard section patterns in the linker script.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--sort-section alignment</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--sort-section alignment</secondary></indexterm> This option will apply <emphasis remap='CW'>`SORT_BY_ALIGNMENT'</emphasis> to all wildcard section patterns in the linker script.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--split-by-file [</emphasis><emphasis remap='I'>size</emphasis><emphasis role='strong' remap='B'>]</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--split-by-file [size]</secondary></indexterm> Similar to <emphasis role='strong' remap='B'>--split-by-reloc</emphasis> but creates a new output section for each input file when <emphasis remap='I'>size</emphasis> is reached. <emphasis remap='I'>size</emphasis> defaults to a size of 1 if not given.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--split-by-reloc [</emphasis><emphasis remap='I'>count</emphasis><emphasis role='strong' remap='B'>]</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--split-by-reloc [count]</secondary></indexterm> Tries to creates extra sections in the output file so that no single output section in the file contains more than <emphasis remap='I'>count</emphasis> relocations. This is useful when generating huge relocatable files for downloading into certain real time kernels with the <?troff ps -1?>COFF<?troff ps 0?> object file format; since <?troff ps -1?>COFF<?troff ps 0?> cannot represent more than 65535 relocations in a single section. Note that this will fail to work with object file formats which do not support arbitrary sections. The linker will not split up individual input sections for redistribution, so if a single input section contains more than <emphasis remap='I'>count</emphasis> relocations one output section will contain that many relocations. <emphasis remap='I'>count</emphasis> defaults to a value of 32768.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--stats</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--stats</secondary></indexterm> Compute and display statistics about the operation of the linker, such as execution time and memory usage.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--sysroot=</emphasis><emphasis remap='I'>directory</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--sysroot=directory</secondary></indexterm> Use <emphasis remap='I'>directory</emphasis> as the location of the sysroot, overriding the configure-time default. This option is only supported by linkers that were configured using <emphasis role='strong' remap='B'>--with-sysroot</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--traditional-format</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--traditional-format</secondary></indexterm> For some targets, the output of <emphasis role='strong' remap='B'>ld</emphasis> is different in some ways from the output of some existing linker. This switch requests <emphasis role='strong' remap='B'>ld</emphasis> to use the traditional format instead.</para> <para>For example, on SunOS, <emphasis role='strong' remap='B'>ld</emphasis> combines duplicate entries in the symbol string table. This can reduce the size of an output file with full debugging information by over 30 percent. Unfortunately, the SunOS <emphasis remap='CW'>`dbx'</emphasis> program can not read the resulting program (<emphasis remap='CW'>`gdb'</emphasis> has no trouble). The <emphasis role='strong' remap='B'>--traditional-format</emphasis> switch tells <emphasis role='strong' remap='B'>ld</emphasis> to not combine duplicate entries.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--section-start</emphasis> <emphasis remap='I'>sectionname</emphasis><emphasis role='strong' remap='B'>=</emphasis><emphasis remap='I'>org</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--section-start sectionname=org</secondary></indexterm> Locate a section in the output file at the absolute address given by <emphasis remap='I'>org</emphasis>. You may use this option as many times as necessary to locate multiple sections in the command line. <emphasis remap='I'>org</emphasis> must be a single hexadecimal integer; for compatibility with other linkers, you may omit the leading <emphasis role='strong' remap='B'>0x</emphasis> usually associated with hexadecimal values. <emphasis remap='I'>Note:</emphasis> there should be no white space between <emphasis remap='I'>sectionname</emphasis>, the equals sign ("<emphasis role='strong' remap='B'>=</emphasis>"), and <emphasis remap='I'>org</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Tbss</emphasis> <emphasis remap='I'>org</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Tbss org</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Tdata</emphasis> <emphasis remap='I'>org</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Tdata org</secondary></indexterm></para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>-Ttext</emphasis> <emphasis remap='I'>org</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>-Ttext org</secondary></indexterm> <!-- PD --> Same as --section-start, with <emphasis remap='CW'>`.bss'</emphasis>, <emphasis remap='CW'>`.data'</emphasis> or <emphasis remap='CW'>`.text'</emphasis> as the <emphasis remap='I'>sectionname</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--unresolved-symbols=</emphasis><emphasis remap='I'>method</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--unresolved-symbols=method</secondary></indexterm> Determine how to handle unresolved symbols. There are four possible values for <emphasis role='strong' remap='B'>method</emphasis>:</para> <variablelist remap='IP'> <varlistentry> <term><emphasis role='strong' remap='B'>ignore-all</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>ignore-all</secondary></indexterm> Do not report any unresolved symbols.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>report-all</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>report-all</secondary></indexterm> Report all unresolved symbols. This is the default.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>ignore-in-object-files</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>ignore-in-object-files</secondary></indexterm> Report unresolved symbols that are contained in shared libraries, but ignore them if they come from regular object files.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>ignore-in-shared-libs</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>ignore-in-shared-libs</secondary></indexterm> Report unresolved symbols that come from regular object files, but ignore them if they come from shared libraries. This can be useful when creating a dynamic binary and it is known that all the shared libraries that it should be referencing are included on the linker's command line.</para> </listitem> </varlistentry> </variablelist> <blockquote remap='RS'> <para>The behaviour for shared libraries on their own can also be controlled by the <emphasis role='strong' remap='B'>--[no-]allow-shlib-undefined</emphasis> option.</para> <para>Normally the linker will generate an error message for each reported unresolved symbol but the option <emphasis role='strong' remap='B'>--warn-unresolved-symbols</emphasis> can change this to a warning. </para></blockquote> <!-- remap='RE' --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--dll-verbose</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--dll-verbose</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--verbose</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--verbose</secondary></indexterm> <!-- PD --> Display the version number for <emphasis role='strong' remap='B'>ld</emphasis> and list the linker emulations supported. Display which input files can and cannot be opened. Display the linker script being used by the linker.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--version-script=</emphasis><emphasis remap='I'>version-scriptfile</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--version-script=version-scriptfile</secondary></indexterm> Specify the name of a version script to the linker. This is typically used when creating shared libraries to specify additional information about the version hierarchy for the library being created. This option is only meaningful on <?troff ps -1?>ELF<?troff ps 0?> platforms which support shared libraries.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--warn-common</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--warn-common</secondary></indexterm> Warn when a common symbol is combined with another common symbol or with a symbol definition. Unix linkers allow this somewhat sloppy practise, but linkers on some other operating systems do not. This option allows you to find potential problems from combining global symbols. Unfortunately, some C libraries use this practise, so you may get some warnings about symbols in the libraries as well as in your programs.</para> <para>There are three kinds of global symbols, illustrated here by C examples:</para> <variablelist remap='IP'> <varlistentry> <term><emphasis role='strong' remap='B'>int i = 1;</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>int i = 1;</secondary></indexterm> A definition, which goes in the initialized data section of the output file.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>extern int i;</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>extern int i;</secondary></indexterm> An undefined reference, which does not allocate space. There must be either a definition or a common symbol for the variable somewhere.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>int i;</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>int i;</secondary></indexterm> A common symbol. If there are only (one or more) common symbols for a variable, it goes in the uninitialized data area of the output file. The linker merges multiple common symbols for the same variable into a single symbol. If they are of different sizes, it picks the largest size. The linker turns a common symbol into a declaration, if there is a definition of the same variable.</para> </listitem> </varlistentry> </variablelist> <blockquote remap='RS'> <para>The <emphasis role='strong' remap='B'>--warn-common</emphasis> option can produce five kinds of warnings. Each warning consists of a pair of lines: the first describes the symbol just encountered, and the second describes the previous symbol encountered with the same name. One or both of the two symbols will be a common symbol.</para> <variablelist remap='IP'> <varlistentry> <term>1.</term> <listitem> <para>Turning a common symbol into a reference, because there is already a definition for the symbol.</para> <literallayout remap='Vb'> &lt;file&gt;(&lt;section&gt;): warning: common of &grave;&lt;symbol&gt; overridden by definition &lt;file&gt;(&lt;section&gt;): warning: defined here </literallayout> <!-- remap='Ve' --> <para>Turning a common symbol into a reference, because a later definition for the symbol is encountered. This is the same as the previous case, except that the symbols are encountered in a different order.</para> <literallayout remap='Vb'> &lt;file&gt;(&lt;section&gt;): warning: definition of &grave;&lt;symbol&gt; overriding common &lt;file&gt;(&lt;section&gt;): warning: common is here </literallayout> <!-- remap='Ve' --> <para>Merging a common symbol with a previous same-sized common symbol.</para> <literallayout remap='Vb'> &lt;file&gt;(&lt;section&gt;): warning: multiple common <funcsynopsis> <funcsynopsisinfo> of &grave;&lt;symbol&gt; </funcsynopsisinfo> </funcsynopsis> &lt;file&gt;(&lt;section&gt;): warning: previous common is here </literallayout> <!-- remap='Ve' --> <para>Merging a common symbol with a previous larger common symbol.</para> <literallayout remap='Vb'> &lt;file&gt;(&lt;section&gt;): warning: common of &grave;&lt;symbol&gt; overridden by larger common &lt;file&gt;(&lt;section&gt;): warning: larger common is here </literallayout> <!-- remap='Ve' --> <para>Merging a common symbol with a previous smaller common symbol. This is the same as the previous case, except that the symbols are encountered in a different order.</para> <literallayout remap='Vb'> &lt;file&gt;(&lt;section&gt;): warning: common of &grave;&lt;symbol&gt; overriding smaller common &lt;file&gt;(&lt;section&gt;): warning: smaller common is here </literallayout> <!-- remap='Ve' --> </listitem> </varlistentry> </variablelist> </blockquote> <!-- remap='RE' .RS 4 .RE --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--warn-constructors</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--warn-constructors</secondary></indexterm> Warn if any global constructors are used. This is only useful for a few object file formats. For formats like <?troff ps -1?>COFF<?troff ps 0?> or <?troff ps -1?>ELF<?troff ps 0?>, the linker can not detect the use of global constructors.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--warn-multiple-gp</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--warn-multiple-gp</secondary></indexterm> Warn if multiple global pointer values are required in the output file. This is only meaningful for certain processors, such as the Alpha. Specifically, some processors put large-valued constants in a special section. A special register (the global pointer) points into the middle of this section, so that constants can be loaded efficiently via a base-register relative addressing mode. Since the offset in base-register relative mode is fixed and relatively small (e.g., 16 bits), this limits the maximum size of the constant pool. Thus, in large programs, it is often necessary to use multiple global pointer values in order to be able to address all possible constants. This option causes a warning to be issued whenever this case occurs.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--warn-once</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--warn-once</secondary></indexterm> Only warn once for each undefined symbol, rather than once per module which refers to it.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--warn-section-align</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--warn-section-align</secondary></indexterm> Warn if the address of an output section is changed because of alignment. Typically, the alignment will be set by an input section. The address will only be changed if it not explicitly specified; that is, if the <emphasis remap='CW'>`SECTIONS'</emphasis> command does not specify a start address for the section.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--warn-shared-textrel</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--warn-shared-textrel</secondary></indexterm> Warn if the linker adds a <?troff ps -1?>DT_TEXTREL<?troff ps 0?> to a shared object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--warn-unresolved-symbols</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--warn-unresolved-symbols</secondary></indexterm> If the linker is going to report an unresolved symbol (see the option <emphasis role='strong' remap='B'>--unresolved-symbols</emphasis>) it will normally generate an error. This option makes it generate a warning instead.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--error-unresolved-symbols</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--error-unresolved-symbols</secondary></indexterm> This restores the linker's default behaviour of generating errors when it is reporting unresolved symbols.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--whole-archive</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--whole-archive</secondary></indexterm> For each archive mentioned on the command line after the <emphasis role='strong' remap='B'>--whole-archive</emphasis> option, include every object file in the archive in the link, rather than searching the archive for the required object files. This is normally used to turn an archive file into a shared library, forcing every object to be included in the resulting shared library. This option may be used more than once.</para> <para>Two notes when using this option from gcc: First, gcc doesn't know about this option, so you have to use <emphasis role='strong' remap='B'>-Wl,-whole-archive</emphasis>. Second, don't forget to use <emphasis role='strong' remap='B'>-Wl,-no-whole-archive</emphasis> after your list of archives, because gcc will add its own list of archives to your link and you may not want this flag to affect those as well.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--wrap</emphasis> <emphasis remap='I'>symbol</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--wrap symbol</secondary></indexterm> Use a wrapper function for <emphasis remap='I'>symbol</emphasis>. Any undefined reference to <emphasis remap='I'>symbol</emphasis> will be resolved to <emphasis remap='CW'>`_&thinsp;_wrap_</emphasis><emphasis remap='CI'>symbol</emphasis><emphasis remap='CW'>'</emphasis>. Any undefined reference to <emphasis remap='CW'>`_&thinsp;_real_</emphasis><emphasis remap='CI'>symbol</emphasis><emphasis remap='CW'>'</emphasis> will be resolved to <emphasis remap='I'>symbol</emphasis>.</para> <para>This can be used to provide a wrapper for a system function. The wrapper function should be called <emphasis remap='CW'>`_&thinsp;_wrap_</emphasis><emphasis remap='CI'>symbol</emphasis><emphasis remap='CW'>'</emphasis>. If it wishes to call the system function, it should call <emphasis remap='CW'>`_&thinsp;_real_</emphasis><emphasis remap='CI'>symbol</emphasis><emphasis remap='CW'>'</emphasis>.</para> <para>Here is a trivial example:</para> <literallayout remap='Vb'> <funcsynopsis> <funcprototype> <funcdef>void *<function>__wrap_malloc</function></funcdef> <paramdef>size_t <parameter>c</parameter></paramdef> </funcprototype> </funcsynopsis> { <funcsynopsis> <funcprototype> <funcdef><function>printf</function></funcdef> <paramdef>"malloc called <parameter>with</parameter>%zu&bsol;n"</paramdef> <paramdef><parameter>c</parameter></paramdef> </funcprototype> <funcprototype> <funcdef>return <function>__real_malloc</function></funcdef> <paramdef><parameter>c</parameter></paramdef> </funcprototype> </funcsynopsis> } </literallayout> <!-- remap='Ve' --> <para>If you link other code with this file using <emphasis role='strong' remap='B'>--wrap malloc</emphasis>, then all calls to <emphasis remap='CW'>`malloc'</emphasis> will call the function <emphasis remap='CW'>`_&thinsp;_wrap_malloc'</emphasis> instead. The call to <emphasis remap='CW'>`_&thinsp;_real_malloc'</emphasis> in <emphasis remap='CW'>`_&thinsp;_wrap_malloc'</emphasis> will call the real <emphasis remap='CW'>`malloc'</emphasis> function.</para> <para>You may wish to provide a <emphasis remap='CW'>`_&thinsp;_real_malloc'</emphasis> function as well, so that links without the <emphasis role='strong' remap='B'>--wrap</emphasis> option will succeed. If you do this, you should not put the definition of <emphasis remap='CW'>`_&thinsp;_real_malloc'</emphasis> in the same file as <emphasis remap='CW'>`_&thinsp;_wrap_malloc'</emphasis>; if you do, the assembler may resolve the call before the linker has a chance to wrap it to <emphasis remap='CW'>`malloc'</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--eh-frame-hdr</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--eh-frame-hdr</secondary></indexterm> Request creation of <emphasis remap='CW'>`.eh_frame_hdr'</emphasis> section and <?troff ps -1?>ELF<?troff ps 0?> <emphasis remap='CW'>`PT_GNU_EH_FRAME'</emphasis> segment header.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--enable-new-dtags</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--enable-new-dtags</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--disable-new-dtags</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--disable-new-dtags</secondary></indexterm> <!-- PD --> This linker can create the new dynamic tags in <?troff ps -1?>ELF<?troff ps 0?>. But the older <?troff ps -1?>ELF<?troff ps 0?> systems may not understand them. If you specify <emphasis role='strong' remap='B'>--enable-new-dtags</emphasis>, the dynamic tags will be created as needed. If you specify <emphasis role='strong' remap='B'>--disable-new-dtags</emphasis>, no new dynamic tags will be created. By default, the new dynamic tags are not created. Note that those options are only available for <?troff ps -1?>ELF<?troff ps 0?> systems.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--hash-size=</emphasis><emphasis remap='I'>number</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--hash-size=number</secondary></indexterm> Set the default size of the linker's hash tables to a prime number close to <emphasis remap='I'>number</emphasis>. Increasing this value can reduce the length of time it takes the linker to perform its tasks, at the expense of increasing the linker's memory requirements. Similarly reducing this value can reduce the memory requirements at the expense of speed.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--hash-style=</emphasis><emphasis remap='I'>style</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--hash-style=style</secondary></indexterm> Set the type of linker's hash table(s). <emphasis remap='I'>style</emphasis> can be either <emphasis remap='CW'>`sysv'</emphasis> for classic <?troff ps -1?>ELF<?troff ps 0?> <emphasis remap='CW'>`.hash'</emphasis> section, <emphasis remap='CW'>`gnu'</emphasis> for new style <?troff ps -1?>GNU<?troff ps 0?> <emphasis remap='CW'>`.gnu.hash'</emphasis> section or <emphasis remap='CW'>`both'</emphasis> for both the classic <?troff ps -1?>ELF<?troff ps 0?> <emphasis remap='CW'>`.hash'</emphasis> and new style <?troff ps -1?>GNU<?troff ps 0?> <emphasis remap='CW'>`.gnu.hash'</emphasis> hash tables. The default is <emphasis remap='CW'>`sysv'</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--reduce-memory-overheads</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--reduce-memory-overheads</secondary></indexterm> This option reduces memory requirements at ld runtime, at the expense of linking speed. This was introduced to select the old O(n^2) algorithm for link map file generation, rather than the new O(n) algorithm which uses about 40% more memory for symbol storage.</para> <para>Another effect of the switch is to set the default hash table size to 1021, which again saves memory at the cost of lengthening the linker's run time. This is not done however if the <emphasis role='strong' remap='B'>--hash-size</emphasis> switch has been used.</para> <para>The <emphasis role='strong' remap='B'>--reduce-memory-overheads</emphasis> switch may be also be used to enable other tradeoffs in future versions of the linker.</para> </listitem> </varlistentry> </variablelist> <para>The i386 <?troff ps -1?>PE<?troff ps 0?> linker supports the <emphasis role='strong' remap='B'>-shared</emphasis> option, which causes the output to be a dynamically linked library (<?troff ps -1?>DLL<?troff ps 0?>) instead of a normal executable. You should name the output <emphasis remap='CW'>`*.dll'</emphasis> when you use this option. In addition, the linker fully supports the standard <emphasis remap='CW'>`*.def'</emphasis> files, which may be specified on the linker command line like an object file (in fact, it should precede archives it exports symbols from, to ensure that they get linked in, just like a normal object file).</para> <para>In addition to the options common to all targets, the i386 <?troff ps -1?>PE<?troff ps 0?> linker support additional command line options that are specific to the i386 <?troff ps -1?>PE<?troff ps 0?> target. Options that take values may be separated from their values by either a space or an equals sign.</para> <variablelist remap='IP'> <varlistentry> <term><emphasis role='strong' remap='B'>--add-stdcall-alias</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--add-stdcall-alias</secondary></indexterm> If given, symbols with a stdcall suffix (@<emphasis remap='I'>nn</emphasis>) will be exported as-is and also with the suffix stripped. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--base-file</emphasis> <emphasis remap='I'>file</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--base-file file</secondary></indexterm> Use <emphasis remap='I'>file</emphasis> as the name of a file in which to save the base addresses of all the relocations needed for generating DLLs with <emphasis remap='I'>dlltool</emphasis>. [This is an i386 <?troff ps -1?>PE<?troff ps 0?> specific option]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--dll</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--dll</secondary></indexterm> Create a <?troff ps -1?>DLL<?troff ps 0?> instead of a regular executable. You may also use <emphasis role='strong' remap='B'>-shared</emphasis> or specify a <emphasis remap='CW'>`LIBRARY'</emphasis> in a given <emphasis remap='CW'>`.def'</emphasis> file. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--enable-stdcall-fixup</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--enable-stdcall-fixup</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--disable-stdcall-fixup</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--disable-stdcall-fixup</secondary></indexterm> <!-- PD --> If the link finds a symbol that it cannot resolve, it will attempt to do &ldquo;fuzzy linking&rdquo; by looking for another defined symbol that differs only in the format of the symbol name (cdecl vs stdcall) and will resolve that symbol by linking to the match. For example, the undefined symbol <emphasis remap='CW'>`_foo'</emphasis> might be linked to the function <emphasis remap='CW'>`_foo@12'</emphasis>, or the undefined symbol <emphasis remap='CW'>`_bar@16'</emphasis> might be linked to the function <emphasis remap='CW'>`_bar'</emphasis>. When the linker does this, it prints a warning, since it normally should have failed to link, but sometimes import libraries generated from third-party dlls may need this feature to be usable. If you specify <emphasis role='strong' remap='B'>--enable-stdcall-fixup</emphasis>, this feature is fully enabled and warnings are not printed. If you specify <emphasis role='strong' remap='B'>--disable-stdcall-fixup</emphasis>, this feature is disabled and such mismatches are considered to be errors. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--export-all-symbols</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--export-all-symbols</secondary></indexterm> If given, all global symbols in the objects used to build a <?troff ps -1?>DLL<?troff ps 0?> will be exported by the <?troff ps -1?>DLL<?troff ps 0?>. Note that this is the default if there otherwise wouldn't be any exported symbols. When symbols are explicitly exported via <?troff ps -1?>DEF<?troff ps 0?> files or implicitly exported via function attributes, the default is to not export anything else unless this option is given. Note that the symbols <emphasis remap='CW'>`DllMain@12'</emphasis>, <emphasis remap='CW'>`DllEntryPoint@0'</emphasis>, <emphasis remap='CW'>`DllMainCRTStartup@12'</emphasis>, and <emphasis remap='CW'>`impure_ptr'</emphasis> will not be automatically exported. Also, symbols imported from other DLLs will not be re-exported, nor will symbols specifying the <?troff ps -1?>DLL<?troff ps 0?>'s internal layout such as those beginning with <emphasis remap='CW'>`_head_'</emphasis> or ending with <emphasis remap='CW'>`_iname'</emphasis>. In addition, no symbols from <emphasis remap='CW'>`libgcc'</emphasis>, <emphasis remap='CW'>`libstd++'</emphasis>, <emphasis remap='CW'>`libmingw32'</emphasis>, or <emphasis remap='CW'>`crtX.o'</emphasis> will be exported. Symbols whose names begin with <emphasis remap='CW'>`_&thinsp;_rtti_'</emphasis> or <emphasis remap='CW'>`_&thinsp;_builtin_'</emphasis> will not be exported, to help with C++; DLLs. Finally, there is an extensive list of cygwin-private symbols that are not exported (obviously, this applies on when building DLLs for cygwin targets). These cygwin-excludes are: <emphasis remap='CW'>`_cygwin_dll_entry@12'</emphasis>, <emphasis remap='CW'>`_cygwin_crt0_common@8'</emphasis>, <emphasis remap='CW'>`_cygwin_noncygwin_dll_entry@12'</emphasis>, <emphasis remap='CW'>`_fmode'</emphasis>, <emphasis remap='CW'>`_impure_ptr'</emphasis>, <emphasis remap='CW'>`cygwin_attach_dll'</emphasis>, <emphasis remap='CW'>`cygwin_premain0'</emphasis>, <emphasis remap='CW'>`cygwin_premain1'</emphasis>, <emphasis remap='CW'>`cygwin_premain2'</emphasis>, <emphasis remap='CW'>`cygwin_premain3'</emphasis>, and <emphasis remap='CW'>`environ'</emphasis>. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--exclude-symbols</emphasis> <emphasis remap='I'>symbol</emphasis><emphasis role='strong' remap='B'>,</emphasis><emphasis remap='I'>symbol</emphasis><emphasis role='strong' remap='B'>,...</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--exclude-symbols symbol,symbol,...</secondary></indexterm> Specifies a list of symbols which should not be automatically exported. The symbol names may be delimited by commas or colons. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--file-alignment</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--file-alignment</secondary></indexterm> Specify the file alignment. Sections in the file will always begin at file offsets which are multiples of this number. This defaults to 512. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--heap</emphasis> <emphasis remap='I'>reserve</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--heap reserve</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--heap</emphasis> <emphasis remap='I'>reserve</emphasis><emphasis role='strong' remap='B'>,</emphasis><emphasis remap='I'>commit</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--heap reserve,commit</secondary></indexterm> <!-- PD --> Specify the amount of memory to reserve (and optionally commit) to be used as heap for this program. The default is 1Mb reserved, 4K committed. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--image-base</emphasis> <emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--image-base value</secondary></indexterm> Use <emphasis remap='I'>value</emphasis> as the base address of your program or dll. This is the lowest memory location that will be used when your program or dll is loaded. To reduce the need to relocate and improve performance of your dlls, each should have a unique base address and not overlap any other dlls. The default is 0x400000 for executables, and 0x10000000 for dlls. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--kill-at</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--kill-at</secondary></indexterm> If given, the stdcall suffixes (@<emphasis remap='I'>nn</emphasis>) will be stripped from symbols before they are exported. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--large-address-aware</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--large-address-aware</secondary></indexterm> If given, the appropriate bit in the &ldquo;Characteristics&rdquo; field of the <?troff ps -1?>COFF<?troff ps 0?> header is set to indicate that this executable supports virtual addresses greater than 2 gigabytes. This should be used in conjunction with the /3GB or /USERVA=<emphasis remap='I'>value</emphasis> megabytes switch in the &ldquo;[operating systems]&rdquo; section of the <?troff ps -1?>BOOT<?troff ps 0?>.INI. Otherwise, this bit has no effect. [This option is specific to <?troff ps -1?>PE<?troff ps 0?> targeted ports of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--major-image-version</emphasis> <emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--major-image-version value</secondary></indexterm> Sets the major number of the &ldquo;image version&rdquo;. Defaults to 1. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--major-os-version</emphasis> <emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--major-os-version value</secondary></indexterm> Sets the major number of the &ldquo;os version&rdquo;. Defaults to 4. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--major-subsystem-version</emphasis> <emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--major-subsystem-version value</secondary></indexterm> Sets the major number of the &ldquo;subsystem version&rdquo;. Defaults to 4. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--minor-image-version</emphasis> <emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--minor-image-version value</secondary></indexterm> Sets the minor number of the &ldquo;image version&rdquo;. Defaults to 0. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--minor-os-version</emphasis> <emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--minor-os-version value</secondary></indexterm> Sets the minor number of the &ldquo;os version&rdquo;. Defaults to 0. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--minor-subsystem-version</emphasis> <emphasis remap='I'>value</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--minor-subsystem-version value</secondary></indexterm> Sets the minor number of the &ldquo;subsystem version&rdquo;. Defaults to 0. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--output-def</emphasis> <emphasis remap='I'>file</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--output-def file</secondary></indexterm> The linker will create the file <filename>file</filename> which will contain a <?troff ps -1?>DEF<?troff ps 0?> file corresponding to the <?troff ps -1?>DLL<?troff ps 0?> the linker is generating. This <?troff ps -1?>DEF<?troff ps 0?> file (which should be called <emphasis remap='CW'>`*.def'</emphasis>) may be used to create an import library with <emphasis remap='CW'>`dlltool'</emphasis> or may be used as a reference to automatically or implicitly exported symbols. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--out-implib</emphasis> <emphasis remap='I'>file</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--out-implib file</secondary></indexterm> The linker will create the file <filename>file</filename> which will contain an import lib corresponding to the <?troff ps -1?>DLL<?troff ps 0?> the linker is generating. This import lib (which should be called <emphasis remap='CW'>`*.dll.a'</emphasis> or <emphasis remap='CW'>`*.a'</emphasis> may be used to link clients against the generated <?troff ps -1?>DLL<?troff ps 0?>; this behaviour makes it possible to skip a separate <emphasis remap='CW'>`dlltool'</emphasis> import library creation step. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--enable-auto-image-base</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--enable-auto-image-base</secondary></indexterm> Automatically choose the image base for DLLs, unless one is specified using the <emphasis remap='CW'>`--image-base'</emphasis> argument. By using a hash generated from the dllname to create unique image bases for each <?troff ps -1?>DLL<?troff ps 0?>, in-memory collisions and relocations which can delay program execution are avoided. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--disable-auto-image-base</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--disable-auto-image-base</secondary></indexterm> Do not automatically generate a unique image base. If there is no user-specified image base (<emphasis remap='CW'>`--image-base'</emphasis>) then use the platform default. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--dll-search-prefix</emphasis> <emphasis remap='I'>string</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--dll-search-prefix string</secondary></indexterm> When linking dynamically to a dll without an import library, search for <emphasis remap='CW'>`&lt;string&gt;&lt;basename&gt;.dll'</emphasis> in preference to <emphasis remap='CW'>`lib&lt;basename&gt;.dll'</emphasis>. This behaviour allows easy distinction between DLLs built for the various &ldquo;subplatforms&rdquo;: native, cygwin, uwin, pw, etc. For instance, cygwin DLLs typically use <emphasis remap='CW'>`--dll-search-prefix=cyg'</emphasis>. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--enable-auto-import</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--enable-auto-import</secondary></indexterm> Do sophisticated linking of <emphasis remap='CW'>`_symbol'</emphasis> to <emphasis remap='CW'>`_&thinsp;_imp_&thinsp;_symbol'</emphasis> for <?troff ps -1?>DATA<?troff ps 0?> imports from DLLs, and create the necessary thunking symbols when building the import libraries with those <?troff ps -1?>DATA<?troff ps 0?> exports. Note: Use of the 'auto-import' extension will cause the text section of the image file to be made writable. This does not conform to the PE-COFF format specification published by Microsoft.</para> <para>Using 'auto-import' generally will 'just work' &mdash; but sometimes you may see this message:</para> <para>"variable '&lt;var&gt;' can't be auto-imported. Please read the documentation for ld's <emphasis remap='CW'>`--enable-auto-import'</emphasis> for details."</para> <para>This message occurs when some (sub)expression accesses an address ultimately given by the sum of two constants (Win32 import tables only allow one). Instances where this may occur include accesses to member fields of struct variables imported from a <?troff ps -1?>DLL<?troff ps 0?>, as well as using a constant index into an array variable imported from a <?troff ps -1?>DLL<?troff ps 0?>. Any multiword variable (arrays, structs, long long, etc) may trigger this error condition. However, regardless of the exact data type of the offending exported variable, ld will always detect it, issue the warning, and exit.</para> <para>There are several ways to address this difficulty, regardless of the data type of the exported variable:</para> <para>One way is to use --enable-runtime-pseudo-reloc switch. This leaves the task of adjusting references in your client code for runtime environment, so this method works only when runtime environment supports this feature.</para> <para>A second solution is to force one of the 'constants' to be a variable &mdash; that is, unknown and un-optimizable at compile time. For arrays, there are two possibilities: a) make the indexee (the array's address) a variable, or b) make the 'constant' index a variable. Thus:</para> <literallayout remap='Vb'> extern type extern_array[]; extern_array[1] --&gt; { volatile type *t=extern_array; t[1] } </literallayout> <!-- remap='Ve' --> <para>or</para> <programlisting remap='Vb'> extern type extern_array[]; extern_array[1] --&gt; { volatile int t=1; extern_array[t] } </programlisting> <!-- remap='Ve' --> <para>For structs (and most other multiword data types) the only option is to make the struct itself (or the long long, or the ...) variable:</para> <programlisting remap='Vb'> extern struct s extern_struct; extern_struct.field --&gt; { volatile struct s *t=&amp;extern_struct; t-&gt;field } </programlisting> <!-- remap='Ve' --> <para>or</para> <literallayout remap='Vb'> extern long long extern_ll; extern_ll --&gt; { volatile long long * local_ll=&amp;extern_ll; *local_ll } </literallayout> <!-- remap='Ve' --> <para>A third method of dealing with this difficulty is to abandon 'auto-import' for the offending symbol and mark it with <emphasis remap='CW'>`_&thinsp;_declspec(dllimport)'</emphasis>. However, in practise that requires using compile-time #defines to indicate whether you are building a <?troff ps -1?>DLL<?troff ps 0?>, building client code that will link to the <?troff ps -1?>DLL<?troff ps 0?>, or merely building/linking to a static library. In making the choice between the various methods of resolving the 'direct address with constant offset' problem, you should consider typical real-world usage:</para> <para>Original:</para> <literallayout remap='Vb'> --foo.h <funcsynopsis> <funcsynopsisinfo> extern int arr[]; </funcsynopsisinfo> </funcsynopsis> --foo.c <funcsynopsis> <funcsynopsisinfo> #include "foo.h" </funcsynopsisinfo> </funcsynopsis> void main(int argc, char **argv){ <funcsynopsis> <funcprototype> <funcdef><function>printf</function></funcdef> <paramdef><parameter>"%d&bsol;n"</parameter></paramdef> <paramdef>arr [ 1 ] <parameter></parameter></paramdef> </funcprototype> </funcsynopsis> } </literallayout> <!-- remap='Ve' --> <para>Solution 1:</para> <literallayout remap='Vb'> --foo.h <funcsynopsis> <funcsynopsisinfo> extern int arr[]; </funcsynopsisinfo> </funcsynopsis> --foo.c <funcsynopsis> <funcsynopsisinfo> #include "foo.h" </funcsynopsisinfo> </funcsynopsis> void main(int argc, char **argv){ <funcsynopsis> <funcsynopsisinfo> /* This workaround is for win32 and cygwin; do not "optimize" */ </funcsynopsisinfo> <funcsynopsisinfo> volatile int *parr = arr; </funcsynopsisinfo> <funcprototype> <funcdef><function>printf</function></funcdef> <paramdef><parameter>"%d&bsol;n"</parameter></paramdef> <paramdef>parr [ 1 ] <parameter></parameter></paramdef> </funcprototype> </funcsynopsis> } </literallayout> <!-- remap='Ve' --> <para>Solution 2:</para> <literallayout remap='Vb'> --foo.h /* Note: auto-export is assumed (no _&thinsp;_declspec(dllexport)) */ <funcsynopsis> <funcsynopsisinfo> #if (defined(_WIN32) || defined(__CYGWIN__)) &amp;&amp; &bsol; </funcsynopsisinfo> </funcsynopsis> !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC)) <funcsynopsis> <funcsynopsisinfo> #define FOO_IMPORT __declspec(dllimport) </funcsynopsisinfo> </funcsynopsis> #else <funcsynopsis> <funcsynopsisinfo> #define FOO_IMPORT #endif extern FOO_IMPORT int arr[]; </funcsynopsisinfo> </funcsynopsis> --foo.c <funcsynopsis> <funcsynopsisinfo> #include "foo.h" </funcsynopsisinfo> </funcsynopsis> void main(int argc, char **argv){ <funcsynopsis> <funcprototype> <funcdef><function>printf</function></funcdef> <paramdef><parameter>"%d&bsol;n"</parameter></paramdef> <paramdef>arr [ 1 ] <parameter></parameter></paramdef> </funcprototype> </funcsynopsis> } </literallayout> <!-- remap='Ve' --> <para>A fourth way to avoid this problem is to re-code your library to use a functional interface rather than a data interface for the offending variables (e.g. <function>set_foo()</function> and <function>get_foo()</function> accessor functions). [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--disable-auto-import</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--disable-auto-import</secondary></indexterm> Do not attempt to do sophisticated linking of <emphasis remap='CW'>`_symbol'</emphasis> to <emphasis remap='CW'>`_&thinsp;_imp_&thinsp;_symbol'</emphasis> for <?troff ps -1?>DATA<?troff ps 0?> imports from DLLs. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--enable-runtime-pseudo-reloc</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--enable-runtime-pseudo-reloc</secondary></indexterm> If your code contains expressions described in --enable-auto-import section, that is, <?troff ps -1?>DATA<?troff ps 0?> imports from <?troff ps -1?>DLL<?troff ps 0?> with non-zero offset, this switch will create a vector of 'runtime pseudo relocations' which can be used by runtime environment to adjust references to such data in your client code. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--disable-runtime-pseudo-reloc</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--disable-runtime-pseudo-reloc</secondary></indexterm> Do not create pseudo relocations for non-zero offset <?troff ps -1?>DATA<?troff ps 0?> imports from DLLs. This is the default. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--enable-extra-pe-debug</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--enable-extra-pe-debug</secondary></indexterm> Show additional debug info related to auto-import symbol thunking. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--section-alignment</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--section-alignment</secondary></indexterm> Sets the section alignment. Sections in memory will always begin at addresses which are a multiple of this number. Defaults to 0x1000. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--stack</emphasis> <emphasis remap='I'>reserve</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--stack reserve</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--stack</emphasis> <emphasis remap='I'>reserve</emphasis><emphasis role='strong' remap='B'>,</emphasis><emphasis remap='I'>commit</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--stack reserve,commit</secondary></indexterm> <!-- PD --> Specify the amount of memory to reserve (and optionally commit) to be used as stack for this program. The default is 2Mb reserved, 4K committed. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--subsystem</emphasis> <emphasis remap='I'>which</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--subsystem which</secondary></indexterm></para> <!-- PD 0 --> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--subsystem</emphasis> <emphasis remap='I'>which</emphasis><emphasis role='strong' remap='B'>:</emphasis><emphasis remap='I'>major</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--subsystem which:major</secondary></indexterm></para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--subsystem</emphasis> <emphasis remap='I'>which</emphasis><emphasis role='strong' remap='B'>:</emphasis><emphasis remap='I'>major</emphasis><emphasis role='strong' remap='B'>.</emphasis><emphasis remap='I'>minor</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--subsystem which:major.minor</secondary></indexterm> <!-- PD --> Specifies the subsystem under which your program will execute. The legal values for <emphasis remap='I'>which</emphasis> are <emphasis remap='CW'>`native'</emphasis>, <emphasis remap='CW'>`windows'</emphasis>, <emphasis remap='CW'>`console'</emphasis>, <emphasis remap='CW'>`posix'</emphasis>, and <emphasis remap='CW'>`xbox'</emphasis>. You may optionally set the subsystem version also. Numeric values are also accepted for <emphasis remap='I'>which</emphasis>. [This option is specific to the i386 <?troff ps -1?>PE<?troff ps 0?> targeted port of the linker]</para> </listitem> </varlistentry> </variablelist> <para>The 68HC11 and 68HC12 linkers support specific options to control the memory bank switching mapping and trampoline code generation.</para> <variablelist remap='IP'> <varlistentry> <term><emphasis role='strong' remap='B'>--no-trampoline</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--no-trampoline</secondary></indexterm> This option disables the generation of trampoline. By default a trampoline is generated for each far function which is called using a <emphasis remap='CW'>`jsr'</emphasis> instruction (this happens when a pointer to a far function is taken).</para> </listitem> </varlistentry> <varlistentry> <term><emphasis role='strong' remap='B'>--bank-window</emphasis> <emphasis remap='I'>name</emphasis></term> <listitem> <para><indexterm><primary>Item</primary><secondary>--bank-window name</secondary></indexterm> This option indicates to the linker the name of the memory region in the <emphasis role='strong' remap='B'><?troff ps -1?>MEMORY<?troff ps 0?></emphasis> specification that describes the memory bank window. The definition of such region is then used by the linker to compute paging and addresses within the memory window.</para> </listitem> </varlistentry> </variablelist> </refsect1> <refsect1 xml:id='doclifter-environment'><title>ENVIRONMENT</title> <para><indexterm><primary>Header</primary><secondary>ENVIRONMENT</secondary></indexterm> You can change the behaviour of <emphasis role='strong' remap='B'>ld</emphasis> with the environment variables <emphasis remap='CW'>`GNUTARGET'</emphasis>, <emphasis remap='CW'>`LDEMULATION'</emphasis> and <emphasis remap='CW'>`COLLECT_NO_DEMANGLE'</emphasis>.</para> <para><emphasis remap='CW'>`GNUTARGET'</emphasis> determines the input-file object format if you don't use <emphasis role='strong' remap='B'>-b</emphasis> (or its synonym <emphasis role='strong' remap='B'>--format</emphasis>). Its value should be one of the <?troff ps -1?>BFD<?troff ps 0?> names for an input format. If there is no <emphasis remap='CW'>`GNUTARGET'</emphasis> in the environment, <emphasis role='strong' remap='B'>ld</emphasis> uses the natural format of the target. If <emphasis remap='CW'>`GNUTARGET'</emphasis> is set to <emphasis remap='CW'>`default'</emphasis> then <?troff ps -1?>BFD<?troff ps 0?> attempts to discover the input format by examining binary input files; this method often succeeds, but there are potential ambiguities, since there is no method of ensuring that the magic number used to specify object-file formats is unique. However, the configuration procedure for <?troff ps -1?>BFD<?troff ps 0?> on each system places the conventional format for that system first in the search-list, so ambiguities are resolved in favor of convention.</para> <para><emphasis remap='CW'>`LDEMULATION'</emphasis> determines the default emulation if you don't use the <emphasis role='strong' remap='B'>-m</emphasis> option. The emulation can affect various aspects of linker behaviour, particularly the default linker script. You can list the available emulations with the <emphasis role='strong' remap='B'>--verbose</emphasis> or <emphasis role='strong' remap='B'>-V</emphasis> options. If the <emphasis role='strong' remap='B'>-m</emphasis> option is not used, and the <emphasis remap='CW'>`LDEMULATION'</emphasis> environment variable is not defined, the default emulation depends upon how the linker was configured.</para> <para>Normally, the linker will default to demangling symbols. However, if <emphasis remap='CW'>`COLLECT_NO_DEMANGLE'</emphasis> is set in the environment, then it will default to not demangling symbols. This environment variable is used in a similar fashion by the <emphasis remap='CW'>`gcc'</emphasis> linker wrapper program. The default may be overridden by the <emphasis role='strong' remap='B'>--demangle</emphasis> and <emphasis role='strong' remap='B'>--no-demangle</emphasis> options.</para> </refsect1> <refsect1 xml:id='doclifter-see_also'><title>SEE ALSO</title> <para><indexterm><primary>Header</primary><secondary>SEE ALSO</secondary></indexterm> <citerefentry><refentrytitle>ar</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>nm</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>objcopy</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>objdump</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>readelf</refentrytitle><manvolnum>1</manvolnum></citerefentry> and the Info entries for <emphasis remap='I'>binutils</emphasis> and <command>ld</command>.</para> </refsect1> <refsect1 xml:id='doclifter-copyright'><title>COPYRIGHT</title> <para><indexterm><primary>Header</primary><secondary>COPYRIGHT</secondary></indexterm> Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.</para> <para>Permission is granted to copy, distribute and/or modify this document under the terms of the <?troff ps -1?>GNU<?troff ps 0?> Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled &ldquo;<?troff ps -1?>GNU<?troff ps 0?> Free Documentation License&rdquo;.</para> </refsect1> </refentry>
164,054
Common Lisp
.l
3,010
52.139203
457
0.74191
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
e8552323e88397ded97165abbd966ff38bdaaf4b83fb92c241204a9a0228ada2
29,372
[ -1 ]
29,373
dlopen.3.xml
thinkum_ltp-main/doc/docbook/ltp-eo/dlopen.3.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- lifted from mdoc+troff by doclifter --> <refentry xmlns='http://docbook.org/ns/docbook' version='5.0' xml:lang='en' xml:id='doclifter-dlopen3'> <!-- This source code is a product of Sun Microsystems, Inc. and is provided for unrestricted use provided that this legend is included on all tape media and as a part of the software program in whole or part. Users may copy or modify this source code without charge, but are not authorized to license or distribute it to anyone else except as part of a product or program developed by the user. --> <!-- THIS PROGRAM CONTAINS SOURCE CODE COPYRIGHTED BY SUN MICROSYSTEMS, INC. SUN MICROSYSTEMS, INC., MAKES NO REPRESENTATIONS ABOUT THE SUITABLITY OF SUCH SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. SUN MICROSYSTEMS, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO SUCH SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM USE OF SUCH SOURCE CODE, REGARDLESS OF THE THEORY OF LIABILITY. --> <!-- This source code is provided with no support and without any obligation on the part of Sun Microsystems, Inc. to assist in its use, correction, modification or enhancement. --> <!-- SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOURCE CODE OR ANY PART THEREOF. --> <!-- Sun Microsystems, Inc. 2550 Garcia Avenue Mountain View, California 94043 --> <!-- Copyright (c) 1991 Sun Microsystems, Inc. --> <!-- @(#) dlopen.3 1.6 90/01/31 SMI $FreeBSD: stable/11/lib/libc/gen/dlopen.3 278758 2015&bsol;-02&bsol;-14 15:14:41Z tijl $ --> <refmeta> <refentrytitle>DLOPEN</refentrytitle> <manvolnum>3</manvolnum> </refmeta> <refnamediv xml:id='doclifter-purpose'> <refname>dlopen</refname> <!-- NB: Doclifter added a @GLUE@ token to the initial refname. That was removed, in this text. The following were transposed from the original dlopen.3 --> <refname>fdlopen</refname> <refname>dlsym</refname> <refname>dlfunc</refname> <refname>dlerror</refname> <refname>dlclose</refname> <refpurpose> programmatic interface to the dynamic linker </refpurpose> </refnamediv> <!-- body begins here --> <refsynopsisdiv xml:id='doclifter-synopsis'> <funcsynopsis> <funcsynopsisinfo> #include &lt;dlfcn.h&gt; </funcsynopsisinfo> <funcprototype> <funcdef>void *<function>dlopen</function></funcdef> <paramdef>const char * <parameter>path</parameter></paramdef> <paramdef>int <parameter>mode</parameter></paramdef> </funcprototype> <funcprototype> <funcdef>void *<function>fdlopen</function></funcdef> <paramdef>int <parameter>fd</parameter></paramdef> <paramdef>int <parameter>mode</parameter></paramdef> </funcprototype> <funcprototype> <funcdef>void *<function>dlsym</function></funcdef> <paramdef>void *restrict <parameter>handle</parameter></paramdef> <paramdef>const char *restrict <parameter>symbol</parameter></paramdef> </funcprototype> <funcprototype> <funcdef>dlfunc_t <function>dlfunc</function></funcdef> <paramdef>void *restrict <parameter>handle</parameter></paramdef> <paramdef>const char *restrict <parameter>symbol</parameter></paramdef> </funcprototype> <funcprototype> <funcdef>char *<function>dlerror</function></funcdef> <paramdef><parameter>void</parameter></paramdef> </funcprototype> <funcprototype> <funcdef>int <function>dlclose</function></funcdef> <paramdef>void * <parameter>handle</parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 xml:id='doclifter-library'><title>LIBRARY</title> <para><citetitle>Standard C Library (libc, -lc)</citetitle></para> </refsect1> <refsect1 xml:id='doclifter-description'><title>DESCRIPTION</title> <para>These functions provide a simple programmatic interface to the services of the dynamic linker. Operations are provided to add new shared objects to a program's address space, to obtain the address bindings of symbols defined by such objects, and to remove such objects when their use is no longer required.</para> <para>The dlopen(); function provides access to the shared object in <emphasis remap='Fa'>path</emphasis>, returning a descriptor that can be used for later references to the object in calls to dlsym(); and dlclose(.); If <emphasis remap='Fa'>path</emphasis> was not in the address space prior to the call to dlopen(,); it is placed in the address space. When an object is first loaded into the address space in this way, its function _init(,); if any, is called by the dynamic linker. If <emphasis remap='Fa'>path</emphasis> has already been placed in the address space in a previous call to dlopen(,); it is not added a second time, although a reference count of dlopen(); operations on <emphasis remap='Fa'>path</emphasis> is maintained. A null pointer supplied for <emphasis remap='Fa'>path</emphasis> is interpreted as a reference to the main executable of the process. The <emphasis remap='Fa'>mode</emphasis> argument controls the way in which external function references from the loaded object are bound to their referents. It must contain one of the following values, possibly ORed with additional flags which will be described subsequently:</para> <variablelist remap='Bl -tag -width RTLD_LAZYX'> <varlistentry> <term><constant>RTLD_LAZY</constant></term> <listitem> <para>Each external function reference is resolved when the function is first called.</para> </listitem> </varlistentry> <varlistentry> <term><constant>RTLD_NOW</constant></term> <listitem> <para>All external function references are bound immediately by dlopen(.);</para> </listitem> </varlistentry> </variablelist> <para><constant>RTLD_LAZY</constant> is normally preferred, for reasons of efficiency. However, <constant>RTLD_NOW</constant> is useful to ensure that any undefined symbols are discovered during the call to dlopen(.);</para> <para>One of the following flags may be ORed into the <emphasis remap='Fa'>mode</emphasis> argument:</para> <variablelist remap='Bl -tag -width RTLD_NODELETE'> <varlistentry> <term><constant>RTLD_GLOBAL</constant></term> <listitem> <para>Symbols from this shared object and its directed acyclic graph (DAG) of needed objects will be available for resolving undefined references from all other shared objects.</para> </listitem> </varlistentry> <varlistentry> <term><constant>RTLD_LOCAL</constant></term> <listitem> <para>Symbols in this shared object and its DAG of needed objects will be available for resolving undefined references only from other objects in the same DAG. This is the default, but it may be specified explicitly with this flag.</para> </listitem> </varlistentry> <varlistentry> <term><constant>RTLD_TRACE</constant></term> <listitem> <para>When set, causes dynamic linker to exit after loading all objects needed by this shared object and printing a summary which includes the absolute pathnames of all objects, to standard output. With this flag dlopen(); will return to the caller only in the case of error.</para> </listitem> </varlistentry> <varlistentry> <term><constant>RTLD_NODELETE</constant></term> <listitem> <para>Prevents unload of the loaded object on dlclose(.); The same behaviour may be requested by <option>-z nodelete</option> option of the static linker <citerefentry><refentrytitle>ld</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para> </listitem> </varlistentry> <varlistentry> <term><constant>RTLD_NOLOAD</constant></term> <listitem> <para>Only return valid handle for the object if it is already loaded in the process address space, otherwise <constant>NULL</constant> is returned. Other mode flags may be specified, which will be applied for promotion for the found object.</para> </listitem> </varlistentry> </variablelist> <para>If dlopen(); fails, it returns a null pointer, and sets an error condition which may be interrogated with dlerror(.);</para> <para>The fdlopen(); function is similar to dlopen(,); but it takes the file descriptor argument <emphasis remap='Fa'>fd</emphasis>, which is used for the file operations needed to load an object into the address space. The file descriptor <emphasis remap='Fa'>fd</emphasis> is not closed by the function regardless a result of execution, but a duplicate of the file descriptor is. This may be important if a <citerefentry><refentrytitle>lockf</refentrytitle><manvolnum>3</manvolnum></citerefentry> lock is held on the passed descriptor. The <emphasis remap='Fa'>fd</emphasis> argument -1 is interpreted as a reference to the main executable of the process, similar to <varname>NULL</varname> value for the <emphasis remap='Fa'>name</emphasis> argument to dlopen(.); The fdlopen(); function can be used by the code that needs to perform additional checks on the loaded objects, to prevent races with symlinking or renames.</para> <para>The dlsym(); function returns the address binding of the symbol described in the null-terminated character string <emphasis remap='Fa'>symbol</emphasis>, as it occurs in the shared object identified by <emphasis remap='Fa'>handle</emphasis>. The symbols exported by objects added to the address space by dlopen(); can be accessed only through calls to dlsym(.); Such symbols do not supersede any definition of those symbols already present in the address space when the object is loaded, nor are they available to satisfy normal dynamic linking references.</para> <para>If dlsym(); is called with the special <emphasis remap='Fa'>handle</emphasis> <constant>NULL</constant>, it is interpreted as a reference to the executable or shared object from which the call is being made. Thus a shared object can reference its own symbols.</para> <para>If dlsym(); is called with the special <emphasis remap='Fa'>handle</emphasis> <constant>RTLD_DEFAULT</constant>, the search for the symbol follows the algorithm used for resolving undefined symbols when objects are loaded. The objects searched are as follows, in the given order:</para> <orderedlist remap='Bl -enum'> <listitem> <para>The referencing object itself (or the object from which the call to dlsym(); is made), if that object was linked using the <option>-Bsymbolic</option> option to <citerefentry><refentrytitle>ld</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para> </listitem> <listitem> <para>All objects loaded at program start-up.</para> </listitem> <listitem> <para>All objects loaded via dlopen(); with the <constant>RTLD_GLOBAL</constant> flag set in the <emphasis remap='Fa'>mode</emphasis> argument.</para> </listitem> <listitem> <para>All objects loaded via dlopen(); which are in needed-object DAGs that also contain the referencing object.</para> </listitem> </orderedlist> <para>If dlsym(); is called with the special <emphasis remap='Fa'>handle</emphasis> <constant>RTLD_NEXT</constant>, then the search for the symbol is limited to the shared objects which were loaded after the one issuing the call to dlsym(.); Thus, if the function is called from the main program, all the shared libraries are searched. If it is called from a shared library, all subsequent shared libraries are searched. <constant>RTLD_NEXT</constant> is useful for implementing wrappers around library functions. For example, a wrapper function getpid(); could access the &ldquo;real&rdquo; getpid(); with <literal>dlsym(RTLD_NEXT,</literal> <literal>"getpid")</literal>. (Actually, the dlfunc(); interface, below, should be used, since getpid(); is a function and not a data object.)</para> <para>If dlsym(); is called with the special <emphasis remap='Fa'>handle</emphasis> <constant>RTLD_SELF</constant>, then the search for the symbol is limited to the shared object issuing the call to dlsym(); and those shared objects which were loaded after it.</para> <para>The dlsym(); function returns a null pointer if the symbol cannot be found, and sets an error condition which may be queried with dlerror(.);</para> <para>The dlfunc(); function implements all of the behavior of dlsym(,); but has a return type which can be cast to a function pointer without triggering compiler diagnostics. (The dlsym(); function returns a data pointer; in the C standard, conversions between data and function pointer types are undefined. Some compilers and <citerefentry><refentrytitle>lint</refentrytitle><manvolnum>1</manvolnum></citerefentry> utilities warn about such casts.) The precise return type of dlfunc(); is unspecified; applications must cast it to an appropriate function pointer type.</para> <para>The dlerror(); function returns a null-terminated character string describing the last error that occurred during a call to dlopen(,); dladdr(,); dlinfo(,); dlsym(,); dlfunc(,); or dlclose(.); If no such error has occurred, dlerror(); returns a null pointer. At each call to dlerror(,); the error indication is reset. Thus in the case of two calls to dlerror(,); where the second call follows the first immediately, the second call will always return a null pointer.</para> <para>The dlclose(); function deletes a reference to the shared object referenced by <emphasis remap='Fa'>handle</emphasis>. If the reference count drops to 0, the object is removed from the address space, and <emphasis remap='Fa'>handle</emphasis> is rendered invalid. Just before removing a shared object in this way, the dynamic linker calls the object's _fini(); function, if such a function is defined by the object. If dlclose(); is successful, it returns a value of 0. Otherwise it returns -1, and sets an error condition that can be interrogated with dlerror(.);</para> <para>The object-intrinsic functions _init(); and _fini(); are called with no arguments, and are not expected to return values.</para> </refsect1> <refsect1 xml:id='doclifter-notes'><title>NOTES</title> <para>ELF executables need to be linked using the <option>-export-dynamic</option> option to <citerefentry><refentrytitle>ld</refentrytitle><manvolnum>1</manvolnum></citerefentry> for symbols defined in the executable to become visible to dlsym(.);</para> <para>In previous implementations, it was necessary to prepend an underscore to all external symbols in order to gain symbol compatibility with object code compiled from the C language. This is still the case when using the (obsolete) <option>-aout</option> option to the C language compiler.</para> </refsect1> <refsect1 xml:id='doclifter-errors'><title>ERRORS</title> <para>The dlopen(,); fdlopen(,); dlsym(,); and dlfunc(); functions return a null pointer in the event of errors. The dlclose(); function returns 0 on success, or -1 if an error occurred. Whenever an error has been detected, a message detailing it can be retrieved via a call to dlerror(.);</para> </refsect1> <refsect1 xml:id='doclifter-see_also'><title>SEE ALSO</title> <para><citerefentry><refentrytitle>ld</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>rtld</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>dladdr</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>dlinfo</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>link</refentrytitle><manvolnum>5</manvolnum></citerefentry></para> </refsect1> </refentry>
15,473
Common Lisp
.l
455
32.8
103
0.793177
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
e78e7559e5c070c2e34ed18507271a8dbdf47f4629ad12afaff06da90b0c6724
29,373
[ -1 ]
29,374
dlinfo.3.xml
thinkum_ltp-main/doc/docbook/ltp-eo/dlinfo.3.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- lifted from mdoc+troff by doclifter --> <refentry xmlns='http://docbook.org/ns/docbook' version='5.0' xml:lang='en' xml:id='doclifter-dlinfo3'> <!-- Copyright (c) 2003 Alexey Zelkin &lt;[email protected]&gt; All rights reserved. --> <!-- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. --> <!-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> <!-- $FreeBSD: stable/11/lib/libc/gen/dlinfo.3 267774 2014&bsol;-06&bsol;-23 08:25:03Z bapt $ --> <refmeta> <refentrytitle>DLINFO</refentrytitle> <manvolnum>3</manvolnum> </refmeta> <refnamediv xml:id='doclifter-purpose'> <refname> dlinfo </refname> <refpurpose> information about dynamically loaded object </refpurpose> </refnamediv> <!-- body begins here --> <refsynopsisdiv xml:id='doclifter-synopsis'> <funcsynopsis> <funcsynopsisinfo> #include &lt;link.h&gt; #include &lt;dlfcn.h&gt; </funcsynopsisinfo> <funcprototype> <funcdef>int <function>dlinfo</function></funcdef> <paramdef>void *restrict <parameter>handle</parameter></paramdef> <paramdef>int <parameter>request</parameter></paramdef> <paramdef>void *restrict <parameter>p</parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 xml:id='doclifter-library'><title>LIBRARY</title> <para><citetitle>Standard C Library (libc, -lc)</citetitle></para> </refsect1> <refsect1 xml:id='doclifter-description'><title>DESCRIPTION</title> <para>The dlinfo(); function provides information about dynamically loaded object. The action taken by dlinfo(); and exact meaning and type of <emphasis remap='Fa'>p</emphasis> argument depend on value of the <emphasis remap='Fa'>request</emphasis> argument provided by caller.</para> <para>The <emphasis remap='Fa'>handle</emphasis> argument is either the value returned from the <citerefentry><refentrytitle>dlopen</refentrytitle><manvolnum>3</manvolnum></citerefentry> function call or special handle <constant>RTLD_SELF</constant>. If <emphasis remap='Fa'>handle</emphasis> is the value returned from <citerefentry><refentrytitle>dlopen</refentrytitle><manvolnum>3</manvolnum></citerefentry>, the information returned by the dlinfo(); function pertains to the specified object. If handle is the special handle <constant>RTLD_SELF</constant>, the information returned pertains to the caller itself.</para> <para>Possible values for the <emphasis remap='Fa'>request</emphasis> argument are:</para> <variablelist remap='Bl -tag -width indent'> <varlistentry> <term><constant>RTLD_DI_LINKMAP</constant></term> <listitem> <para>Retrieve the <type>Link_map</type> (Vt struct link_map) structure pointer for the specified <emphasis remap='Fa'>handle</emphasis>. On successful return, the <emphasis remap='Fa'>p</emphasis> argument is filled with the pointer to the <type>Link_map</type> structure (Fa Link_map **p) describing a shared object specified by the <emphasis remap='Fa'>handle</emphasis> argument. The <type>Link_map</type> structures are maintained as a doubly linked list by <citerefentry><refentrytitle>ld.so</refentrytitle><manvolnum>1</manvolnum></citerefentry>, in the same order as <citerefentry><refentrytitle>dlopen</refentrytitle><manvolnum>3</manvolnum></citerefentry> and <citerefentry><refentrytitle>dlclose</refentrytitle><manvolnum>3</manvolnum></citerefentry> are called. See <link role='Sx' linkend='doclifter-examples'>EXAMPLES</link>, example 1.</para> <para>The <type>Link_map</type> structure is defined in #include &lt;link.h&gt; and has the following members:</para> <programlisting remap='Bd'> caddr_t l_addr; /* Base Address of library */ const char *l_name; /* Absolute Path to Library */ const void *l_ld; /* Pointer to .dynamic in memory */ struct link_map *l_next, /* linked list of mapped libs */ *l_prev; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width .Va l_addr'> <varlistentry> <term><varname>l_addr</varname></term> <listitem> <para>The base address of the object loaded into memory.</para> </listitem> </varlistentry> <varlistentry> <term><varname>l_name</varname></term> <listitem> <para>The full name of the loaded shared object.</para> </listitem> </varlistentry> <varlistentry> <term><varname>l_ld</varname></term> <listitem> <para>The address of the dynamic linking information segment (Dv PT_DYNAMIC) loaded into memory.</para> </listitem> </varlistentry> <varlistentry> <term><varname>l_next</varname></term> <listitem> <para>The next <type>Link_map</type> structure on the link-map list.</para> </listitem> </varlistentry> <varlistentry> <term><varname>l_prev</varname></term> <listitem> <para>The previous <type>Link_map</type> structure on the link-map list.</para> </listitem> </varlistentry> </variablelist> </listitem> </varlistentry> <varlistentry> <term><constant>RTLD_DI_SERINFO</constant></term> <listitem> <para>Retrieve the library search paths associated with the given <emphasis remap='Fa'>handle</emphasis> argument. The <emphasis remap='Fa'>p</emphasis> argument should point to <type>Dl_serinfo</type> structure buffer (Fa Dl_serinfo *p). The <type>Dl_serinfo</type> structure must be initialized first with the <constant>RTLD_DI_SERINFOSIZE</constant> request.</para> <para>The returned <type>Dl_serinfo</type> structure contains <varname>dls_cnt</varname> <type>Dl_serpath</type> entries. Each entry's <varname>dlp_name</varname> field points to the search path. The corresponding <varname>dlp_info</varname> field contains one of more flags indicating the origin of the path (see the <constant>LA_SER_*</constant> flags defined in the #include &lt;link.h&gt; header file). See <link role='Sx' linkend='doclifter-examples'>EXAMPLES</link>, example 2, for a usage example.</para> </listitem> </varlistentry> <varlistentry> <term><constant>RTLD_DI_SERINFOSIZE</constant></term> <listitem> <para>Initialize a <type>Dl_serinfo</type> structure for use in a <constant>RTLD_DI_SERINFO</constant> request. Both the <varname>dls_cnt</varname> and <varname>dls_size</varname> fields are returned to indicate the number of search paths applicable to the handle, and the total size of a <type>Dl_serinfo</type> buffer required to hold <varname>dls_cnt</varname> <type>Dl_serpath</type> entries and the associated search path strings. See <link role='Sx' linkend='doclifter-examples'>EXAMPLES</link>, example 2, for a usage example.</para> </listitem> </varlistentry> <varlistentry> <term><varname>RTLD_DI_ORIGIN</varname></term> <listitem> <para>Retrieve the origin of the dynamic object associated with the handle. On successful return, <emphasis remap='Fa'>p</emphasis> argument is filled with the <type>char</type> pointer (Fa char *p).</para> </listitem> </varlistentry> </variablelist> </refsect1> <refsect1 xml:id='doclifter-return_values'><title>RETURN VALUES</title> <para>The dlinfo(); function returns 0 on success, or -1 if an error occurred. Whenever an error has been detected, a message detailing it can be retrieved via a call to <citerefentry><refentrytitle>dlerror</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para> </refsect1> <refsect1 xml:id='doclifter-examples'><title>EXAMPLES</title> <para>Example 1: Using dlinfo(); to retrieve <type>Link_map</type> structure.</para> <para>The following example shows how dynamic library can detect the list of shared libraries loaded after caller's one. For simplicity, error checking has been omitted.</para> <programlisting remap='Bd'> <funcsynopsis> <funcsynopsisinfo> Link_map *map; </funcsynopsisinfo> <funcprototype> <funcdef><function>dlinfo</function></funcdef> <paramdef><parameter>RTLD_SELF</parameter></paramdef> <paramdef><parameter>RTLD_DI_LINKMAP</parameter></paramdef> <paramdef><parameter>&amp;map</parameter></paramdef> </funcprototype> </funcsynopsis> while (map != NULL) { <funcsynopsis> <funcprototype> <funcdef><function>printf</function></funcdef> <paramdef>"%p: %s&bsol;n" <parameter></parameter></paramdef> <paramdef><parameter>map-&gt;l_addr</parameter></paramdef> <paramdef><parameter>map-&gt;l_name</parameter></paramdef> </funcprototype> <funcsynopsisinfo> map = map-&gt;l_next; </funcsynopsisinfo> </funcsynopsis> } </programlisting> <!-- remap='Ed (block)' --> <para>Example 2: Using dlinfo(); to retrieve the library search paths.</para> <para>The following example shows how a dynamic object can inspect the library search paths that would be used to locate a simple filename with <citerefentry><refentrytitle>dlopen</refentrytitle><manvolnum>3</manvolnum></citerefentry>. For simplicity, error checking has been omitted.</para> <programlisting remap='Bd'> <funcsynopsis> <funcsynopsisinfo> Dl_serinfo _info, *info = &amp;_info; Dl_serpath *path; unsigned int cnt; /* determine search path count and required buffer size */ </funcsynopsisinfo> <funcprototype> <funcdef><function>dlinfo</function></funcdef> <paramdef><parameter>RTLD_SELF</parameter></paramdef> <paramdef><parameter>RTLD_DI_SERINFOSIZE</parameter></paramdef> <paramdef>( void *) <parameter>info</parameter></paramdef> </funcprototype> <funcsynopsisinfo> /* allocate new buffer and initialize */ </funcsynopsisinfo> <funcsynopsisinfo> info = malloc(_info.dls_size); info-&gt;dls_size = _info.dls_size; info-&gt;dls_cnt = _info.dls_cnt; /* obtain sarch path information */ </funcsynopsisinfo> <funcprototype> <funcdef><function>dlinfo</function></funcdef> <paramdef><parameter>RTLD_SELF</parameter></paramdef> <paramdef><parameter>RTLD_DI_SERINFO</parameter></paramdef> <paramdef>( void *) <parameter>info</parameter></paramdef> </funcprototype> <funcsynopsisinfo> path = &amp;info-&gt;dls_serpath[0]; for (cnt = 1; cnt &lt;= info-&gt;dls_cnt; cnt++, path++) { </funcsynopsisinfo> <funcprototype> <funcdef>( void ) <function>printf</function></funcdef> <paramdef>"%2d: %s&bsol;n" <parameter></parameter></paramdef> <paramdef><parameter>cnt</parameter></paramdef> <paramdef><parameter>path-&gt;dls_name</parameter></paramdef> </funcprototype> </funcsynopsis> } </programlisting> <!-- remap='Ed (block)' --> <para><citerefentry><refentrytitle>rtld</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>dladdr</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>dlopen</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>dlsym</refentrytitle><manvolnum>3</manvolnum></citerefentry></para> </refsect1> <refsect1 xml:id='doclifter-history'><title>HISTORY</title> <para>The dlinfo(); function first appeared in the Solaris operating system. In <productname>FreeBSD ,</productname> it first appeared in <productname>FreeBSD 4.8</productname></para> </refsect1> <refsect1 xml:id='doclifter-authors'><title>AUTHORS</title> <para>phrase -nosplit role='author' The <productname>FreeBSD</productname> implementation of the dlinfo(); function was originally written by phrase Alexey Zelkin Aq Mt [email protected] role='author' and later extended and improved by phrase Alexander Kabaev Aq Mt [email protected] role='author'.</para> <para>The manual page for this function was written by phrase Alexey Zelkin Aq Mt [email protected] role='author'.</para> </refsect1> </refentry>
12,402
Common Lisp
.l
359
33.21727
103
0.77701
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
3f90185ff20a198d6ce331d850fce1c0f7559e1667b2eb67a7fa8688d7887051
29,374
[ -1 ]
29,375
dlfcn.castxml.xml
thinkum_ltp-main/doc/docbook/ltp-eo/dlfcn.castxml.xml
<?xml version="1.0"?> <CastXML format="1.1.4"> <Namespace id="_1" name="::" members="_2 _3 _4 _5 _6 _7 _8 _9 _10 _11 _12 _13 _14 _15 _16 _17 _18 _19 _20 _21 _22 _23 _24 _25 _26 _27 _28 _29 _30 _31 _32 _33 _34 _35 _36 _37 _38 _39 _40 _41 _42 _43 _44 _45 _46 _47 _48 _49 _50 _51 _52 _53 _54 _55 _56 _57 _58 _59 _60 _61 _62 _63 _64 _65 _66 _67 _68 _69 _70 _71 _72 _73 _74 _75 _76 _77 _78 _79 _80 _81 _82 _83 _84 _85 _86 _87 _88 _89 _90 _91 _92 _93 _94 _95 _96 _97 _98 _99 _100 _101 _102 _103 _104 _105 _106 _107 _108 _109 _110 _111 _112 _113 _114 _115"/> <Typedef id="_2" name="__int128_t" type="_116" context="_1" location="f0:0" file="f0" line="0"/> <Typedef id="_3" name="__uint128_t" type="_117" context="_1" location="f0:0" file="f0" line="0"/> <Typedef id="_4" name="__NSConstantString" type="_118" context="_1" location="f0:0" file="f0" line="0"/> <Typedef id="_5" name="__builtin_ms_va_list" type="_119" context="_1" location="f0:0" file="f0" line="0"/> <Typedef id="_6" name="__builtin_va_list" type="_120" context="_1" location="f0:0" file="f0" line="0"/> <Typedef id="_7" name="__int8_t" type="_121" context="_1" location="f1:53" file="f1" line="53"/> <Typedef id="_8" name="__uint8_t" type="_122" context="_1" location="f1:54" file="f1" line="54"/> <Typedef id="_9" name="__int16_t" type="_123" context="_1" location="f1:55" file="f1" line="55"/> <Typedef id="_10" name="__uint16_t" type="_124" context="_1" location="f1:56" file="f1" line="56"/> <Typedef id="_11" name="__int32_t" type="_125" context="_1" location="f1:57" file="f1" line="57"/> <Typedef id="_12" name="__uint32_t" type="_126" context="_1" location="f1:58" file="f1" line="58"/> <Typedef id="_13" name="__int64_t" type="_127" context="_1" location="f1:60" file="f1" line="60"/> <Typedef id="_14" name="__uint64_t" type="_128" context="_1" location="f1:61" file="f1" line="61"/> <Typedef id="_15" name="__clock_t" type="_11" context="_1" location="f1:79" file="f1" line="79"/> <Typedef id="_16" name="__critical_t" type="_13" context="_1" location="f1:80" file="f1" line="80"/> <Typedef id="_17" name="__double_t" type="_129" context="_1" location="f1:81" file="f1" line="81"/> <Typedef id="_18" name="__float_t" type="_130" context="_1" location="f1:82" file="f1" line="82"/> <Typedef id="_19" name="__intfptr_t" type="_13" context="_1" location="f1:83" file="f1" line="83"/> <Typedef id="_20" name="__intptr_t" type="_13" context="_1" location="f1:84" file="f1" line="84"/> <Typedef id="_21" name="__intmax_t" type="_13" context="_1" location="f1:93" file="f1" line="93"/> <Typedef id="_22" name="__int_fast8_t" type="_11" context="_1" location="f1:94" file="f1" line="94"/> <Typedef id="_23" name="__int_fast16_t" type="_11" context="_1" location="f1:95" file="f1" line="95"/> <Typedef id="_24" name="__int_fast32_t" type="_11" context="_1" location="f1:96" file="f1" line="96"/> <Typedef id="_25" name="__int_fast64_t" type="_13" context="_1" location="f1:97" file="f1" line="97"/> <Typedef id="_26" name="__int_least8_t" type="_7" context="_1" location="f1:98" file="f1" line="98"/> <Typedef id="_27" name="__int_least16_t" type="_9" context="_1" location="f1:99" file="f1" line="99"/> <Typedef id="_28" name="__int_least32_t" type="_11" context="_1" location="f1:100" file="f1" line="100"/> <Typedef id="_29" name="__int_least64_t" type="_13" context="_1" location="f1:101" file="f1" line="101"/> <Typedef id="_30" name="__ptrdiff_t" type="_13" context="_1" location="f1:103" file="f1" line="103"/> <Typedef id="_31" name="__register_t" type="_13" context="_1" location="f1:104" file="f1" line="104"/> <Typedef id="_32" name="__segsz_t" type="_13" context="_1" location="f1:105" file="f1" line="105"/> <Typedef id="_33" name="__size_t" type="_14" context="_1" location="f1:106" file="f1" line="106"/> <Typedef id="_34" name="__ssize_t" type="_13" context="_1" location="f1:107" file="f1" line="107"/> <Typedef id="_35" name="__time_t" type="_13" context="_1" location="f1:108" file="f1" line="108"/> <Typedef id="_36" name="__uintfptr_t" type="_14" context="_1" location="f1:109" file="f1" line="109"/> <Typedef id="_37" name="__uintptr_t" type="_14" context="_1" location="f1:110" file="f1" line="110"/> <Typedef id="_38" name="__uintmax_t" type="_14" context="_1" location="f1:121" file="f1" line="121"/> <Typedef id="_39" name="__uint_fast8_t" type="_12" context="_1" location="f1:122" file="f1" line="122"/> <Typedef id="_40" name="__uint_fast16_t" type="_12" context="_1" location="f1:123" file="f1" line="123"/> <Typedef id="_41" name="__uint_fast32_t" type="_12" context="_1" location="f1:124" file="f1" line="124"/> <Typedef id="_42" name="__uint_fast64_t" type="_14" context="_1" location="f1:125" file="f1" line="125"/> <Typedef id="_43" name="__uint_least8_t" type="_8" context="_1" location="f1:126" file="f1" line="126"/> <Typedef id="_44" name="__uint_least16_t" type="_10" context="_1" location="f1:127" file="f1" line="127"/> <Typedef id="_45" name="__uint_least32_t" type="_12" context="_1" location="f1:128" file="f1" line="128"/> <Typedef id="_46" name="__uint_least64_t" type="_14" context="_1" location="f1:129" file="f1" line="129"/> <Typedef id="_47" name="__u_register_t" type="_14" context="_1" location="f1:131" file="f1" line="131"/> <Typedef id="_48" name="__vm_offset_t" type="_14" context="_1" location="f1:132" file="f1" line="132"/> <Typedef id="_49" name="__vm_paddr_t" type="_14" context="_1" location="f1:133" file="f1" line="133"/> <Typedef id="_50" name="__vm_size_t" type="_14" context="_1" location="f1:134" file="f1" line="134"/> <Typedef id="_51" name="___wchar_t" type="_125" context="_1" location="f1:145" file="f1" line="145"/> <Typedef id="_52" name="__va_list" type="_6" context="_1" location="f1:154" file="f1" line="154"/> <Typedef id="_53" name="__gnuc_va_list" type="_52" context="_1" location="f1:169" file="f1" line="169"/> <Typedef id="_54" name="__blksize_t" type="_11" context="_1" location="f2:38" file="f2" line="38"/> <Typedef id="_55" name="__blkcnt_t" type="_13" context="_1" location="f2:39" file="f2" line="39"/> <Typedef id="_56" name="__clockid_t" type="_11" context="_1" location="f2:40" file="f2" line="40"/> <Typedef id="_57" name="__fflags_t" type="_12" context="_1" location="f2:41" file="f2" line="41"/> <Typedef id="_58" name="__fsblkcnt_t" type="_14" context="_1" location="f2:42" file="f2" line="42"/> <Typedef id="_59" name="__fsfilcnt_t" type="_14" context="_1" location="f2:43" file="f2" line="43"/> <Typedef id="_60" name="__gid_t" type="_12" context="_1" location="f2:44" file="f2" line="44"/> <Typedef id="_61" name="__id_t" type="_13" context="_1" location="f2:45" file="f2" line="45"/> <Typedef id="_62" name="__ino_t" type="_12" context="_1" location="f2:46" file="f2" line="46"/> <Typedef id="_63" name="__key_t" type="_127" context="_1" location="f2:47" file="f2" line="47"/> <Typedef id="_64" name="__lwpid_t" type="_11" context="_1" location="f2:48" file="f2" line="48"/> <Typedef id="_65" name="__mode_t" type="_10" context="_1" location="f2:49" file="f2" line="49"/> <Typedef id="_66" name="__accmode_t" type="_125" context="_1" location="f2:50" file="f2" line="50"/> <Typedef id="_67" name="__nl_item" type="_125" context="_1" location="f2:51" file="f2" line="51"/> <Typedef id="_68" name="__nlink_t" type="_10" context="_1" location="f2:52" file="f2" line="52"/> <Typedef id="_69" name="__off_t" type="_13" context="_1" location="f2:53" file="f2" line="53"/> <Typedef id="_70" name="__off64_t" type="_13" context="_1" location="f2:54" file="f2" line="54"/> <Typedef id="_71" name="__pid_t" type="_11" context="_1" location="f2:55" file="f2" line="55"/> <Typedef id="_72" name="__rlim_t" type="_13" context="_1" location="f2:56" file="f2" line="56"/> <Typedef id="_73" name="__sa_family_t" type="_8" context="_1" location="f2:59" file="f2" line="59"/> <Typedef id="_74" name="__socklen_t" type="_12" context="_1" location="f2:60" file="f2" line="60"/> <Typedef id="_75" name="__suseconds_t" type="_127" context="_1" location="f2:61" file="f2" line="61"/> <Struct id="_76" name="__timer" context="_1" location="f2:62" file="f2" line="62" incomplete="1"/> <Typedef id="_77" name="__timer_t" type="_131" context="_1" location="f2:62" file="f2" line="62"/> <Struct id="_78" name="__mq" context="_1" location="f2:63" file="f2" line="63" incomplete="1"/> <Typedef id="_79" name="__mqd_t" type="_132" context="_1" location="f2:63" file="f2" line="63"/> <Typedef id="_80" name="__uid_t" type="_12" context="_1" location="f2:64" file="f2" line="64"/> <Typedef id="_81" name="__useconds_t" type="_126" context="_1" location="f2:65" file="f2" line="65"/> <Typedef id="_82" name="__cpuwhich_t" type="_125" context="_1" location="f2:66" file="f2" line="66"/> <Typedef id="_83" name="__cpulevel_t" type="_125" context="_1" location="f2:67" file="f2" line="67"/> <Typedef id="_84" name="__cpusetid_t" type="_125" context="_1" location="f2:68" file="f2" line="68"/> <Typedef id="_85" name="__ct_rune_t" type="_125" context="_1" location="f2:88" file="f2" line="88"/> <Typedef id="_86" name="__rune_t" type="_85" context="_1" location="f2:89" file="f2" line="89"/> <Typedef id="_87" name="__wint_t" type="_85" context="_1" location="f2:90" file="f2" line="90"/> <Typedef id="_88" name="__char16_t" type="_44" context="_1" location="f2:94" file="f2" line="94"/> <Typedef id="_89" name="__char32_t" type="_45" context="_1" location="f2:95" file="f2" line="95"/> <Struct id="_90" name="" context="_1" location="f2:103" file="f2" line="103" members="_133 _134" size="256" align="128"/> <Typedef id="_91" name="__max_align_t" type="_135" context="_1" location="f2:106" file="f2" line="106"/> <Typedef id="_92" name="__dev_t" type="_12" context="_1" location="f2:108" file="f2" line="108"/> <Typedef id="_93" name="__fixpt_t" type="_12" context="_1" location="f2:110" file="f2" line="110"/> <Union id="_94" name="" context="_1" location="f2:116" file="f2" line="116" members="_136 _137" size="1024" align="64"/> <Typedef id="_95" name="__mbstate_t" type="_138" context="_1" location="f2:119" file="f2" line="119"/> <Typedef id="_96" name="__rman_res_t" type="_38" context="_1" location="f2:121" file="f2" line="121"/> <Typedef id="_97" name="size_t" type="_33" context="_1" location="f3:68" file="f3" line="68"/> <Struct id="_98" name="dl_info" context="_1" location="f3:75" file="f3" line="75" members="_139 _140 _141 _142" size="256" align="64"/> <Typedef id="_99" name="Dl_info" type="_143" context="_1" location="f3:80" file="f3" line="80"/> <Struct id="_100" name="__dlfunc_arg" context="_1" location="f3:91" file="f3" line="91" members="_144" size="32" align="32"/> <Typedef id="_101" name="dlfunc_t" type="_145" context="_1" location="f3:95" file="f3" line="95"/> <Struct id="_102" name="dl_serpath" context="_1" location="f3:100" file="f3" line="100" members="_146 _147" size="128" align="64"/> <Typedef id="_103" name="Dl_serpath" type="_148" context="_1" location="f3:103" file="f3" line="103"/> <Struct id="_104" name="dl_serinfo" context="_1" location="f3:105" file="f3" line="105" members="_149 _150 _151" size="256" align="64"/> <Typedef id="_105" name="Dl_serinfo" type="_152" context="_1" location="f3:109" file="f3" line="109"/> <Function id="_106" name="dlclose" returns="_125" context="_1" location="f3:115" file="f3" line="115" mangled="_Z7dlclose"> <Argument type="_153" location="f3:115" file="f3" line="115"/> </Function> <Function id="_107" name="dlerror" returns="_119" context="_1" location="f3:116" file="f3" line="116" mangled="_Z7dlerror"/> <Function id="_108" name="dlopen" returns="_153" context="_1" location="f3:117" file="f3" line="117" mangled="_Z6dlopen"> <Argument type="_154" location="f3:117" file="f3" line="117"/> <Argument type="_125" location="f3:117" file="f3" line="117"/> </Function> <Function id="_109" name="dlsym" returns="_153" context="_1" location="f3:118" file="f3" line="118" mangled="_Z5dlsym"> <Argument type="_153r" location="f3:118" file="f3" line="118"/> <Argument type="_154r" location="f3:118" file="f3" line="118"/> </Function> <Function id="_110" name="fdlopen" returns="_153" context="_1" location="f3:121" file="f3" line="121" mangled="_Z7fdlopen"> <Argument type="_125" location="f3:121" file="f3" line="121"/> <Argument type="_125" location="f3:121" file="f3" line="121"/> </Function> <Function id="_111" name="dladdr" returns="_125" context="_1" location="f3:122" file="f3" line="122" mangled="_Z6dladdr"> <Argument type="_155r" location="f3:122" file="f3" line="122"/> <Argument type="_156r" location="f3:122" file="f3" line="122"/> </Function> <Function id="_112" name="dlfunc" returns="_101" context="_1" location="f3:123" file="f3" line="123" mangled="_Z6dlfunc"> <Argument type="_153r" location="f3:123" file="f3" line="123"/> <Argument type="_154r" location="f3:123" file="f3" line="123"/> </Function> <Function id="_113" name="dlinfo" returns="_125" context="_1" location="f3:124" file="f3" line="124" mangled="_Z6dlinfo"> <Argument type="_153r" location="f3:124" file="f3" line="124"/> <Argument type="_125" location="f3:124" file="f3" line="124"/> <Argument type="_153r" location="f3:124" file="f3" line="124"/> </Function> <Function id="_114" name="dllockinit" returns="_157" context="_1" location="f3:125" file="f3" line="125" mangled="_Z10dllockinit"> <Argument name="_context" type="_153" location="f3:125" file="f3" line="125"/> <Argument name="_lock_create" type="_158" location="f3:126" file="f3" line="126"/> <Argument name="_rlock_acquire" type="_159" location="f3:127" file="f3" line="127"/> <Argument name="_wlock_acquire" type="_159" location="f3:128" file="f3" line="128"/> <Argument name="_lock_release" type="_159" location="f3:129" file="f3" line="129"/> <Argument name="_lock_destroy" type="_159" location="f3:130" file="f3" line="130"/> <Argument name="_context_destroy" type="_159" location="f3:131" file="f3" line="131"/> </Function> <Function id="_115" name="dlvsym" returns="_153" context="_1" location="f3:132" file="f3" line="132" mangled="_Z6dlvsym"> <Argument type="_153r" location="f3:132" file="f3" line="132"/> <Argument type="_154r" location="f3:132" file="f3" line="132"/> <Argument type="_154r" location="f3:133" file="f3" line="133"/> </Function> <FundamentalType id="_116" name="__int128" size="128" align="128"/> <FundamentalType id="_117" name="unsigned __int128" size="128" align="128"/> <Struct id="_118" name="__NSConstantString_tag" context="_1" location="f0:0" file="f0" line="0" members="_160 _161 _162 _163" size="256" align="64"/> <PointerType id="_119" type="_164" size="64" align="64"/> <ArrayType id="_120" min="0" max="0" type="_165"/> <FundamentalType id="_121" name="signed char" size="8" align="8"/> <FundamentalType id="_122" name="unsigned char" size="8" align="8"/> <FundamentalType id="_123" name="short int" size="16" align="16"/> <FundamentalType id="_124" name="short unsigned int" size="16" align="16"/> <FundamentalType id="_125" name="int" size="32" align="32"/> <FundamentalType id="_126" name="unsigned int" size="32" align="32"/> <FundamentalType id="_127" name="long int" size="64" align="64"/> <FundamentalType id="_128" name="long unsigned int" size="64" align="64"/> <FundamentalType id="_129" name="double" size="64" align="64"/> <FundamentalType id="_130" name="float" size="32" align="32"/> <PointerType id="_131" type="_166" size="64" align="64"/> <PointerType id="_132" type="_167" size="64" align="64"/> <Field id="_133" name="__max_align1" type="_168" context="_90" access="public" location="f2:104" file="f2" line="104" offset="0"/> <Field id="_134" name="__max_align2" type="_169" context="_90" access="public" location="f2:105" file="f2" line="105" offset="128"/> <ElaboratedType id="_135" type="_90"/> <Field id="_136" name="__mbstate8" type="_170" context="_94" access="public" location="f2:117" file="f2" line="117" offset="0"/> <Field id="_137" name="_mbstateL" type="_13" context="_94" access="public" location="f2:118" file="f2" line="118" offset="0"/> <ElaboratedType id="_138" type="_94"/> <Field id="_139" name="dli_fname" type="_154" context="_98" access="public" location="f3:76" file="f3" line="76" offset="0"/> <Field id="_140" name="dli_fbase" type="_153" context="_98" access="public" location="f3:77" file="f3" line="77" offset="64"/> <Field id="_141" name="dli_sname" type="_154" context="_98" access="public" location="f3:78" file="f3" line="78" offset="128"/> <Field id="_142" name="dli_saddr" type="_153" context="_98" access="public" location="f3:79" file="f3" line="79" offset="192"/> <ElaboratedType id="_143" type="_98"/> <Field id="_144" name="__dlfunc_dummy" type="_125" context="_100" access="public" location="f3:92" file="f3" line="92" offset="0"/> <PointerType id="_145" type="_171" size="64" align="64"/> <Field id="_146" name="dls_name" type="_119" context="_102" access="public" location="f3:101" file="f3" line="101" offset="0"/> <Field id="_147" name="dls_flags" type="_126" context="_102" access="public" location="f3:102" file="f3" line="102" offset="64"/> <ElaboratedType id="_148" type="_102"/> <Field id="_149" name="dls_size" type="_97" context="_104" access="public" location="f3:106" file="f3" line="106" offset="0"/> <Field id="_150" name="dls_cnt" type="_126" context="_104" access="public" location="f3:107" file="f3" line="107" offset="64"/> <Field id="_151" name="dls_serpath" type="_172" context="_104" access="public" location="f3:108" file="f3" line="108" offset="128"/> <ElaboratedType id="_152" type="_104"/> <PointerType id="_153" type="_157" size="64" align="64"/> <CvQualifiedType id="_153r" type="_153" restrict="1"/> <PointerType id="_154" type="_164c" size="64" align="64"/> <CvQualifiedType id="_154r" type="_154" restrict="1"/> <PointerType id="_155" type="_157c" size="64" align="64"/> <CvQualifiedType id="_155r" type="_155" restrict="1"/> <PointerType id="_156" type="_99" size="64" align="64"/> <CvQualifiedType id="_156r" type="_156" restrict="1"/> <FundamentalType id="_157" name="void" size="0" align="8"/> <CvQualifiedType id="_157c" type="_157" const="1"/> <PointerType id="_158" type="_173" size="64" align="64"/> <PointerType id="_159" type="_174" size="64" align="64"/> <Field id="_160" name="isa" type="_175" context="_118" access="public" offset="0"/> <Field id="_161" name="flags" type="_125" context="_118" access="public" offset="64"/> <Field id="_162" name="str" type="_154" context="_118" access="public" offset="128"/> <Field id="_163" name="length" type="_127" context="_118" access="public" offset="192"/> <CvQualifiedType id="_164c" type="_164" const="1"/> <Struct id="_165" name="__va_list_tag" context="_1" location="f0:0" file="f0" line="0" members="_176 _177 _178 _179" size="192" align="64"/> <FundamentalType id="_168" name="long long int" size="64" align="64"/> <FundamentalType id="_169" name="long double" size="128" align="128"/> <ArrayType id="_170" min="0" max="127" type="_164"/> <FundamentalType id="_164" name="char" size="8" align="8"/> <ArrayType id="_172" min="0" max="0" type="_103"/> <PointerType id="_175" type="_125c" size="64" align="64"/> <CvQualifiedType id="_125c" type="_125" const="1"/> <Field id="_176" name="gp_offset" type="_126" context="_165" access="public" offset="0"/> <Field id="_177" name="fp_offset" type="_126" context="_165" access="public" offset="32"/> <Field id="_178" name="overflow_arg_area" type="_153" context="_165" access="public" offset="64"/> <Field id="_179" name="reg_save_area" type="_153" context="_165" access="public" offset="128"/> <ElaboratedType id="_166" type="_76"/> <ElaboratedType id="_167" type="_78"/> <FunctionType id="_171" returns="_157"> <Argument type="_180"/> </FunctionType> <FunctionType id="_173" returns="_153"> <Argument type="_153"/> </FunctionType> <FunctionType id="_174" returns="_157"> <Argument type="_153"/> </FunctionType> <ElaboratedType id="_180" type="_100"/> <File id="f0" name="&lt;builtin&gt;"/> <File id="f1" name="/usr/include/x86/_types.h"/> <File id="f2" name="/usr/include/sys/_types.h"/> <File id="f3" name="/usr/include/dlfcn.h"/> </CastXML>
20,541
Common Lisp
.l
233
84.95279
506
0.619805
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
61c462b31f85f9d9251797977b2123f5fc02c5827d169e3aeed37af30aca70f8
29,375
[ -1 ]
29,376
dladdr.3.xml
thinkum_ltp-main/doc/docbook/ltp-eo/dladdr.3.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- lifted from mdoc+troff by doclifter --> <refentry xmlns='http://docbook.org/ns/docbook' version='5.0' xml:lang='en' xml:id='doclifter-dladdr3'> <!-- Copyright (c) 1998 John D. Polstra All rights reserved. --> <!-- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. --> <!-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> <!-- $FreeBSD: stable/11/lib/libc/gen/dladdr.3 206622 2010&bsol;-04&bsol;-14 19:08:06Z uqs $ --> <refmeta> <refentrytitle>DLADDR</refentrytitle> <manvolnum>3</manvolnum> </refmeta> <refnamediv xml:id='doclifter-purpose'> <refname> dladdr </refname> <refpurpose> find the shared object containing a given address </refpurpose> </refnamediv> <!-- body begins here --> <refsynopsisdiv xml:id='doclifter-synopsis'> <funcsynopsis> <funcsynopsisinfo> #include &lt;dlfcn.h&gt; </funcsynopsisinfo> <funcprototype> <funcdef>int <function>dladdr</function></funcdef> <paramdef>const void * <parameter>addr</parameter></paramdef> <paramdef>Dl_info * <parameter>info</parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 xml:id='doclifter-library'><title>LIBRARY</title> <para><citetitle>Standard C Library (libc, -lc)</citetitle></para> </refsect1> <refsect1 xml:id='doclifter-description'><title>DESCRIPTION</title> <para>The dladdr(); function queries the dynamic linker for information about the shared object containing the address <emphasis remap='Fa'>addr</emphasis>. The information is returned in the structure specified by <emphasis remap='Fa'>info</emphasis>. The structure contains at least the following members:</para> <variablelist remap='Bl -tag -width XXXconst char *dli_fname'> <varlistentry> <term><literal>const char *dli_fname</literal></term> <listitem> <para>The pathname of the shared object containing the address.</para> </listitem> </varlistentry> <varlistentry> <term><literal>void *dli_fbase</literal></term> <listitem> <para>The base address at which the shared object is mapped into the address space of the calling process.</para> </listitem> </varlistentry> <varlistentry> <term><literal>const char *dli_sname</literal></term> <listitem> <para>The name of the nearest run-time symbol with a value less than or equal to <emphasis remap='Fa'>addr</emphasis>. When possible, the symbol name is returned as it would appear in C source code.</para> <para>If no symbol with a suitable value is found, both this field and <varname>dli_saddr</varname> are set to <constant>NULL</constant>.</para> </listitem> </varlistentry> <varlistentry> <term><literal>void *dli_saddr</literal></term> <listitem> <para>The value of the symbol returned in <literal>dli_sname</literal>.</para> </listitem> </varlistentry> </variablelist> <para>The dladdr(); function is available only in dynamically linked programs.</para> </refsect1> <refsect1 xml:id='doclifter-errors'><title>ERRORS</title> <para>If a mapped shared object containing <emphasis remap='Fa'>addr</emphasis> cannot be found, dladdr(); returns 0. In that case, a message detailing the failure can be retrieved by calling dlerror(.);</para> <para>On success, a non-zero value is returned.</para> </refsect1> <refsect1 xml:id='doclifter-see_also'><title>SEE ALSO</title> <para><citerefentry><refentrytitle>rtld</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>dlopen</refentrytitle><manvolnum>3</manvolnum></citerefentry></para> </refsect1> <refsect1 xml:id='doclifter-history'><title>HISTORY</title> <para>The dladdr(); function first appeared in the Solaris operating system.</para> </refsect1> <refsect1 xml:id='doclifter-bugs'><title>BUGS</title> <para>This implementation is bug-compatible with the Solaris implementation. In particular, the following bugs are present:</para> <itemizedlist remap='Bl -bullet' mark='bullet'> <listitem> <para>If <emphasis remap='Fa'>addr</emphasis> lies in the main executable rather than in a shared library, the pathname returned in <varname>dli_fname</varname> may not be correct. The pathname is taken directly from <varname>argv[0]</varname> of the calling process. When executing a program specified by its full pathname, most shells set <varname>argv[0]</varname> to the pathname. But this is not required of shells or guaranteed by the operating system.</para> </listitem> <listitem> <para>If <emphasis remap='Fa'>addr</emphasis> is of the form <varname>&amp;func</varname>, where <varname>func</varname> is a global function, its value may be an unpleasant surprise. In dynamically linked programs, the address of a global function is considered to point to its program linkage table entry, rather than to the entry point of the function itself. This causes most global functions to appear to be defined within the main executable, rather than in the shared libraries where the actual code resides.</para> </listitem> <listitem> <para>Returning 0 as an indication of failure goes against long-standing Unix tradition.</para> </listitem> </itemizedlist> </refsect1> </refentry>
6,163
Common Lisp
.l
165
36.187879
103
0.789764
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
4e464c2407450745de7030d32cd8bbff2beb006313c6d13cd24625467eb1dbab
29,376
[ -1 ]
29,377
link.5.xml
thinkum_ltp-main/doc/docbook/ltp-eo/link.5.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- lifted from mdoc+troff by doclifter --> <refentry xmlns='http://docbook.org/ns/docbook' version='5.0' xml:lang='en' xml:id='doclifter-link5'> <!-- Copyright (c) 1993 Paul Kranenburg All rights reserved. --> <!-- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by Paul Kranenburg. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission --> <!-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> <!-- $FreeBSD: stable/11/share/man/man5/link.5 213573 2010&bsol;-10&bsol;-08 12:40:16Z uqs $ --> <refmeta> <refentrytitle>LINK</refentrytitle> <manvolnum>5</manvolnum> </refmeta> <refnamediv xml:id='doclifter-purpose'> <refname> link </refname> <refpurpose> dynamic loader and link editor interface </refpurpose> </refnamediv> <!-- body begins here --> <refsynopsisdiv xml:id='doclifter-synopsis'> <funcsynopsis> <funcsynopsisinfo> #include &lt;sys/types.h&gt; #include &lt;nlist.h&gt; #include &lt;link.h&gt; </funcsynopsisinfo> </funcsynopsis> </refsynopsisdiv> <refsect1 xml:id='doclifter-description'><title>DESCRIPTION</title> <para>The include file #include &lt;link.h&gt; declares several structures that are present in dynamically linked programs and libraries. The structures define the interface between several components of the link-editor and loader mechanism. The layout of a number of these structures within the binaries resembles the a.out format in many places as it serves such similar functions as symbol definitions (including the accompanying string table) and relocation records needed to resolve references to external entities. It also records a number of data structures unique to the dynamic loading and linking process. These include references to other objects that are required to complete the link-editing process and indirection tables to facilitate <emphasis remap='Em'>Position</emphasis> <emphasis remap='Em'>Independent</emphasis> <emphasis remap='Em'>Code</emphasis> (PIC for short) to improve sharing of code pages among different processes. The collection of data structures described here will be referred to as the <emphasis remap='Em'>Run-time</emphasis> <emphasis remap='Em'>Relocation</emphasis> <emphasis remap='Em'>Section</emphasis> <emphasis remap='Em'>(RRS)</emphasis> and is embedded in the standard text and data segments of the dynamically linked program or shared object image as the existing <citerefentry><refentrytitle>a.out</refentrytitle><manvolnum>5</manvolnum></citerefentry> format offers no room for it elsewhere.</para> <para>Several utilities cooperate to ensure that the task of getting a program ready to run can complete successfully in a way that optimizes the use of system resources. The compiler emits PIC code from which shared libraries can be built by <citerefentry><refentrytitle>ld</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The compiler also includes size information of any initialized data items through the .size assembler directive. PIC code differs from conventional code in that it accesses data variables through an indirection table, the Global Offset Table, by convention accessible by the reserved name <constant>_GLOBAL_OFFSET_TABLE_</constant>. The exact mechanism used for this is machine dependent, usually a machine register is reserved for the purpose. The rational behind this construct is to generate code that is independent of the actual load address. Only the values contained in the Global Offset Table may need updating at run-time depending on the load addresses of the various shared objects in the address space.</para> <para>Likewise, procedure calls to globally defined functions are redirected through the Procedure Linkage Table (PLT) residing in the data segment of the core image. Again, this is done to avoid run-time modifications to the text segment.</para> <para>The linker-editor allocates the Global Offset Table and Procedure Linkage Table when combining PIC object files into an image suitable for mapping into the process address space. It also collects all symbols that may be needed by the run-time link-editor and stores these along with the image's text and data bits. Another reserved symbol, <emphasis remap='Em'>_DYNAMIC</emphasis> is used to indicate the presence of the run-time linker structures. Whenever _DYNAMIC is relocated to 0, there is no need to invoke the run-time link-editor. If this symbol is non-zero, it points at a data structure from which the location of the necessary relocation- and symbol information can be derived. This is most notably used by the start-up module, <emphasis remap='Em'>crt0</emphasis>. The _DYNAMIC structure is conventionally located at the start of the data segment of the image to which it pertains.</para> </refsect1> <refsect1 xml:id='doclifter-data_structures'><title>DATA STRUCTURES</title> <para>The data structures supporting dynamic linking and run-time relocation reside both in the text and data segments of the image they apply to. The text segments contain read-only data such as symbols descriptions and names, while the data segments contain the tables that need to be modified by during the relocation process.</para> <para>The _DYNAMIC symbol references a <emphasis remap='Fa'>_dynamic</emphasis> structure:</para> <programlisting remap='Bd'> struct _dynamic { int d_version; struct so_debug *d_debug; union { struct section_dispatch_table *d_sdt; } d_un; struct ld_entry *d_entry; }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width d_version'> <varlistentry> <term><emphasis remap='Fa'>d_version</emphasis></term> <listitem> <para>This field provides for different versions of the dynamic linking implementation. The current version numbers understood by <citerefentry><refentrytitle>ld</refentrytitle><manvolnum>1</manvolnum></citerefentry> and <citerefentry><refentrytitle>ld.so</refentrytitle><manvolnum>1</manvolnum></citerefentry> are <emphasis remap='Em'>LD_VERSION_SUN</emphasis> <emphasis remap='Em'>(3)</emphasis>, which is used by the <phrase remap='Tn'>SunOS</phrase> 4.x releases, and <emphasis remap='Em'>LD_VERSION_BSD</emphasis> <emphasis remap='Em'>(8)</emphasis>, which has been in use since <productname>FreeBSD 1.1</productname></para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>d_un</emphasis></term> <listitem> <para>Refers to a <emphasis remap='Em'>d_version</emphasis> dependent data structure.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>so_debug</emphasis></term> <listitem> <para>this field provides debuggers with a hook to access symbol tables of shared objects loaded as a result of the actions of the run-time link-editor.</para> </listitem> </varlistentry> </variablelist> <para>The <emphasis remap='Fa'>section_dispatch_table</emphasis> structure is the main &ldquo;dispatcher&rdquo; table, containing offsets into the image's segments where various symbol and relocation information is located.</para> <programlisting remap='Bd'> struct section_dispatch_table { struct so_map *sdt_loaded; long sdt_sods; long sdt_filler1; long sdt_got; long sdt_plt; long sdt_rel; long sdt_hash; long sdt_nzlist; long sdt_filler2; long sdt_buckets; long sdt_strings; long sdt_str_sz; long sdt_text_sz; long sdt_plt_sz; }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width sdt_filler1'> <varlistentry> <term><emphasis remap='Fa'>sdt_loaded</emphasis></term> <listitem> <para>A pointer to the first link map loaded (see below). This field is set by <command remap='Nm'> link </command></para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_sods</emphasis></term> <listitem> <para>The start of a (linked) list of shared object descriptors needed by <emphasis remap='Em'>this</emphasis> object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_filler1</emphasis></term> <listitem> <para>Deprecated (used by SunOS to specify library search rules).</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_got</emphasis></term> <listitem> <para>The location of the Global Offset Table within this image.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_plt</emphasis></term> <listitem> <para>The location of the Procedure Linkage Table within this image.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_rel</emphasis></term> <listitem> <para>The location of an array of <emphasis remap='Fa'>relocation_info</emphasis> structures (see <citerefentry><refentrytitle>a.out</refentrytitle><manvolnum>5</manvolnum></citerefentry>) specifying run-time relocations.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_hash</emphasis></term> <listitem> <para>The location of the hash table for fast symbol lookup in this object's symbol table.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_nzlist</emphasis></term> <listitem> <para>The location of the symbol table.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_filler2</emphasis></term> <listitem> <para>Currently unused.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_buckets</emphasis></term> <listitem> <para>The number of buckets in <emphasis remap='Fa'>sdt_hash</emphasis></para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_strings</emphasis></term> <listitem> <para>The location of the symbol string table that goes with <emphasis remap='Fa'>sdt_nzlist</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_str_sz</emphasis></term> <listitem> <para>The size of the string table.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_text_sz</emphasis></term> <listitem> <para>The size of the object's text segment.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sdt_plt_sz</emphasis></term> <listitem> <para>The size of the Procedure Linkage Table.</para> </listitem> </varlistentry> </variablelist> <para>A <emphasis remap='Fa'>sod</emphasis> structure describes a shared object that is needed to complete the link edit process of the object containing it. A list of such objects (chained through <emphasis remap='Fa'>sod_next</emphasis>) is pointed at by the <emphasis remap='Fa'>sdt_sods</emphasis> in the section_dispatch_table structure.</para> <programlisting remap='Bd'> struct sod { long sod_name; u_int sod_library : 1, sod_reserved : 31; short sod_major; short sod_minor; long sod_next; }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width sod_library'> <varlistentry> <term><emphasis remap='Fa'>sod_name</emphasis></term> <listitem> <para>The offset in the text segment of a string describing this link object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sod_library</emphasis></term> <listitem> <para>If set, <emphasis remap='Fa'>sod_name</emphasis> specifies a library that is to be searched for by <command remap='Nm'> link </command> The path name is obtained by searching a set of directories (see also <citerefentry><refentrytitle>ldconfig</refentrytitle><manvolnum>8</manvolnum></citerefentry>) for a shared object matching <emphasis remap='Em'>lib&lt;sod_name&gt;.so.n.m</emphasis>. If not set, <emphasis remap='Fa'>sod_name</emphasis> should point at a full path name for the desired shared object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sod_major</emphasis></term> <listitem> <para>Specifies the major version number of the shared object to load.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>sod_minor</emphasis></term> <listitem> <para>Specifies the preferred minor version number of the shared object to load.</para> </listitem> </varlistentry> </variablelist> <para>The run-time link-editor maintains a list of structures called <emphasis remap='Em'>link</emphasis> <emphasis remap='Em'>maps</emphasis> to keep track of all shared objects loaded into a process' address space. These structures are only used at run-time and do not occur within the text or data segment of an executable or shared library.</para> <programlisting remap='Bd'> struct so_map { caddr_t som_addr; char *som_path; struct so_map *som_next; struct sod *som_sod; caddr_t som_sodbase; u_int som_write : 1; struct _dynamic *som_dynamic; caddr_t som_spd; }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width som_dynamic'> <varlistentry> <term><emphasis remap='Fa'>som_addr</emphasis></term> <listitem> <para>The address at which the shared object associated with this link map has been loaded.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>som_path</emphasis></term> <listitem> <para>The full path name of the loaded object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>som_next</emphasis></term> <listitem> <para>Pointer to the next link map.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>som_sod</emphasis></term> <listitem> <para>The <emphasis remap='Fa'>sod</emphasis> structure that was responsible for loading this shared object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>som_sodbase</emphasis></term> <listitem> <para>Tossed out in later versions of the run-time linker.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>som_write</emphasis></term> <listitem> <para>Set if (some portion of) this object's text segment is currently writable.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>som_dynamic</emphasis></term> <listitem> <para>Pointer to this object's <emphasis remap='Fa'>_dynamic</emphasis> structure.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>som_spd</emphasis></term> <listitem> <para>Hook for attaching private data maintained by the run-time link-editor.</para> </listitem> </varlistentry> </variablelist> <para>Symbol description with size. This is simply an <emphasis remap='Fa'>nlist</emphasis> structure with one field (Fa nz_size) added. Used to convey size information on items in the data segment of shared objects. An array of these lives in the shared object's text segment and is addressed by the <emphasis remap='Fa'>sdt_nzlist</emphasis> field of <emphasis remap='Fa'>section_dispatch_table</emphasis>.</para> <programlisting remap='Bd'> struct nzlist { struct nlist nlist; u_long nz_size; #define nz_un nlist.n_un #define nz_strx nlist.n_un.n_strx #define nz_name nlist.n_un.n_name #define nz_type nlist.n_type #define nz_value nlist.n_value #define nz_desc nlist.n_desc #define nz_other nlist.n_other }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width nz_size'> <varlistentry> <term><emphasis remap='Fa'>nlist</emphasis></term> <listitem> <para>(see <citerefentry><refentrytitle>nlist</refentrytitle><manvolnum>3</manvolnum></citerefentry>).</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>nz_size</emphasis></term> <listitem> <para>The size of the data represented by this symbol.</para> </listitem> </varlistentry> </variablelist> <para>A hash table is included within the text segment of shared object to facilitate quick lookup of symbols during run-time link-editing. The <emphasis remap='Fa'>sdt_hash</emphasis> field of the <emphasis remap='Fa'>section_dispatch_table</emphasis> structure points at an array of <emphasis remap='Fa'>rrs_hash</emphasis> structures:</para> <programlisting remap='Bd'> struct rrs_hash { int rh_symbolnum; /* symbol number */ int rh_next; /* next hash entry */ }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width rh_symbolnum'> <varlistentry> <term><emphasis remap='Fa'>rh_symbolnum</emphasis></term> <listitem> <para>The index of the symbol in the shared object's symbol table (as given by the <emphasis remap='Fa'>ld_symbols</emphasis> field).</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>rh_next</emphasis></term> <listitem> <para>In case of collisions, this field is the offset of the next entry in this hash table bucket. It is zero for the last bucket element.</para> </listitem> </varlistentry> </variablelist> <para>The <emphasis remap='Fa'>rt_symbol</emphasis> structure is used to keep track of run-time allocated commons and data items copied from shared objects. These items are kept on linked list and is exported through the <emphasis remap='Fa'>dd_cc</emphasis> field in the <emphasis remap='Fa'>so_debug</emphasis> structure (see below) for use by debuggers.</para> <programlisting remap='Bd'> struct rt_symbol { struct nzlist *rt_sp; struct rt_symbol *rt_next; struct rt_symbol *rt_link; caddr_t rt_srcaddr; struct so_map *rt_smp; }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width rt_scraddr'> <varlistentry> <term><emphasis remap='Fa'>rt_sp</emphasis></term> <listitem> <para>The symbol description.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>rt_next</emphasis></term> <listitem> <para>Virtual address of next rt_symbol.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>rt_link</emphasis></term> <listitem> <para>Next in hash bucket. Used internally by <command remap='Nm'> link </command></para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>rt_srcaddr</emphasis></term> <listitem> <para>Location of the source of initialized data within a shared object.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>rt_smp</emphasis></term> <listitem> <para>The shared object which is the original source of the data that this run-time symbol describes.</para> </listitem> </varlistentry> </variablelist> <para>The <emphasis remap='Fa'>so_debug</emphasis> structure is used by debuggers to gain knowledge of any shared objects that have been loaded in the process's address space as a result of run-time link-editing. Since the run-time link-editor runs as a part of process initialization, a debugger that wishes to access symbols from shared objects can only do so after the link-editor has been called from crt0. A dynamically linked binary contains a <emphasis remap='Fa'>so_debug</emphasis> structure which can be located by means of the <emphasis remap='Fa'>d_debug</emphasis> field in <emphasis remap='Fa'>_dynamic</emphasis>.</para> <programlisting remap='Bd'> struct so_debug { int dd_version; int dd_in_debugger; int dd_sym_loaded; char *dd_bpt_addr; int dd_bpt_shadow; struct rt_symbol *dd_cc; }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width dd_in_debugger'> <varlistentry> <term><emphasis remap='Fa'>dd_version</emphasis></term> <listitem> <para>Version number of this interface.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>dd_in_debugger</emphasis></term> <listitem> <para>Set by the debugger to indicate to the run-time linker that the program is run under control of a debugger.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>dd_sym_loaded</emphasis></term> <listitem> <para>Set by the run-time linker whenever it adds symbols by loading shared objects.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>dd_bpt_addr</emphasis></term> <listitem> <para>The address where a breakpoint will be set by the run-time linker to divert control to the debugger. This address is determined by the start-up module, <filename>crt0.o</filename>, to be some convenient place before the call to _main.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>dd_bpt_shadow</emphasis></term> <listitem> <para>Contains the original instruction that was at <emphasis remap='Fa'>dd_bpt_addr</emphasis>. The debugger is expected to put this instruction back before continuing the program.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>dd_cc</emphasis></term> <listitem> <para>A pointer to the linked list of run-time allocated symbols that the debugger may be interested in.</para> </listitem> </varlistentry> </variablelist> <para>The <emphasis remap='Em'>ld_entry</emphasis> structure defines a set of service routines within <command remap='Nm'> link </command></para> <!-- See .Xr libdl.a for more information. --> <programlisting remap='Bd'> <funcsynopsis> <funcsynopsisinfo> struct ld_entry { void *(*dlopen)(char *, int); int (*dlclose)(void *); void *(*dlsym)(void *, char *); char *(*dlerror)(void); }; </funcsynopsisinfo> </funcsynopsis> </programlisting> <!-- remap='Ed (block)' --> <para>The <emphasis remap='Fa'>crt_ldso</emphasis> structure defines the interface between the start-up code in crt0 and <command remap='Nm'> link </command></para> <programlisting remap='Bd'> struct crt_ldso { int crt_ba; int crt_dzfd; int crt_ldfd; struct _dynamic *crt_dp; char **crt_ep; caddr_t crt_bp; char *crt_prog; char *crt_ldso; struct ld_entry *crt_ldentry; }; #define CRT_VERSION_SUN 1 #define CRT_VERSION_BSD_2 2 #define CRT_VERSION_BSD_3 3 #define CRT_VERSION_BSD_4 4 </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width crt_dzfd'> <varlistentry> <term><emphasis remap='Fa'>crt_ba</emphasis></term> <listitem> <para>The virtual address at which <command remap='Nm'> link </command> was loaded by crt0.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>crt_dzfd</emphasis></term> <listitem> <para>On SunOS systems, this field contains an open file descriptor to &ldquo;Pa /dev/zero&rdquo; used to get demand paged zeroed pages. On <productname>FreeBSD</productname> systems it contains -1.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>crt_ldfd</emphasis></term> <listitem> <para>Contains an open file descriptor that was used by crt0 to load <command remap='Nm'> link </command></para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>crt_dp</emphasis></term> <listitem> <para>A pointer to main's <emphasis remap='Fa'>_dynamic</emphasis> structure.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>crt_ep</emphasis></term> <listitem> <para>A pointer to the environment strings.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>crt_bp</emphasis></term> <listitem> <para>The address at which a breakpoint will be placed by the run-time linker if the main program is run by a debugger. See <emphasis remap='Fa'>so_debug</emphasis></para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>crt_prog</emphasis></term> <listitem> <para>The name of the main program as determined by crt0 (CRT_VERSION_BSD3 only).</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>crt_ldso</emphasis></term> <listitem> <para>The path of the run-time linker as mapped by crt0 (CRT_VERSION_BSD4 only).</para> </listitem> </varlistentry> </variablelist> <para>The <emphasis remap='Fa'>hints_header</emphasis> and <emphasis remap='Fa'>hints_bucket</emphasis> structures define the layout of the library hints, normally found in &ldquo;Pa /var/run/ld.so.hints&rdquo;, which is used by <command remap='Nm'> link </command> to quickly locate the shared object images in the file system. The organization of the hints file is not unlike that of an &ldquo;a.out&rdquo; object file, in that it contains a header determining the offset and size of a table of fixed sized hash buckets and a common string pool.</para> <programlisting remap='Bd'> struct hints_header { long hh_magic; #define HH_MAGIC 011421044151 long hh_version; #define LD_HINTS_VERSION_1 1 long hh_hashtab; long hh_nbucket; long hh_strtab; long hh_strtab_sz; long hh_ehints; }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width hh_strtab_sz'> <varlistentry> <term><emphasis remap='Fa'>hh_magic</emphasis></term> <listitem> <para>Hints file magic number.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>hh_version</emphasis></term> <listitem> <para>Interface version number.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>hh_hashtab</emphasis></term> <listitem> <para>Offset of hash table.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>hh_strtab</emphasis></term> <listitem> <para>Offset of string table.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>hh_strtab_sz</emphasis></term> <listitem> <para>Size of strings.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>hh_ehints</emphasis></term> <listitem> <para>Maximum usable offset in hints file.</para> </listitem> </varlistentry> </variablelist> <programlisting remap='Bd'> <filename>/*</filename> * Hash table element in hints file. */ struct hints_bucket { int hi_namex; int hi_pathx; int hi_dewey[MAXDEWEY]; int hi_ndewey; #define hi_major hi_dewey[0] #define hi_minor hi_dewey[1] int hi_next; }; </programlisting> <!-- remap='Ed (block)' --> <variablelist remap='Bl -tag -width hi_ndewey'> <varlistentry> <term><emphasis remap='Fa'>hi_namex</emphasis></term> <listitem> <para>Index of the string identifying the library.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>hi_pathx</emphasis></term> <listitem> <para>Index of the string representing the full path name of the library.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>hi_dewey</emphasis></term> <listitem> <para>The version numbers of the shared library.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>hi_ndewey</emphasis></term> <listitem> <para>The number of valid entries in <emphasis remap='Fa'>hi_dewey</emphasis>.</para> </listitem> </varlistentry> <varlistentry> <term><emphasis remap='Fa'>hi_next</emphasis></term> <listitem> <para>Next bucket in case of hashing collisions.</para> </listitem> </varlistentry> </variablelist> </refsect1> <refsect1 xml:id='doclifter-caveats'><title>CAVEATS</title> <para>Only the (GNU) C compiler currently supports the creation of shared libraries. Other programming languages cannot be used.</para> </refsect1> </refentry>
27,911
Common Lisp
.l
844
31.949052
161
0.774877
thinkum/ltp-main
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
85fa4b66c78bec179fe70a49dd9b85e2a8f0c94d53d87b8221f9decb03bf95cd
29,377
[ -1 ]
29,393
test-interface.lisp
thinkum_affta/src/main/cltl/test-interface.lisp
;; test-interface.lisp - interface [AFFTA] (in-package #:mcicl.test) #+NIL ;; Regression test onto ASSOCIATIVE-INDEX (progn (defsuite frob) (deftest frob-1 (frob) (:lambda () (break "FROB"))) ;; test integration with instance indexing protocol (compute-key (deftest frob-1 (frob) (:lambda () (break "FROB"))) (find-test-suite 'frob)) ;; => FROB-1 ;; OK ;; test registry for test object in test suite (let ((suite (find-test-suite 'frob)) (tests)) (register-object (deftest frob-1 (frob) (:lambda () (break "FROB"))) suite) (map-tests #'(lambda (test) (setq tests (push test tests))) suite) (values (length tests) (and tess (object-name (car tests)))) ) ;; => 1, FROB-1 ;; OK (hash-table-count (object-table (find-test-suite 'frob))) ;; => 1 ) #+PROTOTYPE ;; from AFFTA-1.2 [Batch Testing] (?) ;; see README.md (progn ;; setup forms (defun radians-to-degrees (theta) (* theta #.(/ 180 pi))) ;; test forms - deftest* (defsuite geometry-test-suite-1 (:class test-suite)) (macroexpand-1 (quote (deftest radians-to-degrees-1 (geometry-test-suite-1) (:object #'radians-to-degrees) (:summary "Verify conversion of radians to degrees") ;; (:setup-lamba ()) ;; no-op ;; (:cleanup-lamba ()) ;; no-op (:lambda (theta) (radians-to-degrees theta)) (:predicate #'set=) ) )) (describe (find-test 'radians-to-degrees-1 'geometry-test-suite-1)) (in-test-suite geometry-test-suite-1) ;; X (defgoals radians-to-degrees-1.1 (radians-to-degrees-1 geometry-test-suite-1) (:summary "Verify conversion onto factors of PI") (:goal pluspi-180 (:summary "Pi Radians => 180 Degrees") (:params pi) (:expect (values (coerce 180 (type-of pi))))) (:goal minuspi-minus180 (:summary "-Pi Radians => -180 Degrees") (:params (- pi)) (:expect (values (coerce -180 (type-of pi)))))) (map-goals #'print (find-goal 'radians-to-degrees-1.1 'geometry-test-suite-1)) (let ((g (find-goal 'pluspi-180 (find-goal 'radians-to-degrees-1.1 'geometry-test-suite-1)))) (describe g) (funcall (test-parameters-function g )) #+TO-DO (run-test g) ) (run-test '(geometry-test-suite-1 pluspi-180)) (run-test '(geometry-test-suite-1 minuspi-minus180 ) (run-test-suite 'geometry-test-suite-1) ;; FIXME: Define a *BREAK-ON-FAILURE* flag ;; and implement within DO-TEST (LISP-TEST-GOAL T) ;; second prototype: (defsuite utils-test-suite-1 ;; TO DO: define TEST-SUITE as a sublcass of ASDF:SYSTEM ;; but do not ADSF/DEFSYSTEM:REGISTER-SYSTEM-DEFINITION ;; of a TEST-SUITE defined within DEFSUITE ;; support a syntax similar to ASDF:DEFSYSTEM (:class test-suite) ;; N/A handle system dependencies in system definition : #+NIL (:depends-on #:info.metacommunity.cltl.utils) ) (find-test-suite 'utils-test-suite-1) (in-test-suite utils-test-suite-1) ;; X (deftest compute-class-1 (utils-test-suite-1) (:object #'compute-class) (:summary "Test evaluation of COMPUTE-CLASS") (:lambda (ident) (values (compute-class ident) ident)) (:predicate #'set-eq)) (find-test 'compute-class-1 'utils-test-suite-1) (defgoals simple-goals-1 (compute-class-1 utils-test-suite-1) (:summary "Test evaluation of COMPUTE-CLASS") (:goal symbol-to-class (:class lisp-test-goal) (:summary "Compute class for symbol class name" ) (:params 'string) (:expect (values (find-class 'string) 'string))) (:goal class-as-class (:class lisp-test-goal) (:summary "Ensure identity operation for class arg") (:params (find-class 'ratio)) (:expect (let ((c (find-class 'ratio))) (values c c))))) (run-test 'compute-class-1) ;; use current-suite (?) (run-test-suite 'utils-test-suite-1) ) ) ;; Protocol for source-inline instance tests [AFFTA 1.3+] #+PROTOTYPE (do-test (mktest #'EXPT (2 2) (4))) #+AFFTA-1.3 (defmacro mktest (function (&rest args) (&rest expected-values) &key (predicate %default-equivalence-function%) (context (get-current-test-suite))) (with-gensym (test record) `(when-test-load ;; ... (let* ((,test (make-instance 'lisp-test :function ,function)) (,record (.... :test ,test .... (quote ,args) .... (quote ,expected-values)))) (when-test-eval ;; ... (do-recorded-test ,record *standard-output*)))))) (defun find-property (name set &optional default) "Return the first property element named NAME from the associative property list SET. Comparison of NAME onto SET will be performed with `EQ' If no such property exists, return DEFAULT" (declare (type symbol name) (type list set)) (or (assoc name set :test #'eq) default)) (defun nfind-property (name set &optional default) "Return the first property element named NAME from associative property list SET. Comparison of NAME onto SET will be performed with `EQ'. If not found, return the value of DEFAULT. If found, this function will destructively modify SET as to delete the property element. The second return value will then be the value of SET, destructively modified if NAME was found If not found, the value SET will be returned as the second return value, unmodified. See also: `nget-property', `nget-property*'" (declare (type symbol name) (type list set) (values t list)) (let ((it (assoc name set :test #'eq))) (cond (it (values it (delete it set :test #'eq))) (t (values default set))))) (defun format-property (spec) "Format a variably atomic/list type property list element. This function returns the formatted element and the name of the element. Examples: (format-property (:foo)) => nil, :foo (format-property (:foo a)) => a, :foo (format-property (:foo . a)) => a, :foo (format-property (:foo a b)) => (a b), :foo (format-property (:foo . a b)) => (a b), :foo See also: `format-property*', `map-properties'" (declare (type list spec) (values t symbol)) (destructuring-bind (name . value) spec (cond ((and (consp value) (cdr value)) (values value name)) ((consp value) (values (car value) name)) (t (values value name))))) (defun format-property* (spec) "Format a list type propert list element This function returns the formatted element and the name of the element. Examples: (format-property (:foo)) => nil, :foo (format-property (:foo a)) => (a), :foo (format-property (:foo . a)) => a, :foo (format-property (:foo a b)) => (a b), :foo (format-property (:foo . a b)) => (a b), :foo See also: `format-property', `map-properties*'" (declare (type list spec) (values t symbol)) (destructuring-bind (name . value) spec (values value name))) (defun map-properties (set) (mapcan #'(lambda (spec) (multiple-value-bind (value name) (format-property spec) (list name value))) set)) (defun map-properties* (set) (mapcan #'(lambda (spec) (multiple-value-bind (value name) (format-property* spec) (list name value))) set)) (defmacro nget-property (indicator where &optional default) "Return a plist formatted property element named NAME from the associative property list denoted by WHERE, destructively mofidying the property list for the removed element. The property element will be formatted with `format-property' If no such property exists, return DEFAULT See also: `nfind-property'" (with-gensym (prop %where) `(multiple-value-bind (,prop ,%where) (nfind-property ,indicator ,where) (cond (,prop (setf ,where ,%where) (values (format-property ,prop))) (t (values ,default)))))) (defmacro nget-property* (indicator where &optional default) "Return a plist formatted property element named NAME from the associative property list denoted by WHERE, destructively mofidying the property list for the removed element. The property element will be formatted with `format-property' If no such property exists, return DEFAULT See also: `nfind-property'" (with-gensym (prop %where) `(multiple-value-bind (,prop ,%where) (nfind-property ,indicator ,where) (cond (,prop (setf ,where ,%where) (values (format-property* ,prop))) (t (values ,default)))))) ;; instance tests (associative property list model) -- nget-property ;; (let ((p '((:a 1) (:b 2)))) (values (nget-property :a p) p)) ;; => 1, ((:B 2)) ;; instance tests (associative property list model) -- nget-property* ;; (let ((p '((:a 1) (:b 2)))) (values (nget-property* :a p) p)) ;; => (1), ((:B 2)) ;;; DEFSUITE (defmacro defsuite (name &rest properties &aux (default-suite-class 'test-suite) (default-test-class 'lisp-test) &environment env) (setq properties (copy-list properties)) (with-gensym (class instance dtc) `(let* ((,class (quote ,(nget-property :class properties (find-class default-suite-class env)))) ;; note that all initarg values except for :CLASS, :NAME, ;; :DEFAULT-TEST-CLASS will be evaluated ;; (FIXME: This is "cheap") (,dtc (quote ,(nget-property :default-test-class properties (find-class default-test-class)))) (,instance (make-instance (compute-class ,class) :name (quote ,name) :default-test-class ,dtc ,@(map-properties properties)))) (register-test-suite ,instance) (values ,instance)))) ;; (defsuite foo-suite) ;; (defsuite foo-suite (:default-test-class lisp-test)) ;; (defclass foo-test-suite (test-suite) ()) ;; (defsuite foo-suite (:class foo-test-suite)) ;;; *TEST-SUITE* (declaim (type test-suite *test-suite*)) (defvar *test-suite*) (setf (documentation '*test-suite* 'variable) "Default test suite, within the active lexical environment. See also: * `TEST-SUITE' [Class] * `DEFSUITE' [Macro] * `IN-TEST-SUITE' [Macro] * `FIND-TEST-SUITE' [Function]") (defmacro in-test-suite (name) "Specify that the test suite named NAME will be bound to `*TEST-SUITE*' within the active lexical environment. NAME will not be evaluated See also: * `TEST-SUITE' [Class] * `DEFSUITE' [Macro] * `IN-TEST-SUITE' [Macro] * `FIND-TEST-SUITE' [Function]" ;; FIXME: Try to ensure IN-TEST-SUITE will be applied local to: ;; 1. evaluation of a file ;; 2. evaluation of forms from an input stream ;; ;; Consider defining *TEST-SUITE* as a thread-local variable (TO DO) ;; for this purpose `(setq *test-suite* (find-test-suite (quote ,name)))) ;;; DEFTEST (defconstant* %unspecified% (make-symbol "%UNSPECIFIED%")) (defmacro deftest (name (&optional (suite *test-suite* suitep)) &rest properties &environment env) (setq properties (copy-list properties)) (let* ((lp (nget-property :lambda properties %unspecified%)) (ob (nget-property :object properties)) ;; will be evaluted (c (nget-property :class properties %unspecified%)) (pred (nget-property :predicate properties %unspecified%))) (when (eq lp %unspecified%) (error "DEFTEST ~S absent of :LAMBDA property" name)) (with-gensym (%suite class test object predicate) `(let* ((,%suite ,(if suitep `(find-test-suite (quote ,suite) t) `(values *test-suite*))) ;; FIXME: "Chicken and egg" issue for defaulting of TEST-CLASS ;; ;; Observe: ;; 1. A TEST-SUITE may make reference to one or more tests ;; 2. If a TEST must be defined as deriving its ;; TEST-CLASS from a TEST-SUITE, there is a ;; bootstrapping issue. ;; ;; Therefore. ;; 1. If a TEST is to be defined newly and without an ;; explicit :CLASS specifier in DEFTEST, then at ;; least one TEST-SUITE must be defined, intially, ;; from which the DEFTEST macroexpansion may then ;; derive the test's class. ;; ;; 2. For DEFTEST forms with explicit :CLASS ;; specifiers, the containing TEST-SUITE need not be ;; referenced for teremining the class of the test ;; definition in DEFTEST ;; ;; Moreover: When a TEST-GOAL is initialized, the class ;; of the TEST-GOAL is computed per the test object and ;; the container object in which the test is to be ;; defined. See also: `ENSURE-GOAL', `COMPUTE-GOAL-CLASS' ;; ... however FIXME: If the :CLASS speciifed within ;; a DEFTEST form for a named test is not EQ to the ;; existing class of the test, then the test must be ;; updated for its new class, via CHANGE-CLASS etc. ;; ;; The similar must be done, for test goal objects (,class ,(if (eq c %unspecified%) `(default-test-class ,%suite) `(find-class ,c t ,env))) (,object ,(values ob)) (,predicate ,(if (eq pred %unspecified%) `(function eql) `(values ,pred))) ;; FIXME: :LAMBDA only applicable for LISP-TEST (,test (make-instance ,class :name (quote ,name) :object ,object :predicate ,predicate :lambda (lambda ,@lp) ,@(map-properties properties)))) (add-test ,test ,%suite) (values ,test ,%suite))))) (defmacro defgoals (name (test &optional (suite *test-suite* suitep)) &rest properties) #+NIL "Define a GOAL-SET with name NAME FIXME: Update documentation string: * TEST * Must name an initialized TEST object within the specified SUITE * Will not be evaluated * SUITE * Symbol, a test suite name * May name be a TEST-SUITE or a GOAL-SET (VERIFY). * Will not be evaluated * :GOALS syntax, within PROPERTIES * Other PROPERTIES syntax - :CLASS, etc. " (setq properties (copy-list properties)) (let ((c (nget-property :class properties %unspecified%)) ;; ? class of ..? (forms-cache)) (with-gensym (%suite goal-set %test class) `(let* ((,%suite ,(if suitep `(find-test-suite (quote ,suite) t) `(values *test-suite*))) (,%test (find-test (quote ,test) ,%suite)) (,class ,(if (eq c %unspecified%) ;; FIXME: No interface for defining ;; GOAL-SET instances `(default-goal-set-class ,%suite) `(compute-class (quote ,c))))) ;; FIXME: Record source locations (portably) - see DEFINITION ,@(loop (let ((g (nget-property :goal properties %unspecified%))) (cond ((eq g %unspecified%) (return)) (t (destructuring-bind (name . args) g ;; NB: This (FIXME: ;; 1. ensures that all elements of ARGS will be evaluated ;; 2. does not coerce ARGS from property format ;; 3. does not define a PARAMS-FUNCTION for ;; evaluating :PARAMS initarg ;; 4. does not define an :EXPECT-FUNCTION for ;; evaluating :EXPECT initarg (let* ((expect (nget-property* :expect args)) (expect-fn `(lambda () (list ,@expect))) (params (nget-property* :params args)) (params-fn `(lambda () (list ,@params))) (class (nget-property :class args %unspecified%))) (cond ((eq class %unspecified%) (setq class `(compute-goal-class ,%test ,goal-set))) ((symbolp class) (setq class `(quote,class)))) (setq forms-cache (append forms-cache `((ensure-goal (quote ,name) ,goal-set :expect (quote ,expect) :expect-function ,expect-fn :params (quote ,params) :params-function ,params-fn :class (compute-class ,class) ,@(map-properties args))))))))))) (let ((,goal-set (ensure-goal-set (quote ,name) ,%suite :test ,%test :class (compute-class ,class) ,@(map-properties properties)))) ,@forms-cache ))))) (defun run-test-suite (suite &rest recording-params) (declare (type (or symbol test-suite) suite) (ignore recording-params)) ;; FIXME: pass the RECORDING-PARAMS through to RUN-TESTS (let ((%suite (etypecase suite (symbol (find-test-suite suite)) (test-suite suite)))) (run-tests %suite)))
18,546
Common Lisp
.lisp
413
34.007264
85
0.568872
thinkum/affta
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
78f9dc71a5f8888ffa4a1f7ecb0699f3b4147a0accdad08d2f52aed3cb4fe4b6
29,393
[ -1 ]
29,394
test-reporting.lisp
thinkum_affta/src/main/cltl/test-reporting.lisp
;; test-reporting.lisp - Test result reporting [AFFTA] (in-package #:mcicl.test) ;; FIXME: Merge into file test-recording.lisp (define-condition test-condition () ((test :initarg :test :reader test-condition-test))) (defgeneric format-test-results (condition stream)) (define-condition test-result (test-condition) ;; The TEST-RESULT class was developed both to serve as a ;; condition class for test failure/success and furthermore to serve ;; as an effective "bucket" for test result values, as the latter ;; being encapsulated within a TEST-RECORD object ((record :initarg :record :accessor test-result-record))) (defmethod format-condition ((condition test-result) (stream stream)) (let ((test (test-condition-test condition))) (princ (class-name (class-of condition)) stream) (write-char #\Space stream) (print-label test stream) (write-char #\Space stream) (format-test-results condition stream))) (defmethod format-test-results ((condition test-result) (stream stream)) ;; system may be in an inconsistent state when a test result is printed. (let* ((record (ignore-errors (test-result-record condition))) (goal (ignore-errors (test-goal record))) (test (ignore-errors (test-reference-test goal)))) #+NIL (print-label (ignore-errors (test-goal record)) stream) (print-label (ignore-errors (object-name test)) stream) #+NIL (write-char #\Space stream) #+NIL (print-label (ignore-errors (test-reference-test goal)) stream) (write-string " | " stream) (princ (ignore-errors (test-main-values record)) stream))) (define-condition test-failed (test-result) () (:report format-test-condition)) (defmethod format-test-condition ((condition test-failed) (stream stream)) ;; FIXME/TO-DO: #I18N for condition/reporter format control strings (princ "Test failed" stream)) (define-condition test-succeeded (test-result) () (:report format-test-condition)) (defmethod format-test-condition ((condition test-succeeded) (stream stream)) ;; FIXME/TO-DO: #I18N for condition/reporter format control strings (princ "Test succeeded" stream))
2,281
Common Lisp
.lisp
53
37.301887
74
0.69276
thinkum/affta
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
4c1fcbfa5a7feaedb3ff8425d35de889812866ee169fdcc48eccb2cb54940d35
29,394
[ -1 ]
29,395
test-utils.lisp
thinkum_affta/src/main/cltl/test-utils.lisp
;; test-utils.lisp - utility forms [AFFTA] (in-package #:mcicl.test) (defclass closure-container () ;; cf. PREDICATE (?) ;; FIXME: Reevaluate this class' application ((environment :initarg :environment :initform nil :accessor container-environment))) ;;; % Set Equivalence Operations (defmacro do-seo (op (a b)) ;; do-set-equivalence-op (with-gensym (%a %b len-a len-b n) `(let ((,%a ,a) (,%b ,b) (,len-a (length a)) (,len-b (length b))) (declare (type unsigned-byte ,len-a ,len-b) (inline ,op)) ;; NB: This might avert some compiler transformations, in using ;; DOTIMES instead of EVERY. Notably, SBCL converts an EVERY ;; call to a MAP call. Perhaps there may be not much of an ;; optimization lost, in this alternate approach of using ;; DOTIMES instead of EVERY -- with LEN-A and LEN-B already ;; available, as needed for this set/elements form. ;; ;; NB: A compiler optimization may be defined for the LENGTH ;; and ELT calls in this form, for when A and/or B can be ;; determined to be type VECTOR or SIMPLE-ARRAY [SBCL ;; 1.2.6]. Perhaps that may behoove a design for a method for ;; dispatching optimizations. Alternately, this may be ;; implemented within a generic function in which the types of ;; A and B would be more specificall defined (and (= ,len-a ,len-b) (dotimes (,n ,len-a t) (unless (funcall (function ,op) (elt ,%a ,n) (elt ,%b ,n)) (return nil))))))) (defun set= (a b) (declare (type sequence a b) (values boolean)) (do-seo = (a b))) ;; (set= '(1.0 2.0) '(1 2.0d0)) ;; => T ;; (set= '(1.0 2.0) '(1 2.0d0 3)) ;; => NIL ;; (set= '(1.0 3.0) '(1 2.0d0)) ;; => NIL (defun set-eql (a b) (declare (type sequence a b) (values boolean)) (do-seo eql (a b))) (defun set-eq (a b) (declare (type sequence a b) (values boolean)) (do-seo eq (a b))) (defun set-equal (a b) (declare (type sequence a b) (values boolean)) (do-seo equal (a b))) (defun set-equalp (a b) (declare (type sequence a b) (values boolean)) (do-seo equalp (a b))) ;;; % Class DEFINITION (defgeneric definition-summary (object) (:documentation "Provide a succinct summary about a definition object")) (defgeneric (setf definition-summary) (new-value object) (:documentation "Establish a succinct summary about a definition object")) (defgeneric definition-source-location (object)) (defgeneric (setf definition-source-location) (new-value object)) ;; ^ FIXME/TO-DO : Define a portable source locations library (stand-alone) (defclass definition () ((summary :initarg :summary :accessor definition-summary :type simple-string))) ;; Trivial regression test ;; (make-instance 'definition) ;; (make-instance 'definition :summary "FOO")
2,958
Common Lisp
.lisp
80
31.6375
75
0.633788
thinkum/affta
0
0
0
EPL-1.0
9/19/2024, 11:37:33 AM (Europe/Amsterdam)
db88c6046bafac069acdea7a9fc1b1f7c4cd7b5cefbc80483709b07e08df8a3e
29,395
[ -1 ]