Index: src/Makefile.in =================================================================== --- src/Makefile.in (revision 1076) +++ src/Makefile.in (revision 1077) @@ -12,6 +12,7 @@ # main: objects put /local/pcb/OBJS [@ action.o + action_funchash.o buffer.o change.o clip.o Index: src/action.c =================================================================== --- src/action.c (revision 1076) +++ src/action.c (revision 1077) @@ -1,5 +1,3 @@ -/* 15 Oct 2008 Ineiev: add CycleCrosshair action */ - /* * COPYRIGHT * @@ -84,136 +82,6 @@ #include #endif -/* --------------------------------------------------------------------------- - * some local types - */ -typedef enum { - F_AddSelected, - F_All, - F_AllConnections, - F_AllRats, - F_AllUnusedPins, - F_Arc, - F_Arrow, - F_Block, - F_Description, - F_Cancel, - F_Center, - F_Clear, - F_ClearAndRedraw, - F_ClearList, - F_Close, - F_Connection, - F_Convert, - F_Copy, - F_CycleClip, - F_CycleCrosshair, - F_DeleteRats, - F_Drag, - F_DrillReport, - F_Element, - F_ElementByName, - F_ElementConnections, - F_ElementToBuffer, - F_Escape, - F_Find, - F_FlipElement, - F_FoundPins, - F_Grid, - F_InsertPoint, - F_Layer, - F_Layout, - F_LayoutAs, - F_LayoutToBuffer, - F_Line, - F_LineSize, - F_Lock, - F_Mirror, - F_Move, - F_NameOnPCB, - F_Netlist, - F_NetByName, - F_None, - F_Notify, - F_Object, - F_ObjectByName, - F_PasteBuffer, - F_PadByName, - F_PinByName, - F_PinOrPadName, - F_Pinout, - F_Polygon, - F_PolygonHole, - F_PreviousPoint, - F_RatsNest, - F_Rectangle, - F_Redraw, - F_Release, - F_Revert, - F_Remove, - F_RemoveSelected, - F_Report, - F_Reset, - F_ResetLinesAndPolygons, - F_ResetPinsViasAndPads, - F_Restore, - F_Rotate, - F_Save, - F_Selected, - F_SelectedArcs, - F_SelectedElements, - F_SelectedLines, - F_SelectedNames, - F_SelectedObjects, - F_SelectedPads, - F_SelectedPins, - F_SelectedTexts, - F_SelectedVias, - F_SelectedRats, - F_Stroke, - F_Text, - F_TextByName, - F_TextScale, - F_Thermal, - F_ToLayout, - F_ToggleAllDirections, - F_ToggleAutoDRC, - F_ToggleClearLine, - F_ToggleFullPoly, - F_ToggleGrid, - F_ToggleHideNames, - F_ToggleMinCut, - F_ToggleMask, - F_ToggleName, - F_ToggleObject, - F_ToggleShowDRC, - F_ToggleLiveRoute, - F_ToggleRubberBandMode, - F_ToggleStartDirection, - F_ToggleSnapPin, - F_ToggleSnapOffGridLine, - F_ToggleHighlightOnPoint, - F_ToggleThindraw, - F_ToggleLockNames, - F_ToggleOnlyNames, - F_ToggleThindrawPoly, - F_ToggleOrthoMove, - F_ToggleLocalRef, - F_ToggleCheckPlanes, - F_ToggleUniqueNames, - F_Via, - F_ViaByName, - F_Value, - F_ViaDrillingHole, - F_ViaSize, - F_Zoom -} FunctionID; - -typedef struct { /* used to identify subfunctions */ - char *Identifier; - FunctionID ID; -} FunctionType, *FunctionTypePtr; - /* --------------------------------------------------------------------------- */ /* %start-doc actions 00delta @@ -317,132 +185,10 @@ static bool mid_stroke = false; static BoxType StrokeBox; #endif -static FunctionType Functions[] = { - {"AddSelected", F_AddSelected}, - {"All", F_All}, - {"AllConnections", F_AllConnections}, - {"AllRats", F_AllRats}, - {"AllUnusedPins", F_AllUnusedPins}, - {"Arc", F_Arc}, - {"Arrow", F_Arrow}, - {"Block", F_Block}, - {"Description", F_Description}, - {"Cancel", F_Cancel}, - {"Center", F_Center}, - {"Clear", F_Clear}, - {"ClearAndRedraw", F_ClearAndRedraw}, - {"ClearList", F_ClearList}, - {"Close", F_Close}, - {"Connection", F_Connection}, - {"Convert", F_Convert}, - {"Copy", F_Copy}, - {"CycleClip", F_CycleClip}, - {"CycleCrosshair", F_CycleCrosshair}, - {"DeleteRats", F_DeleteRats}, - {"Drag", F_Drag}, - {"DrillReport", F_DrillReport}, - {"Element", F_Element}, - {"ElementByName", F_ElementByName}, - {"ElementConnections", F_ElementConnections}, - {"ElementToBuffer", F_ElementToBuffer}, - {"Escape", F_Escape}, - {"Find", F_Find}, - {"FlipElement", F_FlipElement}, - {"FoundPins", F_FoundPins}, - {"Grid", F_Grid}, - {"InsertPoint", F_InsertPoint}, - {"Layer", F_Layer}, - {"Layout", F_Layout}, - {"LayoutAs", F_LayoutAs}, - {"LayoutToBuffer", F_LayoutToBuffer}, - {"Line", F_Line}, - {"LineSize", F_LineSize}, - {"Lock", F_Lock}, - {"Mirror", F_Mirror}, - {"Move", F_Move}, - {"NameOnPCB", F_NameOnPCB}, - {"Netlist", F_Netlist}, - {"NetByName", F_NetByName}, - {"None", F_None}, - {"Notify", F_Notify}, - {"Object", F_Object}, - {"ObjectByName", F_ObjectByName}, - {"PasteBuffer", F_PasteBuffer}, - {"PadByName", F_PadByName}, - {"PinByName", F_PinByName}, - {"PinOrPadName", F_PinOrPadName}, - {"Pinout", F_Pinout}, - {"Polygon", F_Polygon}, - {"PolygonHole", F_PolygonHole}, - {"PreviousPoint", F_PreviousPoint}, - {"RatsNest", F_RatsNest}, - {"Rectangle", F_Rectangle}, - {"Redraw", F_Redraw}, - {"Release", F_Release}, - {"Remove", F_Remove}, - {"RemoveSelected", F_RemoveSelected}, - {"Report", F_Report}, - {"Reset", F_Reset}, - {"ResetLinesAndPolygons", F_ResetLinesAndPolygons}, - {"ResetPinsViasAndPads", F_ResetPinsViasAndPads}, - {"Restore", F_Restore}, - {"Revert", F_Revert}, - {"Rotate", F_Rotate}, - {"Save", F_Save}, - {"Selected", F_Selected}, - {"SelectedArcs", F_SelectedArcs}, - {"SelectedElements", F_SelectedElements}, - {"SelectedLines", F_SelectedLines}, - {"SelectedNames", F_SelectedNames}, - {"SelectedObjects", F_SelectedObjects}, - {"SelectedPins", F_SelectedPins}, - {"SelectedPads", F_SelectedPads}, - {"SelectedRats", F_SelectedRats}, - {"SelectedTexts", F_SelectedTexts}, - {"SelectedVias", F_SelectedVias}, - {"Stroke", F_Stroke}, - {"Text", F_Text}, - {"TextByName", F_TextByName}, - {"TextScale", F_TextScale}, - {"Thermal", F_Thermal}, - {"ToLayout", F_ToLayout}, - {"Toggle45Degree", F_ToggleAllDirections}, - {"ToggleClearLine", F_ToggleClearLine}, - {"ToggleFullPoly", F_ToggleFullPoly}, - {"ToggleGrid", F_ToggleGrid}, - {"ToggleMask", F_ToggleMask}, - {"ToggleName", F_ToggleName}, - {"ToggleObject", F_ToggleObject}, - {"ToggleRubberBandMode", F_ToggleRubberBandMode}, - {"ToggleStartDirection", F_ToggleStartDirection}, - {"ToggleSnapPin", F_ToggleSnapPin}, - {"ToggleSnapOffGridLine", F_ToggleSnapOffGridLine}, - {"ToggleHighlightOnPoint", F_ToggleHighlightOnPoint}, - {"ToggleThindraw", F_ToggleThindraw}, - {"ToggleThindrawPoly", F_ToggleThindrawPoly}, - {"ToggleLockNames", F_ToggleLockNames}, - {"ToggleOnlyNames", F_ToggleOnlyNames}, - {"ToggleHideNames", F_ToggleHideNames}, - {"ToggleMinCut", F_ToggleMinCut}, - {"ToggleCheckPlanes", F_ToggleCheckPlanes}, - {"ToggleLocalRef", F_ToggleLocalRef}, - {"ToggleOrthoMove", F_ToggleOrthoMove}, - {"ToggleShowDRC", F_ToggleShowDRC}, - {"ToggleLiveRoute", F_ToggleLiveRoute}, - {"ToggleAutoDRC", F_ToggleAutoDRC}, - {"ToggleUniqueNames", F_ToggleUniqueNames}, - {"Value", F_Value}, - {"Via", F_Via}, - {"ViaByName", F_ViaByName}, - {"ViaSize", F_ViaSize}, - {"ViaDrillingHole", F_ViaDrillingHole}, - {"Zoom", F_Zoom} -}; /* --------------------------------------------------------------------------- * some local routines */ -static int GetFunctionID(String); static void AdjustAttachedBox(void); static void NotifyLine(void); static void NotifyBlock(void); @@ -762,67 +508,6 @@ } /* --------------------------------------------------------------------------- - * get function ID of passed string - */ -#define HSIZE 257 -static char function_hash[HSIZE]; -static int hash_initted = 0; - -static int hashfunc(String s) -{ - int i = 0; - while (*s) { - i ^= i >> 16; - i = (i * 13) ^ (unsigned char) tolower((int) *s); - s++; - } - i = (unsigned int) i % HSIZE; - return i; -} - -static int GetFunctionID(String Ident) -{ - int i, h; - - if (Ident == 0) - return -1; - - if (!hash_initted) { - hash_initted = 1; - if (HSIZE < ENTRIES(Functions) * 2) { - fprintf(stderr, _("Error: function hash size too small (%d vs %lu at %s:%d)\n"), - HSIZE, (unsigned long) ENTRIES(Functions) * 2, __FILE__, __LINE__); - exit(1); - } - if (ENTRIES(Functions) > 254) { - /* Change 'char' to 'int' and remove this when we get to 256 - strings to hash. */ - fprintf(stderr, _("Error: function hash type too small (%d vs %lu at %s:%d)\n"), - 256, (unsigned long) ENTRIES(Functions), __FILE__, __LINE__); - exit(1); - - } - for (i = ENTRIES(Functions) - 1; i >= 0; i--) { - h = hashfunc(Functions[i].Identifier); - while (function_hash[h]) - h = (h + 1) % HSIZE; - function_hash[h] = i + 1; - } - } - - i = hashfunc(Ident); - while (1) { - /* We enforce the "hash table bigger than function table" rule, - so we know there will be at least one zero entry to find. */ - if (!function_hash[i]) - return (-1); - if (!strcasecmp(Ident, Functions[function_hash[i] - 1].Identifier)) - return ((int) Functions[function_hash[i] - 1].ID); - i = (i + 1) % HSIZE; - } -} - -/* --------------------------------------------------------------------------- * set new coordinates if in 'RECTANGLE' mode * the cursor shape is also adjusted */ Index: src/action.h =================================================================== --- src/action.h (revision 1076) +++ src/action.h (revision 1077) @@ -46,4 +46,13 @@ bool ActionGetLocation(char *); void ActionGetXY(char *); +#define action_entry(x) F_ ## x, +typedef enum { +#include "action_funclist.h" +F_END +} FunctionID; +#undef action_entry + +#include "action_funchash.h" + #endif Index: src/action_funchash.c =================================================================== --- src/action_funchash.c (nonexistent) +++ src/action_funchash.c (revision 1077) @@ -0,0 +1,94 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact addresses for paper mail and Email: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ +#include "action.h" + +#define action_entry(x) { #x, F_ ## x}, +static FunctionType Functions[] = { +#include "action_funclist.h" + {"F_END", F_END} +}; + +/* --------------------------------------------------------------------------- + * get function ID of passed string + */ +#define HSIZE 257 +static char function_hash[HSIZE]; +static int hash_initted = 0; + +static int hashfunc(String s) +{ + int i = 0; + while (*s) { + i ^= i >> 16; + i = (i * 13) ^ (unsigned char) tolower((int) *s); + s++; + } + i = (unsigned int) i % HSIZE; + return i; +} + +int GetFunctionID(String Ident) +{ + int i, h; + + if (Ident == 0) + return -1; + + if (!hash_initted) { + hash_initted = 1; + if (HSIZE < ENTRIES(Functions) * 2) { + fprintf(stderr, _("Error: function hash size too small (%d vs %lu at %s:%d)\n"), + HSIZE, (unsigned long) ENTRIES(Functions) * 2, __FILE__, __LINE__); + exit(1); + } + if (ENTRIES(Functions) > 254) { + /* Change 'char' to 'int' and remove this when we get to 256 + strings to hash. */ + fprintf(stderr, _("Error: function hash type too small (%d vs %lu at %s:%d)\n"), + 256, (unsigned long) ENTRIES(Functions), __FILE__, __LINE__); + exit(1); + + } + for (i = ENTRIES(Functions) - 1; i >= 0; i--) { + h = hashfunc(Functions[i].Identifier); + while (function_hash[h]) + h = (h + 1) % HSIZE; + function_hash[h] = i + 1; + } + } + + i = hashfunc(Ident); + while (1) { + /* We enforce the "hash table bigger than function table" rule, + so we know there will be at least one zero entry to find. */ + if (!function_hash[i]) + return (-1); + if (!strcasecmp(Ident, Functions[function_hash[i] - 1].Identifier)) + return ((int) Functions[function_hash[i] - 1].ID); + i = (i + 1) % HSIZE; + } +} Index: src/action_funchash.h =================================================================== --- src/action_funchash.h (nonexistent) +++ src/action_funchash.h (revision 1077) @@ -0,0 +1,35 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact addresses for paper mail and Email: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +typedef struct { /* used to identify subfunctions */ + char *Identifier; + FunctionID ID; +} FunctionType, *FunctionTypePtr; + +/* Convert function name to integer function id */ +int GetFunctionID(String Ident); + Index: src/action_funclist.h =================================================================== --- src/action_funclist.h (nonexistent) +++ src/action_funclist.h (revision 1077) @@ -0,0 +1,125 @@ +/* + Central list of function IDs + The core and core plugins use these from a single, central hash + This list is used to cpp-generate the F_* constants in enum FunctionID +*/ +action_entry(AddSelected) +action_entry(All) +action_entry(AllConnections) +action_entry(AllRats) +action_entry(AllUnusedPins) +action_entry(Arc) +action_entry(Arrow) +action_entry(Block) +action_entry(Description) +action_entry(Cancel) +action_entry(Center) +action_entry(Clear) +action_entry(ClearAndRedraw) +action_entry(ClearList) +action_entry(Close) +action_entry(Connection) +action_entry(Convert) +action_entry(Copy) +action_entry(CycleClip) +action_entry(CycleCrosshair) +action_entry(DeleteRats) +action_entry(Drag) +action_entry(DrillReport) +action_entry(Element) +action_entry(ElementByName) +action_entry(ElementConnections) +action_entry(ElementToBuffer) +action_entry(Escape) +action_entry(Find) +action_entry(FlipElement) +action_entry(FoundPins) +action_entry(Grid) +action_entry(InsertPoint) +action_entry(Layer) +action_entry(Layout) +action_entry(LayoutAs) +action_entry(LayoutToBuffer) +action_entry(Line) +action_entry(LineSize) +action_entry(Lock) +action_entry(Mirror) +action_entry(Move) +action_entry(NameOnPCB) +action_entry(Netlist) +action_entry(NetByName) +action_entry(None) +action_entry(Notify) +action_entry(Object) +action_entry(ObjectByName) +action_entry(PasteBuffer) +action_entry(PadByName) +action_entry(PinByName) +action_entry(PinOrPadName) +action_entry(Pinout) +action_entry(Polygon) +action_entry(PolygonHole) +action_entry(PreviousPoint) +action_entry(RatsNest) +action_entry(Rectangle) +action_entry(Redraw) +action_entry(Release) +action_entry(Revert) +action_entry(Remove) +action_entry(RemoveSelected) +action_entry(Report) +action_entry(Reset) +action_entry(ResetLinesAndPolygons) +action_entry(ResetPinsViasAndPads) +action_entry(Restore) +action_entry(Rotate) +action_entry(Save) +action_entry(Selected) +action_entry(SelectedArcs) +action_entry(SelectedElements) +action_entry(SelectedLines) +action_entry(SelectedNames) +action_entry(SelectedObjects) +action_entry(SelectedPads) +action_entry(SelectedPins) +action_entry(SelectedTexts) +action_entry(SelectedVias) +action_entry(SelectedRats) +action_entry(Stroke) +action_entry(Text) +action_entry(TextByName) +action_entry(TextScale) +action_entry(Thermal) +action_entry(ToLayout) +action_entry(ToggleAllDirections) +action_entry(ToggleAutoDRC) +action_entry(ToggleClearLine) +action_entry(ToggleFullPoly) +action_entry(ToggleGrid) +action_entry(ToggleHideNames) +action_entry(ToggleMinCut) +action_entry(ToggleMask) +action_entry(ToggleName) +action_entry(ToggleObject) +action_entry(ToggleShowDRC) +action_entry(ToggleLiveRoute) +action_entry(ToggleRubberBandMode) +action_entry(ToggleStartDirection) +action_entry(ToggleSnapPin) +action_entry(ToggleSnapOffGridLine) +action_entry(ToggleHighlightOnPoint) +action_entry(ToggleThindraw) +action_entry(ToggleLockNames) +action_entry(ToggleOnlyNames) +action_entry(ToggleThindrawPoly) +action_entry(ToggleOrthoMove) +action_entry(ToggleLocalRef) +action_entry(ToggleCheckPlanes) +action_entry(ToggleUniqueNames) +action_entry(Via) +action_entry(ViaByName) +action_entry(Value) +action_entry(ViaDrillingHole) +action_entry(ViaSize) +action_entry(Zoom) + Index: src/action_list.h =================================================================== --- src/action_list.h (nonexistent) +++ src/action_list.h (revision 1077) @@ -0,0 +1,75 @@ +/* gui hid/gtk */ +/* gui hid/lesstif */ +/* gui hid/batch */ +/* export hid/ps */ +/* export hid/png */ +/* export hid/gcode */ +/* export hid/nelma */ +/* hid/png (export) */ +REGISTER_ATTRIBUTES(png_attribute_list) + +/* move.c () */ +REGISTER_ACTIONS(move_action_list) + +/* main.c () */ +REGISTER_ATTRIBUTES(main_attribute_list) + +/* command.c () */ +REGISTER_ACTIONS(command_action_list) + +/* action.c () */ +REGISTER_ACTIONS(action_action_list) + +/* hid/ps (export) */ +REGISTER_ATTRIBUTES(ps_attribute_list) +REGISTER_ATTRIBUTES(eps_attribute_list) + +/* hid/gtk (gui) */ +if ((gui != NULL) && (strcmp(gui->name, "gtk") == 0)) { +REGISTER_ATTRIBUTES(ghid_attribute_list) +REGISTER_ACTIONS(gtk_topwindow_action_list) +REGISTER_ACTIONS(ghid_menu_action_list) +REGISTER_ACTIONS(ghid_netlist_action_list) +REGISTER_ACTIONS(ghid_log_action_list) +REGISTER_ACTIONS(ghid_main_action_list) +REGISTER_FLAGS(ghid_main_flag_list) + +} +/* hid/nelma (export) */ +REGISTER_ATTRIBUTES(nelma_attribute_list) + +/* report.c () */ +REGISTER_ACTIONS(report_action_list) + +/* netlist.c () */ +REGISTER_ACTIONS(netlist_action_list) + +/* misc.c () */ +REGISTER_ACTIONS(misc_action_list) + +/* flags.c () */ +REGISTER_FLAGS(flags_flag_list) + +/* buffer.c () */ +REGISTER_ACTIONS(rotate_action_list) + +/* hid/gcode (export) */ +REGISTER_ATTRIBUTES(gcode_attribute_list) + +/* hid/batch (gui) */ +if ((gui != NULL) && (strcmp(gui->name, "batch") == 0)) { +REGISTER_ACTIONS(batch_action_list) + +} +/* hid/lesstif (gui) */ +if ((gui != NULL) && (strcmp(gui->name, "lesstif") == 0)) { +REGISTER_ACTIONS(lesstif_library_action_list) +REGISTER_ACTIONS(lesstif_menu_action_list) +REGISTER_FLAGS(lesstif_main_flag_list) +REGISTER_ATTRIBUTES(lesstif_attribute_list) +REGISTER_ACTIONS(lesstif_main_action_list) +REGISTER_ACTIONS(lesstif_styles_action_list) +REGISTER_ACTIONS(lesstif_dialog_action_list) +REGISTER_ACTIONS(lesstif_netlist_action_list) + +}