Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file plugin_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130(** Base class type that all trait should follow.
For single type declaration
[
type ('a, 'b, ...) typ = ...
]
plugin generate a {i plugin class} called [traitnname_typ_t] and
a {i transformation function} called [traitname_t].
Generated transformation functions can make use of inherited attribute for type
parameter (which is being generated by method {!method:typ_g#inh_of_param})
or simply ignore it.
For example, transformation function for type parameter ['a] can have types
either ['a -> 'sa] (see plugins {!Show} and {!Gmap} as examples) or
['ia -> 'a -> 'sa].
*)typeplugin_args=(Ppxlib.longident*Ppxlib.expression)list(** A type that stores additional arguments passed to each plugin. *)(** Base class type for all plugins.
Is parametrized by output AST types for convenience. All plugins receive input data as
OCaml AST and return pieces specific for backend.
*)classvirtual['loc,'exp,'typ,'type_arg,'ctf,'cf,'str,'sign]typ_g=object(** {1 Methods that are specific for a concrete plugin implementation } *)(* They are very likely will need to be implemented when new plugin is added. *)(** Name of a trait (and of plugin too). It is used for constructing new classes and
* functions related to plugin.
*)methodvirtualtrait_name:string(** Inherited attribute for whole type declaration. Is is defined by plugin kind. *)methodvirtualinh_of_main:loc:'loc->Ppxlib.type_declaration->'typ(** Synthesized attribute for whole type declaration. Is is defined by plugin kind. *)methodvirtualsyn_of_main:loc:'loc->?in_class:bool->Ppxlib.type_declaration->'typ(** [syn_of_param ~loc name] constructs synthethized attribute for type paramter [name]. *)methodvirtualsyn_of_param:loc:'loc->string->'typ(** [inh_of_param ~loc tdecl name ] constructs inherited attribute for type parameter [name]. *)methodvirtualinh_of_param:loc:'loc->Ppxlib.type_declaration->string->'typ(** The parameters that the plugin class will have in its definition.
* Add ['extra] manually if needed. *)methodvirtualplugin_class_params:loc:'loc->Ppxlib.core_typelist->typname:string->'typlist(** Arguments of inherit class field that will be generated using the types
applied in the RHS of type definition. *)methodvirtualalias_inherit_type_params:loc:'loc->Ppxlib.type_declaration->Ppxlib.core_typelist->'typlist(* These methods will be implemented in plugin.ml *)(** Adds a few extra members to a plugin class. Could be some constraints that are
difficult to add in place where type parameters are declared. *)methodvirtualextra_class_sig_members:Ppxlib.type_declaration->'ctflist(** The same as [extra_class_sig_members] but for structures. *)methodvirtualextra_class_str_members:Ppxlib.type_declaration->'cflist(** {1 Methods that are specific for all plugins and unlikely will need to be override } *)(** Generate signature items for single type definition. *)methodvirtualdo_single_sig:loc:'loc->is_rec:bool->Ppxlib.type_declaration->'signlist(** Generate structure items for single type definition. *)methodvirtualdo_single:loc:'loc->is_rec:bool->Ppxlib.type_declaration->'strlist(** Generate structure items a type extension. Beta feature. *)(* method virtual do_typext_str: loc:'loc -> Ppxlib.type_extension -> 'str list *)(** Generate name for transformation function. *)methodvirtualmake_trans_function_name:Ppxlib.type_declaration->string(** Generate type of a transformation function. *)methodvirtualmake_trans_function_typ:loc:'loc->Ppxlib.type_declaration->'typ(** Generate structure items for mutally recursive type declarations. *)methodvirtualdo_mutuals:loc:'loc->is_rec:bool->Ppxlib.type_declarationlist->'strlistmethodvirtualdo_mutuals_sigs:loc:'loc->is_rec:bool->'signlistmethodvirtualneed_inh_attr:boolmethodvirtualeta_and_exp:center:'exp->Ppxlib.type_declaration->'expmethodvirtualmake_final_trans_function_typ:loc:'loc->Ppxlib.type_declaration->'typend(** Functor that takes AST construction functions for a specific backend and
constructs a plugin object. *)moduleMake(AstHelpers:GTHELPERS_sig.S)=structopenAstHelpersclassvirtualg=objectinherit[loc,Exp.t,Typ.t,type_arg,Ctf.t,Cf.t,Str.t,Sig.t]typ_gendendmoduletypeMAKE=functor(AstHelpers:GTHELPERS_sig.S)->sigopenAstHelpersvaltrait_name:stringvalcreate:plugin_args->Ppxlib.type_declarationlist->(loc,Exp.t,Typ.t,type_arg,Ctf.t,Cf.t,Str.t,Sig.t)typ_gend