Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 33607) +++ trunk/scconfig/plugins.h (revision 33608) @@ -133,6 +133,7 @@ plugin_def("io_kicad", "Kicad's s-expr format", sbuildin, 1, 0) plugin_def("io_lihata", "lihata board format", sbuildin, 1, 0) plugin_def("io_mentor_cell", "Mentor Graphics cell footprints", sdisable, 1, 0) +plugin_def("io_pads", "PADS board", sdisable, 1, 0) plugin_def("io_pcb", "the original pcb format", sbuildin, 1, 0) plugin_def("io_tedax", "tEDAx (Trivial EDA eXchange)", sbuildin, 1, 0) Index: trunk/src_plugins/io_pads/Makefile =================================================================== --- trunk/src_plugins/io_pads/Makefile (nonexistent) +++ trunk/src_plugins/io_pads/Makefile (revision 33608) @@ -0,0 +1,5 @@ +all: + cd ../../src && $(MAKE) mod_io_pads + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/io_pads/Plug.tmpasm =================================================================== --- trunk/src_plugins/io_pads/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/io_pads/Plug.tmpasm (revision 33608) @@ -0,0 +1,14 @@ +put /local/pcb/mod {io_pads} +put /local/pcb/mod/OBJS [@ + $(PLUGDIR)/io_pads/io_pads.o + $(PLUGDIR)/io_pads/read.o +@] + +put /local/pcb/mod/BYACCIC {$(PLUGDIR)/io_pads/pads_gram} +put /local/pcb/mod/UREGLEX {$(PLUGDIR)/io_pads/pads_lex} + +switch /local/pcb/io_pads/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/io_pads/io_pads.c =================================================================== --- trunk/src_plugins/io_pads/io_pads.c (nonexistent) +++ trunk/src_plugins/io_pads/io_pads.c (revision 33608) @@ -0,0 +1,91 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * PADS IO plugin - plugin coordination + * pcb-rnd Copyright (C) 2020 Tibor 'Igor2' Palinkas + * (Supported by NLnet NGI0 PET Fund in 2020) + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" + +#include +#include +#include +#include +#include "plug_io.h" + +#include "read.h" + +static pcb_plug_io_t io_pads; +static const char *pads_cookie = "PADS IO"; + + +int io_pads_fmt(pcb_plug_io_t *ctx, pcb_plug_iot_t typ, int wr, const char *fmt) +{ + if ((strcmp(ctx->description, fmt) != 0) && (rnd_strcasecmp(fmt, "pads") != 0)) /* format name mismatch */ + return 0; + + if (((typ & (~(PCB_IOT_FOOTPRINT))) != 0) && ((typ & (~(PCB_IOT_PCB))) != 0)) /* support only footprints */ + return 0; + + if (wr) /* no footprint write yet */ + return 0; + + return 100; +} + +int pplg_check_ver_io_pads(int ver_needed) { return 0; } + +void pplg_uninit_io_pads(void) +{ + rnd_remove_actions_by_cookie(pads_cookie); + RND_HOOK_UNREGISTER(pcb_plug_io_t, pcb_plug_io_chain, &io_pads); +} + +int pplg_init_io_pads(void) +{ + RND_API_CHK_VER; + + io_pads.plugin_data = NULL; + io_pads.fmt_support_prio = io_pads_fmt; + io_pads.test_parse = io_pads_test_parse; + io_pads.parse_pcb = io_pads_parse_pcb; +/* io_pads.parse_footprint = io_pads_parse_footprint; + io_pads.map_footprint = io_pads_map_footprint;*/ + io_pads.parse_font = NULL; + io_pads.write_buffer = NULL; + io_pads.write_pcb = NULL; + io_pads.default_fmt = "pads"; + io_pads.description = "pads board"; + io_pads.save_preference_prio = 91; + io_pads.default_extension = ".asc"; + io_pads.fp_extension = ".asc"; + io_pads.mime_type = "application/x-pads"; + io_pads.multi_footprint = 1; + + RND_HOOK_REGISTER(pcb_plug_io_t, pcb_plug_io_chain, &io_pads); + + return 0; +} + Index: trunk/src_plugins/io_pads/io_pads.pup =================================================================== --- trunk/src_plugins/io_pads/io_pads.pup (nonexistent) +++ trunk/src_plugins/io_pads/io_pads.pup (revision 33608) @@ -0,0 +1,9 @@ +$class io +$short PADS board +$long load boards in the PADS ASCII format +$state WIP +$fmt-native no +$fmt-feature-r PADS board +#$package io-alien +default disable +autoload 1 Index: trunk/src_plugins/io_pads/pads_gram.y =================================================================== --- trunk/src_plugins/io_pads/pads_gram.y (nonexistent) +++ trunk/src_plugins/io_pads/pads_gram.y (revision 33608) @@ -0,0 +1,373 @@ +%prefix pcb_pads_% + +%struct +{ + long line, first_col, last_col; +} + +%union +{ + double d; + int i; + char *s; + rnd_coord_t c; +} + + +%{ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * PADS IO plugin - PADS grammar + * pcb-rnd Copyright (C) 2020 Tibor 'Igor2' Palinkas + * (Supported by NLnet NGI0 PET Fund in 2020) + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ +#include +#include "../src_plugins/io_pads/pads_gram.h" +#include "../src_plugins/io_pads/pads.h" + +TODO("Can remove this once the coord unit is converted with getvalue") +#include + +#define XCRD(c) pcb_pads_coord_x(c) +#define YCRD(c) pcb_pads_coord_y(c) + +%} + +/* Generic */ +%token T_ID T_INTEGER T_REAL_ONLY T_QSTR + +%type T_QSTR +%type T_ID +%type T_INTEGER +%type T_REAL_ONLY +%type real +%type coord + +%% + +full_file: + header + file + ; + +file: + /* empty */ + |statement nl file + ; + +header: + '!' T_ID '!' junk nl + +statement: + T_UNITS + ; + +/*** common and misc ***/ + +nl: + '\n' + | '\n' nl + ; + +maybe_nl: + /* empty */ + | nl + ; + +real: + T_INTEGER { $$ = $1; } + | T_REAL_ONLY { $$ = $1; } + ; + +coord: + real { $$ = RND_MIL_TO_COORD($1); } + ; + +common_attr_text: + T_JUSTIFY T_ID { pcb_pads_set_justify(ctx, $2); free($2); } + | T_TEXTSTYLE T_QSTR { pcb_pads_set_text_style(ctx, $2); free($2); } + | T_ISVISIBLE boolean { ctx->state.is_visible = $2; } + ; + +common_origin: + T_ORIGIN coord ',' coord { ctx->state.origin_x = XCRD($2); ctx->state.origin_y = YCRD($4); } + ; + +common_layer: + T_LAYER T_ID { pcb_pads_set_layer(ctx, $2); free($2); } + ; + +common_width: + T_WIDTH coord { ctx->state.width = $2; } + ; + +/*** TextStyle ***/ + +text_style: + T_TEXTSTYLE T_QSTR { pcb_pads_text_style_begin(ctx, $2); /* $2 is taken over */ } + text_style_attrs { pcb_pads_text_style_end(ctx); } + ; + +text_style_attrs: + /* empty */ + | '(' text_style_attr ')' text_style_attrs + ; + +text_style_attr: + T_FONTWIDTH real { ctx->state.text_style->width = $2; } + | T_FONTCHARWIDTH real { ctx->state.text_style->char_width = $2; } + | T_FONTHEIGHT real { ctx->state.text_style->height = $2; } + ; + + +/*** PadStack ***/ + +pad_stack: + T_PADSTACK T_QSTR { pcb_pads_reset(ctx); pcb_pads_padstack_begin(ctx, $2); /* $2 is taken over */ } + pstk_attrs nl + T_SHAPES ':' T_INTEGER nl { ctx->state.num_shapes = $8; } + pad_shapes + T_ENDPADSTACK { pcb_pads_padstack_end(ctx); } + ; + +pstk_attrs: + /* empty */ + | '(' pstk_attr ')' pstk_attrs + ; + +pstk_attr: + T_HOLEDIAM coord { ctx->state.hole = $2; } + | T_SURFACE boolean { ctx->state.surface = $2; } + | T_PLATED boolean { ctx->state.plated = $2; } + | T_NOPASTE boolean { ctx->state.nopaste = $2; } + ; + +pad_shapes: + /* empty */ + | pad_shape pad_shapes + ; + +pad_shape: + T_PADSHAPE T_QSTR { pcb_pads_padstack_begin_shape(ctx, $2); free($2); } + padshape_attrs nl { pcb_pads_padstack_end_shape(ctx); } + ; + +padshape_attrs: + /* empty */ + | '(' padshape_attr ')' padshape_attrs + ; + +padshape_attr: + T_HEIGHT coord { ctx->state.height = $2; } + | T_PADTYPE T_INTEGER { ctx->state.pad_type = $2; } + | common_layer + | common_width + ; + +/*** Pattern ***/ +pattern: + T_PATTERN T_QSTR nl { pcb_pads_reset_pattern(ctx); pcb_pads_pattern_begin(ctx, $2); free($2); } + pattern_chldrn + T_ENDPATTERN { pcb_pads_pattern_end(ctx); pcb_pads_reset_pattern(ctx); } + ; + +pattern_chldrn: + /* empty */ + | pattern_chld nl pattern_chldrn + ; + +pattern_chld: + data + | T_ORIGINPOINT '(' coord ',' coord ')' { ctx->pat_state.origin_x = XCRD($3); ctx->pat_state.origin_y = YCRD($5); } + | T_PICKPOINT '(' coord ',' coord ')' { ctx->pat_state.pick_x = XCRD($3); ctx->pat_state.pick_y = YCRD($5); } + | T_GLUEPOINT '(' coord ',' coord ')' { ctx->pat_state.glue_x = XCRD($3); ctx->pat_state.glue_y = YCRD($5); } + ; + +data: + T_DATA ':' T_INTEGER nl + data_chldrn + T_ENDDATA + ; + +data_chldrn: + /* empty */ + | data_chld nl data_chldrn + ; + +data_chld: + pad + | poly + | line + | attribute + | templatedata + | arc + | text + | wizard + + ; + +/*** Pad ***/ +pad: + T_PAD { pcb_pads_pad_begin(ctx); } + pad_attrs { pcb_pads_pad_end(ctx); } + ; + +pad_attrs: + /* empty */ + | '(' pad_attr ')' pad_attrs + ; + +pad_attr: + T_NUMBER T_INTEGER { ctx->state.pin_number = $2; } + | T_PINNAME T_QSTR { ctx->state.pin_name = $2; /* takes over $2 */ } + | T_PADSTYLE T_QSTR { pcb_pads_pad_set_style(ctx, $2); free($2); } + | T_ORIGINALPADSTYLE T_QSTR { /* what's this?! */ free($2); } + | T_ORIGINALPINNUMBER T_INTEGER { /* what's this?! */ } + | T_ROTATE real { ctx->state.rot = $2; } + | common_origin + ; + +/*** Poly ***/ +poly: + T_POLY { pcb_pads_poly_begin(ctx); } + poly_attrs { pcb_pads_poly_end(ctx); } + ; + +poly_attrs: + /* empty */ + | '(' poly_attr ')' poly_attrs + ; + +poly_attr: + + T_PROPERTY T_QSTR { pcb_pads_add_property(ctx, (pcb_any_obj_t *)ctx->state.poly, $2); free($2); } + | coord ',' coord { pcb_pads_poly_add_vertex(ctx, XCRD($1), YCRD($3)); } + | common_origin + | common_layer + | common_width + ; + +/*** Line ***/ +line: + T_LINE { pcb_pads_reset(ctx); } + line_attrs { pcb_pads_add_line(ctx); pcb_pads_reset(ctx); } + ; + +line_attrs: + /* empty */ + | '(' line_attr ')' line_attrs + ; + +line_attr: + T_ENDPOINT coord ',' coord { ctx->state.endp_x = XCRD($2); ctx->state.endp_y = YCRD($4); } + | common_origin + | common_layer + | common_width + ; + +/*** Attribute ***/ +attribute: + T_ATTRIBUTE { pcb_pads_reset(ctx); ctx->state.is_text = 0; } + attribute_attrs { pcb_pads_add_text(ctx); pcb_pads_reset(ctx); } + ; + +attribute_attrs: + /* empty */ + | '(' attribute_attr ')' attribute_attrs + ; + +attribute_attr: + T_ATTR T_QSTR T_QSTR { pcb_pads_set_attr_val(ctx, $2, $3); /* $2 and $3 are taken over */ } + | common_attr_text + | common_origin + | common_layer + ; + + +/*** Arc ***/ +arc: + T_ARC { pcb_pads_reset(ctx); } + arc_attrs { pcb_pads_add_arc(ctx); pcb_pads_reset(ctx); } + ; + +arc_attrs: + /* empty */ + | '(' arc_attr ')' arc_attrs + ; + +arc_attr: + T_RADIUS coord { ctx->state.radius = $2; } + | T_STARTANGLE real { ctx->state.arc_start = $2; } + | T_SWEEPANGLE real { ctx->state.arc_delta = $2; } + | common_origin + | common_layer + | common_width + ; + +/*** Text ***/ +text: + T_TEXT { pcb_pads_reset(ctx); ctx->state.is_text = 1; } + text_attrs { pcb_pads_add_text(ctx); pcb_pads_reset(ctx); } + ; + +text_attrs: + /* empty */ + | '(' text_attr ')' text_attrs + ; + +text_attr: + T_TEXT T_QSTR { pcb_pads_set_text_str(ctx, $2); /* $2 is taken over */ } + | T_ISFLIPPED boolean { ctx->state.flipped = $2; } + | T_ROTATE real { ctx->state.rot = $2; } + | common_attr_text + | common_origin + | common_layer + ; + +/*** Wizard & template ***/ +wizard: + T_WIZARD wizard_attrs + ; + +templatedata: + T_TEMPLATEDATA wizard_attrs + ; + +wizard_attrs: + /* empty */ + | '(' wizard_attr ')' wizard_attrs + ; + +wizard_attr: + T_VARNAME T_QSTR { free($2); } + | T_VARDATA T_QSTR { free($2); } + | common_origin + ; + +/*** Sections not interesting for pcb-rnd ***/ +boring_section: + { ctx->in_error = 1; } T_SYMBOL error T_ENDSYMBOL { ctx->in_error = 0; } + | { ctx->in_error = 1; } T_COMPONENT error T_ENDCOMPONENT { ctx->in_error = 0; } + ; Index: trunk/src_plugins/io_pads/pads_lex.ul =================================================================== --- trunk/src_plugins/io_pads/pads_lex.ul (nonexistent) +++ trunk/src_plugins/io_pads/pads_lex.ul (revision 33608) @@ -0,0 +1,75 @@ +prefix pcb_pads +by_score + +top_code + /* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * PADS IO plugin - pads lexer + * pcb-rnd Copyright (C) 2020 Tibor 'Igor2' Palinkas + * (Supported by NLnet NGI0 PET Fund in 2020) + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + #include + #include + #include "../src_plugins/io_pads/pads_gram.h" + #define lval ((pcb_pads_STYPE *)(user_ctx)) + +rule integer +regex [-]?[0-9]+ +code + lval->un.i = atoi(ULX_BUF); + return T_INTEGER; + +rule real +regex [-]?[0-9]*[.][0-9Ee+-]* +code + lval->un.d = strtod(ULX_BUF, NULL); + return T_REAL_ONLY; + +rule id +regex [a-zA-Z][a-zA-Z0-9_-]* +code + lval->un.s = rnd_strdup(ULX_BUF); + return T_ID; + +rule quoted string +regex "\([^"]*\)" +code + lval->un.s = rnd_strndup(ULX_TAGP(1), ULX_TAGL(1)); + return T_QSTR; + +rule chars +regex [!=*\n] +code + return *ULX_BUF; + +rule blank +regex [ \t\r]+ +code + ULX_IGNORE; + +/*rulestring 3D_DXF lval->un.s = rnd_strdup(ULX_BUF); return T_ID;*/ + +rulestring UNIT return T_UNIT +rulestring PCB return T_PCB Index: trunk/src_plugins/io_pads/read.c =================================================================== --- trunk/src_plugins/io_pads/read.c (nonexistent) +++ trunk/src_plugins/io_pads/read.c (revision 33608) @@ -0,0 +1,55 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * PADS IO plugin - read: decode, parse, interpret + * pcb-rnd Copyright (C) 2020 Tibor 'Igor2' Palinkas + * (Supported by NLnet NGI0 PET Fund in 2020) + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" + +#include +#include + +#include +#include +#include +#include "board.h" + +#include "read.h" +#include "pads_lex.h" +#include "pads_gram.h" + + +int io_pads_test_parse(pcb_plug_io_t *ctx, pcb_plug_iot_t typ, const char *Filename, FILE *f) +{ + return 0; +} + +int io_pads_parse_pcb(pcb_plug_io_t *ctx, pcb_board_t *Ptr, const char *Filename, rnd_conf_role_t settings_dest) +{ + return -1; +} + + Index: trunk/src_plugins/io_pads/read.h =================================================================== --- trunk/src_plugins/io_pads/read.h (nonexistent) +++ trunk/src_plugins/io_pads/read.h (revision 33608) @@ -0,0 +1,7 @@ +#include +#include "plug_io.h" + +int io_pads_test_parse(pcb_plug_io_t *ctx, pcb_plug_iot_t typ, const char *Filename, FILE *f); +int io_pads_parse_pcb(pcb_plug_io_t *ctx, pcb_board_t *Ptr, const char *Filename, rnd_conf_role_t settings_dest); + + Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 33607) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 33608) @@ -78,6 +78,7 @@ include {../src_plugins/io_kicad_legacy/Plug.tmpasm} include {../src_plugins/io_lihata/Plug.tmpasm} include {../src_plugins/io_mentor_cell/Plug.tmpasm} +include {../src_plugins/io_pads/Plug.tmpasm} include {../src_plugins/io_pcb/Plug.tmpasm} include {../src_plugins/io_tedax/Plug.tmpasm} include {../src_plugins/jostle/Plug.tmpasm}