Index: trunk/src/libcschem/actions_csch.c =================================================================== --- trunk/src/libcschem/actions_csch.c (revision 750) +++ trunk/src/libcschem/actions_csch.c (revision 751) @@ -40,6 +40,7 @@ const char *CSCH_PTR_DOMAIN_COBJ = "csch_fgw_ptr_domain_cobj"; const char *CSCH_PTR_DOMAIN_AOBJ = "csch_fgw_ptr_domain_aobj"; +const char *CSCH_PTR_DOMAIN_PROJECT = "csch_fgw_ptr_domain_project"; const char *CSCH_PTR_DOMAIN_SHEET = "csch_fgw_ptr_domain_sheet"; const char *CSCH_PTR_DOMAIN_ATTRIB = "csch_fgw_ptr_domain_attrib"; Index: trunk/src/libcschem/actions_csch.h =================================================================== --- trunk/src/libcschem/actions_csch.h (revision 750) +++ trunk/src/libcschem/actions_csch.h (revision 751) @@ -1,21 +1,32 @@ +#ifndef ACTIONS_CSCH_H +#define ACTIONS_CSCH_H + +#include + typedef enum { FGW_COBJ_ = FGW_CUSTOM + 20, FGW_AOBJ_, + FGW_PROJECT_, FGW_SHEET_, FGW_ATTRIB_ } csch_fgw_types_e; #define fgw_cobj(arg) ((arg)->val.ptr_void) #define fgw_aobj(arg) ((arg)->val.ptr_void) +#define fgw_project(arg) ((arg)->val.ptr_void) #define fgw_sheet(arg) ((arg)->val.ptr_void) #define fgw_attrib(arg) ((arg)->val.ptr_void) #define FGW_COBJ ((fgw_type_t)FGW_COBJ_) #define FGW_AOBJ ((fgw_type_t)FGW_AOBJ_) +#define FGW_PROJECT ((fgw_type_t)FGW_PROJECT_) #define FGW_SHEET ((fgw_type_t)FGW_SHEET_) #define FGW_ATTRIB ((fgw_type_t)FGW_ATTRIB_) extern const char *CSCH_PTR_DOMAIN_COBJ; extern const char *CSCH_PTR_DOMAIN_AOBJ; +extern const char *CSCH_PTR_DOMAIN_PROJECT; extern const char *CSCH_PTR_DOMAIN_SHEET; extern const char *CSCH_PTR_DOMAIN_ATTRIB; void csch_actions_init(fgw_ctx_t *ctx); + +#endif Index: trunk/src/libcschem/compile.c =================================================================== --- trunk/src/libcschem/compile.c (revision 750) +++ trunk/src/libcschem/compile.c (revision 751) @@ -29,6 +29,7 @@ #include #include "abstract.h" +#include "actions_csch.h" #include "concrete.h" #include "cnc_line.h" #include "cnc_arc.h" @@ -37,6 +38,7 @@ #include "cnc_conn.h" #include "cnc_grp.h" #include "cnc_pen.h" +#include "engine.h" static int compile_attributes(csch_ahdr_t *dst, const csch_attribs_t *src) { @@ -82,7 +84,7 @@ { char tmpname[128]; htip_entry_t *e; - const char *name; + const char *name, *pname_tmp; const csch_attrib_t *aname = NULL; csch_acomp_t *comp; int res = 0; @@ -139,9 +141,15 @@ else pname = tname->val; - port = csch_aport_get(dst, comp, pname, 1); + csch_eng_call_strmod(sheet->parent, CSCH_ENGHK_TERMINAL_NAME_TO_PORT_NAME, + &pname_tmp, pname, + FGW_PROJECT, sheet->parent, FGW_SHEET, sheet, FGW_AOBJ, comp, FGW_COBJ, t, FGW_INVALID); + + port = csch_aport_get(dst, comp, pname_tmp, 1); port->parent = comp; t->aid = port->hdr.aid; + + csch_eng_free_strmod(&pname_tmp, pname); } return res; } Index: trunk/src/libcschem/engine.c =================================================================== --- trunk/src/libcschem/engine.c (revision 750) +++ trunk/src/libcschem/engine.c (revision 751) @@ -27,6 +27,7 @@ #include "config.h" #include +#include #include #include "project.h" @@ -33,8 +34,7 @@ #include "engine.h" const char *csch_enghk_names[CSCH_ENGHK_max] = { - "terminal_name_to_port_name", - NULL + "terminal_name_to_port_name" }; #warning TODO: remove this in favor of fgws_c_call_script() in fungwbind (make sure it is installed) @@ -64,3 +64,28 @@ for(i = 0; i < CSCH_ENGHK_max; i++) eng->hook[i] = fgw_func_lookup_in(obj, csch_enghk_names[i]); } + +/*** calls ***/ +void csch_eng_call_strmod(csch_project_t *proj, csch_eng_hook_t hkid, const char **res, const char *defval, ...) +{ + csch_view_t *view; + void **v; + long n; + + v = vtp0_get(&proj->views, proj->curr, 0); + if (v == NULL) { + *res = NULL; + return; + } + view = *v; + + *res = defval; + + for(n = 0; n < view->engines.used; n++) { + csch_view_eng_t *eng = view->engines.array[n]; + fgw_func_t *hk = eng->hook[hkid]; + if (hk == NULL) + continue; +#warning TODO: the actual call + } +} Index: trunk/src/libcschem/engine.h =================================================================== --- trunk/src/libcschem/engine.h (revision 750) +++ trunk/src/libcschem/engine.h (revision 751) @@ -55,4 +55,23 @@ /* temporary until fungw C binding installation is sorted out */ fgw_error_t csch_c_call_script(fgw_arg_t *res, int argc, fgw_arg_t *argv); +/*** calls ***/ + +/* Call hooks to modify a string. Result is in *res after the call and needs + to be freed using csch_eng_call_strmod() */ +void csch_eng_call_strmod(csch_project_t *proj, csch_eng_hook_t hook, const char **res, const char *defval, ...); + +/* Clean up after csch_eng_call_strmod(). defval must be the same pointer + that was passed to csch_eng_call_strmod() */ +csch_inline csch_eng_free_strmod(const char **res, const char *defval); + + + +/*** implementation ***/ +csch_inline csch_eng_free_strmod(const char **res, const char *defval) +{ + if (*res != defval) + free((char *)(*res)); +} + #endif Index: trunk/src/libcschem/project.h =================================================================== --- trunk/src/libcschem/project.h (revision 750) +++ trunk/src/libcschem/project.h (revision 751) @@ -38,7 +38,7 @@ struct csch_view_s { fgw_ctx_t fgw_ctx; /* name of the view is the name of the context */ - vtp0_t engines; /* of (csch_view_eng_t *) */ + vtp0_t engines; /* priority-ordered list of (csch_view_eng_t *); highest prio (lowest numer) is at the end */ csch_project_t *parent; };