2685767a |
1 | /* -*-c-*- |
2 | * |
1256557a |
3 | * $Id$ |
dbfee00a |
4 | * |
5 | * Abstract field operations |
2685767a |
6 | * |
2685767a |
7 | * (c) 2001 Straylight/Edgeware |
8 | */ |
9 | |
45c0fd36 |
10 | /*----- Licensing notice --------------------------------------------------* |
2685767a |
11 | * |
12 | * This file is part of Catacomb. |
13 | * |
14 | * Catacomb is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU Library General Public License as |
16 | * published by the Free Software Foundation; either version 2 of the |
17 | * License, or (at your option) any later version. |
45c0fd36 |
18 | * |
2685767a |
19 | * Catacomb is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | * GNU Library General Public License for more details. |
45c0fd36 |
23 | * |
2685767a |
24 | * You should have received a copy of the GNU Library General Public |
25 | * License along with Catacomb; if not, write to the Free |
26 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
27 | * MA 02111-1307, USA. |
28 | */ |
29 | |
2685767a |
30 | /*----- Header files ------------------------------------------------------*/ |
31 | |
32 | #include "field.h" |
33 | #include "mp.h" |
34 | |
35 | /*----- Main code ---------------------------------------------------------*/ |
36 | |
37 | /* --- @field_id@ --- * |
38 | * |
39 | * Arguments: @field *f@ = pointer to a field |
40 | * @mp *d@ = a destination element |
41 | * @mp *x@ = a source element |
42 | * |
43 | * Returns: The result element. |
44 | * |
45 | * Use: An identity operation which can be used if your field has no |
46 | * internal representation. |
47 | */ |
48 | |
49 | mp *field_id(field *f, mp *d, mp *x) |
1256557a |
50 | { x = MP_COPY(x); if (d) MP_DROP(d); return (x); } |
2685767a |
51 | |
34e4f738 |
52 | /* --- @field_samep@ --- * |
53 | * |
54 | * Arguments: @field *f, *g@ = two fields |
55 | * |
56 | * Returns: Nonzero if the fields are identical (not just isomorphic). |
57 | * |
58 | * Use: Checks for sameness of fields. This function does the full |
59 | * check, not just the field-type-specific check done by the |
60 | * @sampep@ field operation. |
61 | */ |
62 | |
63 | int field_samep(field *f, field *g) |
1256557a |
64 | { return (f == g || (f->ops == g->ops && F_SAMEP(f, g))); } |
34e4f738 |
65 | |
66 | /* --- @field_stdsamep@ --- * |
67 | * |
68 | * Arguments: @field *f, *g@ = two fields |
69 | * |
70 | * Returns: Nonzero if the fields are identical (not just isomorphic). |
71 | * |
72 | * Use: Standard sameness check, based on equality of the @m@ |
73 | * member. |
74 | */ |
75 | |
1256557a |
76 | int field_stdsamep(field *f, field *g) { return (MP_EQ(f->m, g->m)); } |
34e4f738 |
77 | |
2685767a |
78 | /*----- That's all, folks -------------------------------------------------*/ |