reactos/sdk/tools/widl/utils.h

86 lines
3.2 KiB
C
Raw Normal View History

/*
* Utility routines' prototypes etc.
*
* Copyright 1998 Bertho A. Stultiens (BS)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WIDL_UTILS_H
#define __WIDL_UTILS_H
#include "widltypes.h"
#include <stddef.h> /* size_t */
void *xmalloc(size_t);
void *xrealloc(void *, size_t);
char *xstrdup(const char *str);
int strendswith(const char* str, const char* end);
#ifndef __GNUC__
#define __attribute__(X)
#endif
void parser_error(const char *s) __attribute__((noreturn));
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void error_loc(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn));
void error(const char *s, ...) __attribute__((format (printf, 1, 2))) __attribute__((noreturn));
void error_loc_info(const loc_info_t *, const char *s, ...) __attribute__((format (printf, 2, 3))) __attribute__((noreturn));
void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
Sync to wine-0.9.60: - Rob Shearman <rob@codeweavers.com> Fri, 11 Apr 2008 widl: Support non-default calling conventions for object methods. - Rob Shearman <rob@codeweavers.com> Fri, 11 Apr 2008 widl: Support non-default calling conventions for non-object functions. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: Check that attributes applied to interfaces, functions and arguments are applicable and issue an error if not. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: Check that attributes applied to typedefs and fields are applicable and issue an error otherwise. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: Make the attrs parameter passed to start_typelib const. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: The odl attribute is valid for dispinterfaces. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: Check that attributes are applicable for libraries, modules, dispinterfaces and coclasses and otherwise issue an error. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: Output a warning if duplicate attributes are specified. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: Add support for the broadcast and idempotent operation attributes. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: Write out TYPEFLAG, FUNCFLAG and VARFLAG flags for all attribute we currently parse. Add FIXMEs for the remaining ones and remove the warning for unimplemented attribute types since we now support all the attributes that we parse. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: Add functions to print an error or warning message using location information to enable these to be printed accurately when a check is done after an element is parsed. Add location information to variable automatically, since this is will be useful for type checking of arguments. - Rob Shearman <rob@codeweavers.com> Mon, 14 Apr 2008 widl: Add checking to arguments of non-local functions. Check that out arguments have enough levels of indirection and that they don't derive from void * or a function pointer. - Rob Shearman <rob@codeweavers.com> Tue, 15 Apr 2008 widl: Change alls calls to error in the parser to error_loc so that line number information is printed. svn path=/trunk/; revision=37260
2008-11-09 14:21:53 +00:00
void warning_loc_info(const loc_info_t *, const char *s, ...) __attribute__((format (printf, 2, 3)));
void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
char *dup_basename(const char *name, const char *ext);
size_t widl_getline(char **linep, size_t *lenp, FILE *fp);
UUID *parse_uuid(const char *u);
int is_valid_uuid(const char *s);
/* buffer management */
extern int byte_swapped;
extern unsigned char *output_buffer;
extern size_t output_buffer_pos;
extern size_t output_buffer_size;
extern void init_output_buffer(void);
extern void flush_output_buffer( const char *name );
extern void add_output_to_resources( const char *type, const char *name );
extern void flush_output_resources( const char *name );
extern void put_data( const void *data, size_t size );
extern void put_byte( unsigned char val );
extern void put_word( unsigned short val );
extern void put_dword( unsigned int val );
extern void put_qword( unsigned int val );
extern void put_pword( unsigned int val );
extern void put_str( int indent, const char *format, ... ) __attribute__((format (printf, 2, 3)));
extern void align_output( unsigned int align );
/* typelibs expect the minor version to be stored in the higher bits and
* major to be stored in the lower bits */
#define MAKEVERSION(major, minor) ((((minor) & 0xffff) << 16) | ((major) & 0xffff))
#define MAJORVERSION(version) ((version) & 0xffff)
#define MINORVERSION(version) (((version) >> 16) & 0xffff)
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif