Fixed Makefile.
[libabstract.git] / src / poly.c
blobf72b83385c8ca8e3e5067f0c14c6dcc2ea2fa730
1 /*
2 poly.c: Polymorphic Data Types
4 Copyright (c) 2007, Matthew Schmidt <matt.alboin@gmail.com>
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <time.h>
24 #include "alboin.h"
25 #include "ll.h"
26 #include "hash.h"
27 #include "poly.h"
29 poly m_poly_new(char type, ...) {
30 va_list list;
31 poly ret;
33 /* Set initial. */
34 ret.type = type;
36 va_start(list, type);
37 switch(type) {
38 case M_PTR:
39 ret._ptr = va_arg(list, void*);
40 break;
41 case M_CHAR:
42 ret._char = va_arg(list, char);
43 break;
44 case M_STRING:
45 ret._string = va_arg(list, char*);
46 break;
47 case M_SHORT:
48 ret._string = va_arg(list, short);
49 break;
50 case M_INT:
51 ret._int = va_arg(list, int);
52 break;
53 case M_LONG:
54 ret._long = va_arg(list, long);
55 break;
56 case M_LONG_LONG:
57 ret._long_long = va_arg(list, long long);
58 break;
59 case M_FLOAT:
60 ret._float = va_arg(list, float);
61 break;
62 case M_DOUBLE:
63 ret._double = va_arg(list, double);
64 break;
67 return ret;