Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2004 David A. Schleef <ds@schleef.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
30 #include <liboil/liboil.h>
31 #include <liboil/liboilfunction.h>
36 #define LOG_FILE "c:\\logs\\testsuite_introspect_log.txt"
37 #include "std_log_result.h"
38 #define LOG_FILENAME_LINE __FILE__, __LINE__
40 void create_xml(int result)
45 testResultXml("testsuite_introspect");
49 void parse_prototype (const char *s);
51 int main (int argc, char *argv[])
53 OilFunctionClass *klass;
54 OilFunctionImpl *impl;
59 std_log(LOG_FILENAME_LINE,"Test started testsuite_introspect");
62 n = oil_class_get_n_classes ();
66 klass = oil_class_get_by_index (i);
68 std_log(LOG_FILENAME_LINE,"class: %s\n", klass->name);
69 for(impl = klass->first_impl; impl; impl=impl->next) {
70 std_log(LOG_FILENAME_LINE," %s %s %s\n", impl->name,
71 (impl->flags&OIL_IMPL_FLAG_REF)?"(ref)":"",
72 (impl->flags&OIL_IMPL_FLAG_OPT)?"(opt)":"");
73 if (impl->flags & OIL_IMPL_FLAG_REF) {
78 std_log(LOG_FILENAME_LINE,"ERROR: no reference function\n");
82 std_log(LOG_FILENAME_LINE,"ERROR: more than one reference function\n");
85 if (klass->prototype == NULL) {
86 std_log(LOG_FILENAME_LINE,"ERROR: prototype is NULL\n");
90 printf ("#define %s ((void (*)(%s)) \\\n\t_oil_function_%s_class.func)\n",
91 klass->name, klass->prototype, klass->name);
92 //printf("void %s (%s);\n", klass->name, klass->prototype);
93 parse_prototype(klass->prototype);
97 assert_failed = (errors == 0) ? assert_failed : 1;
99 std_log(LOG_FILENAME_LINE,"Test Fail");
101 std_log(LOG_FILENAME_LINE,"Test Successful");
107 static char *typenames[] = {
127 static int parse_type (char *s, char **endptr)
131 while(isspace((int)*s))s++;
134 if(strncmp(typenames[i],s,strlen(typenames[i]))==0){
135 *endptr = s + strlen(typenames[i]);
136 return OIL_TYPE_s8 + i;
140 return OIL_TYPE_UNKNOWN;
143 static int parse_size (const char *s, char **endptr)
145 while(isspace((int)*s))s++;
148 *endptr = (char *)(s + 1);
151 if(isdigit((int)s[0])){
152 return strtol(s,endptr,0);
160 xstrndup (const char *s, int n)
174 static char * parse_string (const char *s, const char **endptr)
179 while(isalnum((int)*s) || *s=='_') {
184 return xstrndup(s0, s - s0);
187 void parse_prototype (const char *s)
193 while (isspace((int)*s))s++;
195 type = parse_string (s, &s);
197 while (isspace((int)*s))s++;
203 while (isspace((int)*s))s++;
204 name = parse_string (s, &s);
206 while (isspace((int)*s))s++;
211 while (isspace((int)*s))s++;
213 std_log(LOG_FILENAME_LINE,"%s %s\n", type, name);