~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/tools/winedump/output.c

Version: ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  *  Code generation functions
  3  *
  4  *  Copyright 2000-2002 Jon Griffiths
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "config.h"
 22 #include "wine/port.h"
 23 
 24 #include "winedump.h"
 25 
 26 /* Output files */
 27 static FILE *specfile = NULL;
 28 static FILE *hfile    = NULL;
 29 static FILE *cfile    = NULL;
 30 
 31 static void  output_spec_postamble (void);
 32 static void  output_header_postamble (void);
 33 static void  output_c_postamble (void);
 34 static void  output_c_banner (const parsed_symbol *sym);
 35 static const char *get_format_str (int type);
 36 static const char *get_in_or_out (const parsed_symbol *sym, size_t arg);
 37 
 38 
 39 /*******************************************************************
 40  *         output_spec_preamble
 41  *
 42  * Write the first part of the .spec file
 43  */
 44 void  output_spec_preamble (void)
 45 {
 46   specfile = open_file (OUTPUT_DLL_NAME, ".spec", "w");
 47 
 48   atexit (output_spec_postamble);
 49 
 50   if (VERBOSE)
 51     puts ("Creating .spec preamble");
 52 
 53   fprintf (specfile,
 54            "# Generated from %s by winedump\n\n", globals.input_name);
 55 }
 56 
 57 
 58 /*******************************************************************
 59  *         output_spec_symbol
 60  *
 61  * Write a symbol to the .spec file
 62  */
 63 void  output_spec_symbol (const parsed_symbol *sym)
 64 {
 65   char ord_spec[16];
 66 
 67   assert (specfile);
 68   assert (sym && sym->symbol);
 69 
 70   if (sym->ordinal >= 0)
 71     snprintf(ord_spec, 8, "%d", sym->ordinal);
 72   else
 73   {
 74     ord_spec[0] = '@';
 75     ord_spec[1] = '\0';
 76   }
 77   if (sym->flags & SYM_THISCALL)
 78     strcat (ord_spec, " -i386"); /* For binary compatibility only */
 79 
 80   if (!globals.do_code || !sym->function_name)
 81   {
 82     if (sym->flags & SYM_DATA)
 83     {
 84       if (globals.forward_dll)
 85         fprintf (specfile, "%s forward %s %s.%s #", ord_spec, sym->symbol,
 86                  globals.forward_dll, sym->symbol);
 87 
 88       fprintf (specfile, "%s extern %s %s\n", ord_spec, sym->symbol,
 89                sym->arg_name[0]);
 90       return;
 91     }
 92 
 93     if (globals.forward_dll)
 94       fprintf (specfile, "%s forward %s %s.%s\n", ord_spec, sym->symbol,
 95                globals.forward_dll, sym->symbol);
 96     else
 97       fprintf (specfile, "%s stub %s\n", ord_spec, sym->symbol);
 98   }
 99   else
100   {
101     unsigned int i = sym->flags & SYM_THISCALL ? 1 : 0;
102 
103     fprintf (specfile, "%s %s %s(", ord_spec, sym->varargs ? "varargs" :
104              symbol_get_call_convention(sym), sym->symbol);
105 
106     for (; i < sym->argc; i++)
107       fprintf (specfile, " %s", symbol_get_spec_type(sym, i));
108 
109     if (sym->argc)
110       fputc (' ', specfile);
111     fputs (") ", specfile);
112 
113     if (sym->flags & SYM_THISCALL)
114       fputs ("__thiscall_", specfile);
115     fprintf (specfile, "%s_%s", OUTPUT_UC_DLL_NAME, sym->function_name);
116 
117     fputc ('\n',specfile);
118   }
119 }
120 
121 
122 /*******************************************************************
123  *         output_spec_postamble
124  *
125  * Write the last part of the .spec file
126  */
127 static void output_spec_postamble (void)
128 {
129   if (specfile)
130     fclose (specfile);
131   specfile = NULL;
132 }
133 
134 
135 /*******************************************************************
136  *         output_header_preamble
137  *
138  * Write the first part of the .h file
139  */
140 void  output_header_preamble (void)
141 {
142   if (!globals.do_code)
143       return;
144 
145   hfile = open_file (OUTPUT_DLL_NAME, "_dll.h", "w");
146 
147   atexit (output_header_postamble);
148 
149   fprintf (hfile,
150            "/*\n * %s.dll\n *\n * Generated from %s.dll by winedump.\n *\n"
151            " * DO NOT SEND GENERATED DLLS FOR INCLUSION INTO WINE !\n * \n */"
152            "\n#ifndef __WINE_%s_DLL_H\n#define __WINE_%s_DLL_H\n\n"
153            "#include \"windef.h\"\n#include \"wine/debug.h\"\n"
154            "#include \"winbase.h\"\n#include \"winnt.h\"\n\n\n",
155            OUTPUT_DLL_NAME, OUTPUT_DLL_NAME, OUTPUT_UC_DLL_NAME,
156            OUTPUT_UC_DLL_NAME);
157 }
158 
159 
160 /*******************************************************************
161  *         output_header_symbol
162  *
163  * Write a symbol to the .h file
164  */
165 void  output_header_symbol (const parsed_symbol *sym)
166 {
167   if (!globals.do_code)
168       return;
169 
170   assert (hfile);
171   assert (sym && sym->symbol);
172 
173   if (!globals.do_code)
174     return;
175 
176   if (sym->flags & SYM_DATA)
177     return;
178 
179   if (!sym->function_name)
180     fprintf (hfile, "/* __%s %s_%s(); */\n", symbol_get_call_convention(sym),
181              OUTPUT_UC_DLL_NAME, sym->symbol);
182   else
183   {
184     output_prototype (hfile, sym);
185     fputs (";\n", hfile);
186   }
187 }
188 
189 
190 /*******************************************************************
191  *         output_header_postamble
192  *
193  * Write the last part of the .h file
194  */
195 static void output_header_postamble (void)
196 {
197   if (hfile)
198   {
199     fprintf (hfile, "\n\n\n#endif\t/* __WINE_%s_DLL_H */\n",
200              OUTPUT_UC_DLL_NAME);
201     fclose (hfile);
202     hfile = NULL;
203   }
204 }
205 
206 
207 /*******************************************************************
208  *         output_c_preamble
209  *
210  * Write the first part of the .c file
211  */
212 void  output_c_preamble (void)
213 {
214   cfile = open_file (OUTPUT_DLL_NAME, "_main.c", "w");
215 
216   atexit (output_c_postamble);
217 
218   fprintf (cfile,
219            "/*\n * %s.dll\n *\n * Generated from %s by winedump.\n *\n"
220            " * DO NOT SUBMIT GENERATED DLLS FOR INCLUSION INTO WINE!\n *\n */"
221            "\n\n#include \"config.h\"\n\n#include <stdarg.h>\n\n"
222            "#include \"windef.h\"\n#include \"winbase.h\"\n",
223            OUTPUT_DLL_NAME, globals.input_name);
224 
225   if (globals.do_code)
226     fprintf (cfile, "#include \"%s_dll.h\"\n", OUTPUT_DLL_NAME);
227 
228   fprintf (cfile,"#include \"wine/debug.h\"\n\nWINE_DEFAULT_DEBUG_CHANNEL(%s);\n\n",
229            OUTPUT_DLL_NAME);
230 
231   if (globals.forward_dll)
232   {
233     if (VERBOSE)
234       puts ("Creating a forwarding DLL");
235 
236     fputs ("\nHMODULE hDLL=0;\t/* DLL to call */\n\n", cfile);
237   }
238 
239   fprintf (cfile,
240            "BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID "
241            "lpvReserved)\n{\n"
242            "\tTRACE(\"(0x%%p, %%d, %%p)\\n\", hinstDLL, fdwReason, lpvReserved);\n"
243            "\n\tswitch (fdwReason)\n\t{\n"
244            "\t\tcase DLL_WINE_PREATTACH:\n"
245            "\t\t\treturn FALSE;    /* prefer native version */\n"
246            "\t\tcase DLL_PROCESS_ATTACH:\n");
247 
248   if (globals.forward_dll)
249     fprintf (cfile, "\t\t\thDLL = LoadLibraryA(\"%s\");\n"
250              "\t\t\tTRACE(\"Forwarding DLL (%s) loaded (%%p)\\n\", hDLL);\n",
251              globals.forward_dll, globals.forward_dll);
252   else
253     fprintf (cfile, "\t\t\t/* FIXME: Initialisation */\n"
254              "\t\t\tDisableThreadLibraryCalls(hinstDLL);\n\t\t\tbreak;\n");
255 
256   fprintf (cfile, "\t\t\tbreak;\n\t\tcase DLL_PROCESS_DETACH:\n");
257 
258   if (globals.forward_dll)
259     fprintf (cfile, "\t\t\tFreeLibrary(hDLL);\n"
260              "\t\t\tTRACE(\"Forwarding DLL (%s) freed\\n\");\n",
261              globals.forward_dll);
262 
263   fprintf (cfile, "\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n"
264            "\treturn TRUE;\n}\n\n\n");
265 }
266 
267 
268 /*******************************************************************
269  *         output_c_symbol
270  *
271  * Write a symbol to the .c file
272  */
273 void  output_c_symbol (const parsed_symbol *sym)
274 {
275   unsigned int i, start = sym->flags & SYM_THISCALL ? 1 : 0;
276   int is_void;
277   static int has_thiscall = 0;
278 
279   assert (cfile);
280   assert (sym && sym->symbol);
281 
282   if (!globals.do_code)
283     return;
284 
285   if (sym->flags & SYM_DATA)
286   {
287     fprintf (cfile, "/* FIXME: Move to top of file */\n%s;\n\n",
288              sym->arg_text[0]);
289     return;
290   }
291 
292   if (sym->flags & SYM_THISCALL && !has_thiscall)
293   {
294     fputs ("#ifdef __i386__  /* thiscall functions are i386-specific */\n\n"
295            "#define THISCALL(func) __thiscall_ ## func\n"
296            "#define THISCALL_NAME(func) __ASM_NAME(\"__thiscall_\" #func)\n"
297            "#define DEFINE_THISCALL_WRAPPER(func) \\\n"
298            "\textern void THISCALL(func)(); \\\n"
299            "\t__ASM_GLOBAL_FUNC(__thiscall_ ## func, \\\n"
300            "\t\t\t\"popl %eax\\n\\t\" \\\n"
301            "\t\t\t\"pushl %ecx\\n\\t\" \\\n"
302            "\t\t\t\"pushl %eax\\n\\t\" \\\n"
303            "\t\t\t\"jmp \" __ASM_NAME(#func) )\n"
304            "#else /* __i386__ */\n\n"
305            "#define THISCALL(func) func\n"
306            "#define THISCALL_NAME(func) __ASM_NAME(#func)\n"
307            "#define DEFINE_THISCALL_WRAPPER(func) /* nothing */\n\n"
308            "#endif /* __i386__ */\n\n", cfile);
309     has_thiscall = 1;
310   }
311 
312   output_c_banner(sym);
313 
314   if (sym->flags & SYM_THISCALL)
315     fprintf(cfile, "DEFINE_THISCALL_WRAPPER(%s)\n", sym->function_name);
316 
317   if (!sym->function_name)
318   {
319     /* #ifdef'd dummy */
320     fprintf (cfile, "#if 0\n__%s %s_%s()\n{\n\t/* %s in .spec */\n}\n#endif\n",
321              symbol_get_call_convention(sym), OUTPUT_UC_DLL_NAME, sym->symbol,
322              globals.forward_dll ? "@forward" : "@stub");
323     return;
324   }
325 
326   is_void = !strcmp (sym->return_text, "void");
327 
328   output_prototype (cfile, sym);
329   fputs ("\n{\n", cfile);
330 
331   if (!globals.do_trace)
332   {
333     fputs ("\tFIXME(\":stub\\n\");\n", cfile);
334     if (!is_void)
335         fprintf (cfile, "\treturn (%s) 0;\n", sym->return_text);
336     fputs ("}\n", cfile);
337     return;
338   }
339 
340   /* Tracing, maybe forwarding as well */
341   if (globals.forward_dll)
342   {
343     /* Write variables for calling */
344     if (sym->varargs)
345       fputs("\tva_list valist;\n", cfile);
346 
347     fprintf (cfile, "\t%s (__%s *pFunc)(", sym->return_text,
348              symbol_get_call_convention(sym));
349 
350     for (i = start; i < sym->argc; i++)
351       fprintf (cfile, "%s%s", i > start ? ", " : "", sym->arg_text [i]);
352 
353     fprintf (cfile, "%s);\n", sym->varargs ? ",..." : sym->argc == 1 &&
354              sym->flags & SYM_THISCALL ? "" : sym->argc ? "" : "void");
355 
356     if (!is_void)
357       fprintf (cfile, "\t%s retVal;\n", sym->return_text);
358 
359     fprintf (cfile, "\tpFunc=(void*)GetProcAddress(hDLL,\"%s\");\n",
360              sym->symbol);
361   }
362 
363   /* TRACE input arguments */
364   fprintf (cfile, "\tTRACE(\"(%s", !sym->argc ? "void" : "");
365 
366   for (i = 0; i < sym->argc; i++)
367     fprintf (cfile, "%s(%s)%s", i ? "," : "", sym->arg_text [i],
368              get_format_str (sym->arg_type [i]));
369 
370   fprintf (cfile, "%s): %s\\n\"", sym->varargs ? ",..." : "",
371            globals.forward_dll ? "forward" : "stub");
372 
373   for (i = 0; i < sym->argc; i++)
374     if (sym->arg_type[i] != ARG_STRUCT)
375       fprintf(cfile, ",%s%s%s%s", sym->arg_type[i] == ARG_LONG ? "(LONG)" : "",
376               sym->arg_type[i] == ARG_WIDE_STRING ? "debugstr_w(" : "",
377               sym->arg_name[i],
378               sym->arg_type[i] == ARG_WIDE_STRING ? ")" : "");
379 
380   fputs (");\n", cfile);
381 
382   if (!globals.forward_dll)
383   {
384     if (!is_void)
385       fprintf (cfile, "\treturn (%s) 0;\n", sym->return_text);
386     fputs ("}\n", cfile);
387     return;
388   }
389 
390   /* Call the DLL */
391   if (sym->varargs)
392     fprintf (cfile, "\tva_start(valist,%s);\n", sym->arg_name[sym->argc-1]);
393 
394   fprintf (cfile, "\t%spFunc(", !is_void ? "retVal = " : "");
395 
396   for (i = 0; i < sym->argc; i++)
397     fprintf (cfile, "%s%s", i ? "," : "", sym->arg_name [i]);
398 
399   fputs (sym->varargs ? ",valist);\n\tva_end(valist);" : ");", cfile);
400 
401   /* TRACE return value */
402   fprintf (cfile, "\n\tTRACE(\"Returned (%s)\\n\"",
403            get_format_str (sym->return_type));
404 
405   if (!is_void)
406   {
407     if (sym->return_type == ARG_WIDE_STRING)
408       fputs (",debugstr_w(retVal)", cfile);
409     else
410       fprintf (cfile, ",%s%s", sym->return_type == ARG_LONG ? "(LONG)" : "",
411                sym->return_type == ARG_STRUCT ? "" : "retVal");
412     fputs (");\n\treturn retVal;\n", cfile);
413   }
414   else
415     fputs (");\n", cfile);
416 
417   fputs ("}\n", cfile);
418 }
419 
420 
421 /*******************************************************************
422  *         output_c_postamble
423  *
424  * Write the last part of the .c file
425  */
426 static void output_c_postamble (void)
427 {
428   if (cfile)
429     fclose (cfile);
430   cfile = NULL;
431 }
432 
433 
434 /*******************************************************************
435  *         output_makefile
436  *
437  * Write a Wine compatible makefile.in
438  */
439 void  output_makefile (void)
440 {
441   FILE *makefile = open_file ("Makefile", ".in", "w");
442 
443   if (VERBOSE)
444     puts ("Creating makefile");
445 
446   fprintf (makefile,
447            "# Generated from %s by winedump.\nTOPSRCDIR = @top_srcdir@\n"
448            "TOPOBJDIR = ../..\nSRCDIR    = @srcdir@\nVPATH     = @srcdir@\n"
449            "MODULE    = %s.dll\n", globals.input_name, OUTPUT_DLL_NAME);
450 
451   fprintf (makefile, "IMPORTS   = kernel32");
452   if (globals.forward_dll)
453     fprintf (makefile, " %s", globals.forward_dll);
454 
455   fprintf (makefile,
456            "\n\nC_SRCS = \\\n\t%s_main.c\n\n@MAKE_DLL_RULES@\n\n"
457            "@DEPENDENCIES@  # everything below this line is overwritten by make depend",
458            OUTPUT_DLL_NAME);
459 
460   if (globals.forward_dll)
461     fprintf (specfile,"#import %s.dll\n", globals.forward_dll);
462 
463   fclose (makefile);
464 }
465 
466 
467 /*******************************************************************
468  *         output_prototype
469  *
470  * Write a C prototype for a parsed symbol
471  */
472 void  output_prototype (FILE *file, const parsed_symbol *sym)
473 {
474   unsigned int i, start = sym->flags & SYM_THISCALL ? 1 : 0;
475 
476   fprintf (file, "%s __%s %s_%s(", sym->return_text, symbol_get_call_convention(sym),
477            OUTPUT_UC_DLL_NAME, sym->function_name);
478 
479   if (!sym->argc || (sym->argc == 1 && sym->flags & SYM_THISCALL))
480     fputs ("void", file);
481   else
482     for (i = start; i < sym->argc; i++)
483       fprintf (file, "%s%s %s", i > start ? ", " : "", sym->arg_text [i],
484                sym->arg_name [i]);
485   if (sym->varargs)
486     fputs (", ...", file);
487   fputc (')', file);
488 }
489 
490 
491 /*******************************************************************
492  *         output_c_banner
493  *
494  * Write a function banner to the .c file
495  */
496 void  output_c_banner (const parsed_symbol *sym)
497 {
498   char ord_spec[16];
499   size_t i;
500 
501   if (sym->ordinal >= 0)
502     snprintf(ord_spec, sizeof (ord_spec), "%d", sym->ordinal);
503   else
504   {
505     ord_spec[0] = '@';
506     ord_spec[1] = '\0';
507   }
508 
509   fprintf (cfile, "/*********************************************************"
510            "*********\n *\t\t%s (%s.%s)\n *\n", sym->symbol,
511            OUTPUT_UC_DLL_NAME, ord_spec);
512 
513   if (globals.do_documentation && sym->function_name)
514   {
515     fputs (" *\n * PARAMS\n *\n", cfile);
516 
517     if (!sym->argc)
518       fputs (" *  None.\n *\n", cfile);
519     else
520     {
521       for (i = 0; i < sym->argc; i++)
522         fprintf (cfile, " *  %s [%s]%s\n", sym->arg_name [i],
523                  get_in_or_out(sym, i),
524                  strcmp (sym->arg_name [i], "_this") ? "" :
525                  "     Pointer to the class object (in ECX)");
526 
527       if (sym->varargs)
528         fputs (" *  ...[I]\n", cfile);
529       fputs (" *\n", cfile);
530     }
531 
532     fputs (" * RETURNS\n *\n", cfile);
533 
534     if (sym->return_text && !strcmp (sym->return_text, "void"))
535       fputs (" *  Nothing.\n", cfile);
536     else
537       fprintf (cfile, " *  %s\n", sym->return_text);
538   }
539   fputs (" *\n */\n", cfile);
540 }
541 
542 
543 /*******************************************************************
544  *         get_format_str
545  *
546  * Get a string containing the correct format string for a type
547  */
548 static const char *get_format_str (int type)
549 {
550   switch (type)
551   {
552   case ARG_VOID:        return "void";
553   case ARG_FLOAT:       return "%f";
554   case ARG_DOUBLE:      return "%g";
555   case ARG_POINTER:     return "%p";
556   case ARG_WIDE_STRING:
557   case ARG_STRING:      return "%s";
558   case ARG_LONG:        return "%ld";
559   case ARG_STRUCT:      return "struct";
560   }
561   assert (0);
562   return "";
563 }
564 
565 
566 /*******************************************************************
567  *         get_in_or_out
568  *
569  * Determine if a parameter is In or In/Out
570  */
571 static const char *get_in_or_out (const parsed_symbol *sym, size_t arg)
572 {
573   assert (sym && arg < sym->argc);
574   assert (globals.do_documentation);
575 
576   if (sym->arg_flag [arg] & CT_CONST)
577     return "In";
578 
579   switch (sym->arg_type [arg])
580   {
581   case ARG_FLOAT:
582   case ARG_DOUBLE:
583   case ARG_LONG:
584   case ARG_STRUCT:      return "In";
585   case ARG_POINTER:
586   case ARG_WIDE_STRING:
587   case ARG_STRING:      return "In/Out";
588   }
589   assert (0);
590   return "";
591 }
592 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.