diff options
author | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 22:17:40 +0000 |
---|---|---|
committer | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 22:17:40 +0000 |
commit | acc3d8e973805f8ecd2ab2d31d5f4cddeadfc4e6 (patch) | |
tree | c308ba5684b3f364a6dbc05246f1df3343c88c53 /ppapi/generators | |
parent | 28cfaed056451113a72ce00603848f4a6dd616bb (diff) | |
download | chromium_src-acc3d8e973805f8ecd2ab2d31d5f4cddeadfc4e6.zip chromium_src-acc3d8e973805f8ecd2ab2d31d5f4cddeadfc4e6.tar.gz chromium_src-acc3d8e973805f8ecd2ab2d31d5f4cddeadfc4e6.tar.bz2 |
Add base class for generators
This CL is the first step towards alowing multiple generators
with a single driver to simplify the use of the generator.
It removes old built-in in idl_c_header.py, and replaces it with
several golden files to verify output is unchanged.
It renames the old 'version' option to 'release' to disambiguate
between a RELEASE name such as M14, and an interface VERSION such
as 1.0.
Removes the 'M14' hack which as added to the source code to force
release M14 to be generated.
TEST= ./generator.py
BUG= http://code.google.com/p/chromium/issues/detail?id=91607
R=sehr@google.com
Review URL: http://codereview.chromium.org/7477056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/generators')
-rwxr-xr-x | ppapi/generators/generator.py | 32 | ||||
-rw-r--r-- | ppapi/generators/idl_c_header.py | 177 | ||||
-rw-r--r-- | ppapi/generators/idl_c_proto.py | 9 | ||||
-rw-r--r-- | ppapi/generators/idl_generator.py | 187 | ||||
-rw-r--r-- | ppapi/generators/idl_namespace.py | 1 | ||||
-rw-r--r-- | ppapi/generators/test_cgen/enum_typedef.h | 67 | ||||
-rw-r--r-- | ppapi/generators/test_cgen/interface.h | 55 | ||||
-rw-r--r-- | ppapi/generators/test_cgen/stdint.h | 21 | ||||
-rw-r--r-- | ppapi/generators/test_cgen/stdint.idl | 51 | ||||
-rw-r--r-- | ppapi/generators/test_cgen/structs.h | 94 |
10 files changed, 563 insertions, 131 deletions
diff --git a/ppapi/generators/generator.py b/ppapi/generators/generator.py new file mode 100755 index 0000000..142bd11 --- /dev/null +++ b/ppapi/generators/generator.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +# +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import sys + +from idl_ast import IDLAst +from idl_generator import Generator +from idl_log import ErrOut, InfoOut, WarnOut +from idl_node import IDLAttribute, IDLNode +from idl_option import GetOption, Option, ParseOptions +from idl_outfile import IDLOutFile +from idl_parser import ParseFiles +from idl_c_header import HGen + + +def Main(args): + filenames = ParseOptions(args) + ast = ParseFiles(filenames) + return Generator.Run(ast) + +if __name__ == '__main__': + args = sys.argv[1:] + + # If no arguments are provided, assume we are tring to rebuild the + # C headers with warnings off. + if not args: args = ['--wnone', '--cgen'] + + sys.exit(Main(args)) + diff --git a/ppapi/generators/idl_c_header.py b/ppapi/generators/idl_c_header.py index 72fbf2a..46ca82a 100644 --- a/ppapi/generators/idl_c_header.py +++ b/ppapi/generators/idl_c_header.py @@ -18,6 +18,7 @@ from idl_option import GetOption, Option, ParseOptions from idl_outfile import IDLOutFile from idl_parser import ParseFiles from idl_c_proto import CGen +from idl_generator import Generator Option('dstroot', 'Base directory of output', default='../c') Option('guard', 'Include guard prefix', default='ppapi/c') @@ -34,7 +35,7 @@ def IDLToHeader(filenode, relpath=None, prefix=None): return name -def GenerateHeader(filenode, pref, inline=True): +def GenerateHeader(filenode, release, pref, inline=True): name = filenode.GetProperty('NAME') # if name == 'pp_stdint.idl': return @@ -66,7 +67,7 @@ def GenerateHeader(filenode, pref, inline=True): if label.GetName() == GetOption('label'): cgen.SetVersionMap(label) - deps = filenode.GetDeps('M14') + deps = filenode.GetDeps(release) # Generate set of includes includes = set([]) for dep in deps: @@ -87,7 +88,6 @@ def GenerateHeader(filenode, pref, inline=True): out.Write('#include "%s"\n' % include) # Generate all interface defines - release = 'M14' out.Write('\n') for node in filenode.GetListOf('Interface'): out.Write( cgen.InterfaceDefs(node) ) @@ -144,133 +144,60 @@ def GenerateHeader(filenode, pref, inline=True): out.Write(cgen.CommentLines(['*',' @}', '']) + '\n') out.Write('#endif /* %s */\n\n' % def_guard) - out.Close() - - -def GenerateFileTest(cfile, filenode, pref): - tests = [] - original = IDLToHeader(filenode, relpath='') - savename = IDLToHeader(filenode, relpath='', prefix=pref) - cfile.Write('/* Test %s */\n' % filenode.GetProperty('NAME')) - cfile.Write('#include "%s"\n' % original) - cfile.Write('#include "%s"\n' % savename) - - # For all children (excluding copyright notice) - for node in filenode.children[1:]: - # Test enums by assigning all enum items to themselves. Unfortunately this - # will not catch cases where the '.h' has enums that the IDL does not. - if node.IsA('Enum'): - tests.append('test_%s' % node.GetProperty('NAME')) - cfile.Write('int test_%s() {\n' % node.GetProperty('NAME')) - cfile.Write(' int errors = 0;\n') - for enum in node.GetListOf('EnumItem'): - cfile.Write(' errors += VERIFY_ENUM(%s, %s%s);\n' % - (enum.GetProperty('NAME'), pref, enum.GetProperty('NAME'))) - cfile.Write(' if (errors) printf("Failure in %s:%s.\\n");\n' % - (filenode.GetName(), node.GetName())) - cfile.Write(' return errors;\n}\n\n') - continue - - # Use a structure asignment to verify equivilency - if node.IsA('Interface', 'Struct'): - tests.append('test_%s' % node.GetName()) - rtype1 = cgen.GetTypeName(node) - rtype2 = cgen.GetTypeName(node, prefix='tst_') - cfile.Write('int test_%s() {\n' % node.GetName()) - cfile.Write(' int errors = 0;\n'); - cmp_structs = ' %s A;\n %s B;\n' % (rtype1, rtype2) - cfile.Write(cmp_structs) - cfile.Write(' memset(&A, 0, sizeof(A));\n') - cfile.Write(' memset(&B, 1, sizeof(B));\n') - for member in node.GetListOf('Member', 'Function'): - if member.GetOneOf('Array'): - cfile.Write(' memcpy(A.%s, B.%s, sizeof(A.%s));\n' % - (member.GetName(), member.GetName(), member.GetName())) - else: - cfile.Write(' A.%s = B.%s;\n' % (member.GetName(), member.GetName())) - cfile.Write(' errors += (sizeof(A) != sizeof(B)) ? 1 : 0;\n') - cfile.Write(' errors += (memcmp(&A, &B, sizeof(A))) ? 1 : 0;\n') - cfile.Write(' return (sizeof(A) == sizeof(B));\n}\n') - continue - - cfile.Write('\n\n') - return tests - -def GenerateBaseTest(cfile): - for inc in ['<stdio.h>','<string.h>','"pp_stdint.h"']: - cfile.Write('#include %s\n' % inc) - cfile.Write('\n') - cfile.Write('#define VERIFY_ENUM(orig, idl) Check(#orig, orig, idl)\n\n') - cfile.Write('int Check(const char *name, int v1, int v2) {\n') - cfile.Write(' if (v1 == v2) return 0;\n') - cfile.Write(' printf("Mismatch enum %s : %d vs %d\\n", name, v1, v2);\n') - cfile.Write(' return 1;\n}\n\n') - - -def Main(args): - filenames = ParseOptions(args) - ast = ParseFiles(filenames) - testFuncs = [] - skipList = [] + return out.Close() - outdir = GetOption('dstroot') +class HGen(Generator): + def __init__(self): + Generator.__init__(self, 'C Header', 'cgen', 'Generate the C headers.') - if GetOption('test'): - prefix = 'tst_' - cfile = IDLOutFile(os.path.join(outdir, 'test.c')) - GenerateBaseTest(cfile) - else: + def GenerateVersion(self, ast, release, options): + outdir = GetOption('dstroot') + skipList= [] prefix = '' cfile = None + cnt = 0 + + for filenode in ast.GetListOf('File'): + if GetOption('verbose'): + print "Working on %s" % filenode + + # If this file has errors, skip it + if filenode.GetProperty('ERRORS') > 0: + skipList.append(filenode) + continue + + if GenerateHeader(filenode, release, prefix): + cnt = cnt + 1 - for filenode in ast.GetListOf('File'): - if GetOption('verbose'): - print "Working on %s" % filenode - - # If this file has errors, skip it - if filenode.GetProperty('ERRORS') > 0: - skipList.append(filenode) - continue - - GenerateHeader(filenode, prefix, inline=not cfile) - if cfile: GenerateFileTest(cfile, filenode, prefix) - - if cfile: - cfile.Write('int main(int argc, const char *args[]) {\n') - cfile.Write(' int errors = 0;\n'); - for testname in testFuncs: - cfile.Write(' errors += %s();\n' % testname) - - cfile.Write(' printf("Found %d error(s) in the IDL.\\n", errors);\n') - cfile.Write(' return errors;\n}\n\n') - cfile.Close() - - # TODO(noelallen) Add a standard test - if not skipList: - args = ['gcc', '-o', 'tester', '%s/test.c' % outdir, '-I%s' % outdir, - '-I../c', '-I../..', '-DPPAPI_INSTANCE_REMOVE_SCRIPTING'] - InfoOut.Log('Running: %s' % ' '.join(args)) - ret = subprocess.call(args) - if ret: - ErrOut.Log('Failed to compile.') - return -1 - InfoOut.Log('Running: ./tester') - ret = subprocess.call('./tester') - if ret > 0: - ErrOut.Log('Found %d errors.' % ret) - return ret - InfoOut.Log('Success!') - return 0 - - for filenode in skipList: - errcnt = filenode.GetProperty('ERRORS') - ErrOut.Log('%s : Skipped because of %d errors.' % ( - filenode.GetName(), errcnt)) - - if not skipList: - InfoOut.Log('Processed %d files.' % len(ast.GetListOf('File'))) - return len(skipList) + for filenode in skipList: + errcnt = filenode.GetProperty('ERRORS') + ErrOut.Log('%s : Skipped because of %d errors.' % ( + filenode.GetName(), errcnt)) + + if skipList: + return -len(skipList) + + if GetOption('diff'): + return -cnt + return cnt + + +hgen = HGen() + +def Main(args): + # Default invocation will verify the golden files are unchanged. + if not args: + args = ['--wnone', '--diff', '--test', '--dstroot=.'] + + ParseOptions(args) + idldir = os.path.split(sys.argv[0])[0] + idldir = os.path.join(idldir, 'test_cgen', '*.idl') + filenames = glob.glob(idldir) + + ast = ParseFiles(filenames) + return hgen.GenerateVersion(ast, 'M14', {}) if __name__ == '__main__': - sys.exit(Main(sys.argv[1:])) + retval = Main(sys.argv[1:]) + sys.exit(retval) diff --git a/ppapi/generators/idl_c_proto.py b/ppapi/generators/idl_c_proto.py index 7147bbb..a116e36 100644 --- a/ppapi/generators/idl_c_proto.py +++ b/ppapi/generators/idl_c_proto.py @@ -105,13 +105,13 @@ class CGen(object): self.dbg_depth = 0 self.vmin = 0.0 self.vmax = 1e100 - self.release = 'M14' + self.release = GetOption('release') def SetVersionMap(self, node): self.vmin = 0.0 self.vmax = 1e100 for version in node.GetListOf('LabelItem'): - if version.GetName() == GetOption('version'): + if version.GetName() == GetOption('release'): self.vmin = float(version.GetProperty('VALUE')) self.vmax = float(version.GetProperty('VALUE')) @@ -385,7 +385,6 @@ class CGen(object): def InterfaceDefs(self, node): out = '' - release = 'M14' name = node.GetName() macro = node.GetProperty('macro') if not macro: @@ -396,7 +395,7 @@ class CGen(object): strver = str(vers).replace('.', '_') out += self.GetDefine('%s_%s' % (macro, strver), '"%s;%s"' % (name, vers)) - if label.GetRelease(vers) == release: + if label.GetRelease(vers) == self.release: out += self.GetDefine(macro, '%s_%s' % (macro, strver)) out += '\n' return out @@ -478,7 +477,7 @@ class CGen(object): label = node.GetLabel() if label: - lver = label.GetVersion('M14') + lver = label.GetVersion(self.release) # Verify that we are in a valid version. if node_max <= lver: return '' diff --git a/ppapi/generators/idl_generator.py b/ppapi/generators/idl_generator.py new file mode 100644 index 0000000..32c943c --- /dev/null +++ b/ppapi/generators/idl_generator.py @@ -0,0 +1,187 @@ +#!/usr/bin/python +# +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import sys + +from idl_log import ErrOut, InfoOut, WarnOut +from idl_option import GetOption, Option, ParseOptions + +GeneratorList = [] + +Option('release', 'Which release to generate.', default='M14') +Option('range', 'Which release ranges in the form of MIN,MAX.', default='') + + +# +# Generator +# +# Base class for generators. This class provides a mechanism for +# adding new generator objects to the IDL driver. To use this class +# override the GenerateVersion and GenerateRange members, and +# instantiate one copy of the class in the same module which defines it to +# register the generator. After the AST is generated, call the static Run +# member which will check every registered generator to see which ones have +# been enabled through command-line options. To enable a generator use the +# switches: +# --<sname> : To enable with defaults +# --<sname>_opt=<XXX,YYY=y> : To enable with generator specific options. +# +# NOTE: Generators still have access to global options + +class Generator(object): + def __init__(self, name, sname, desc): + self.name = name + self.run_switch = Option(sname, desc) + self.opt_switch = Option(sname + '_opt', 'Options for %s.' % sname, + default='') + GeneratorList.append(self) + self.errors = 0 + + def Error(self, msg): + ErrOut.Log('Error %s : %s' % (self.name, msg)) + self.errors += 1 + + def GetRunOptions(self): + options = {} + option_list = self.opt_switch.Get() + if option_list: + option_list = option_list.split(',') + for opt in option_list: + offs = opt.find('=') + if offs > 0: + options[opt[:offs]] = opt[offs+1:] + else: + options[opt] = True + return options + if self.run_switch.Get(): + return options + return None + + def Generate(self, ast, options): + self.errors = 0 + + rangestr = GetOption('range') + releasestr = GetOption('release') + + # Check for a range option which over-rides a release option + if rangestr: + range_list = rangestr.split(',') + if len(range_list) != 2: + self.Error('Failed to generate for %s, incorrect range: "%s"' % + (self.name, rangestr)) + else: + vmin = range_list[0] + vmax = range_list[1] + ret = self.GenerateRange(ast, vmin, vmax, options) + if not ret: + self.Error('Failed to generate range %s : %s.' %(vmin, vmax)) + # Otherwise this should be a single release generation + else: + if releasestr: + ret = self.GenerateVersion(ast, releasestr, options) + if ret < 0: + self.Error('Failed to generate release %s.' % releasestr) + else: + InfoOut.Log('%s wrote %d files.' % (self.name, ret)) + + else: + self.Error('No range or release specified for %s.' % releasestr) + return self.errors + + def GenerateVersion(self, ast, release, options): + __pychecker__ = 'unusednames=ast,release,options' + self.Error("Undefined release generator.") + return 0 + + def GenerateRange(self, ast, vmin, vmax, options): + __pychecker__ = 'unusednames=ast,vmin,vmax,options' + self.Error("Undefined range generator.") + return 0 + + @staticmethod + def Run(ast): + fail_count = 0 + + # Check all registered generators if they should run. + for gen in GeneratorList: + options = gen.GetRunOptions() + if options is not None: + if gen.Generate(ast, options): + fail_count += 1 + return fail_count + + +check_release = 0 +check_range = 0 + +class GeneratorVersionTest(Generator): + def GenerateVersion(self, ast, release, options = {}): + __pychecker__ = 'unusednames=ast,release,options' + global check_release + check_map = { + 'so_long': True, + 'MyOpt': 'XYZ', + 'goodbye': True + } + check_release = 1 + for item in check_map: + check_item = check_map[item] + option_item = options.get(item, None) + if check_item != option_item: + print 'Option %s is %s, expecting %s' % (item, option_item, check_item) + check_release = 0 + + if release != 'M14': + check_release = 0 + return check_release == 1 + + def GenerateRange(self, ast, vmin, vmax, options = {}): + __pychecker__ = 'unusednames=ast,vmin,vmax,options' + global check_range + check_range = 1 + return True + +def Test(): + __pychecker__ = 'unusednames=args' + global check_release + global check_range + + ParseOptions(['--testgen_opt=so_long,MyOpt=XYZ,goodbye']) + if Generator.Run('AST') != 0: + print 'Generate release: Failed.\n' + return -1 + + if check_release != 1 or check_range != 0: + print 'Gererate release: Failed to run.\n' + return -1 + + check_release = 0 + ParseOptions(['--testgen_opt="HELLO"', '--range=M14,M16']) + if Generator.Run('AST') != 0: + print 'Generate range: Failed.\n' + return -1 + + if check_release != 0 or check_range != 1: + print 'Gererate range: Failed to run.\n' + return -1 + + print 'Generator test: Pass' + return 0 + + +def Main(args): + if not args: return Test() + + filenames = ParseOptions(args) + ast = ParseFiles(filenames) + + return Generator.Run(ast) + + +if __name__ == '__main__': + GeneratorVersionTest('Test Gen', 'testgen', 'Generator Class Test.') + sys.exit(Main(sys.argv[1:])) + diff --git a/ppapi/generators/idl_namespace.py b/ppapi/generators/idl_namespace.py index b20e4f2..2451168 100644 --- a/ppapi/generators/idl_namespace.py +++ b/ppapi/generators/idl_namespace.py @@ -18,7 +18,6 @@ from idl_log import ErrOut, InfoOut, WarnOut from idl_version import IDLVersion Option('label', 'Use the specifed label blocks.', default='Chrome') -Option('version', 'Use the specified version', default='M14') Option('namespace_debug', 'Use the specified version') diff --git a/ppapi/generators/test_cgen/enum_typedef.h b/ppapi/generators/test_cgen/enum_typedef.h new file mode 100644 index 0000000..e442205 --- /dev/null +++ b/ppapi/generators/test_cgen/enum_typedef.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From test_cgen/enum_typedef.idl modified Mon Aug 22 15:15:49 2011. */ + +#ifndef PPAPI_C_TEST_CGEN_ENUM_TYPEDEF_H_ +#define PPAPI_C_TEST_CGEN_ENUM_TYPEDEF_H_ + +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/test_cgen/stdint.h" + +/** + * @file + * This file will test that the IDL snippet matches the comment. + */ + + +/** + * @addtogroup Enums + * @{ + */ +/* typedef enum { A = 1, B = 2, C = 3 } et1; */ +typedef enum { + A = 1, + B = 2, + C = 3 +} et1; +/** + * @} + */ + +/** + * @addtogroup Typedefs + * @{ + */ +/* typedef int32_t i; */ +typedef int32_t i; + +/* typedef int32_t i2[2]; */ +typedef int32_t i2[2]; + +/* typedef int32_t (*i_func)(); */ +typedef int32_t (*i_func)(); + +/* typedef int32_t (*i_func_i)(int32_t i); */ +typedef int32_t (*i_func_i)(int32_t i); + +/* typedef et1 et4[4]; */ +typedef et1 et4[4]; + +/* + * typedef int8_t (*PPB_Audio_Callback)(const void* sample_buffer, + * uint32_t buffer_size_in_bytes, + * const void* user_data); + */ +typedef int8_t (*PPB_Audio_Callback)(const void* sample_buffer, + uint32_t buffer_size_in_bytes, + const void* user_data); +/** + * @} + */ + +#endif /* PPAPI_C_TEST_CGEN_ENUM_TYPEDEF_H_ */ + diff --git a/ppapi/generators/test_cgen/interface.h b/ppapi/generators/test_cgen/interface.h new file mode 100644 index 0000000..6a187e4 --- /dev/null +++ b/ppapi/generators/test_cgen/interface.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From test_cgen/interface.idl modified Mon Aug 22 15:15:43 2011. */ + +#ifndef PPAPI_C_TEST_CGEN_INTERFACE_H_ +#define PPAPI_C_TEST_CGEN_INTERFACE_H_ + +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/test_cgen/stdint.h" + + +/** + * @file + * This file will test that the IDL snippet matches the comment. + */ + + +/** + * @addtogroup Structs + * @{ + */ +/* struct ist { void* X; }; */ +struct ist { + void* X; +}; +/** + * @} + */ + +/** + * @addtogroup Interfaces + * @{ + */ +/* + * struct iface1 { + * int8_t (*mem1)(int16_t x, int32_t y); + * int32_t (*mem2)(const struct ist* a); + * int32_t (*mem3)(struct ist* b); + * }; + */ +struct iface1 { + int8_t (*mem1)(int16_t x, int32_t y); + int32_t (*mem2)(const struct ist* a); + int32_t (*mem3)(struct ist* b); +}; +/** + * @} + */ + +#endif /* PPAPI_C_TEST_CGEN_INTERFACE_H_ */ + diff --git a/ppapi/generators/test_cgen/stdint.h b/ppapi/generators/test_cgen/stdint.h new file mode 100644 index 0000000..e49f0c0 --- /dev/null +++ b/ppapi/generators/test_cgen/stdint.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From test_cgen/stdint.idl modified Thu Aug 18 16:20:46 2011. */ + +#ifndef PPAPI_C_TEST_CGEN_STDINT_H_ +#define PPAPI_C_TEST_CGEN_STDINT_H_ + +#include "ppapi/c/pp_macros.h" + +/** + * @file + * This file provides a definition of C99 sized types + * for Microsoft compilers. These definitions only apply + * for trusted modules. + */ + +#endif /* PPAPI_C_TEST_CGEN_STDINT_H_ */ + diff --git a/ppapi/generators/test_cgen/stdint.idl b/ppapi/generators/test_cgen/stdint.idl new file mode 100644 index 0000000..9a8e00b --- /dev/null +++ b/ppapi/generators/test_cgen/stdint.idl @@ -0,0 +1,51 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * This file provides a definition of C99 sized types + * for Microsoft compilers. These definitions only apply + * for trusted modules. + */ + +label Chrome { + M13 = 0.0, + M14 = 1.0, + M15 = 2.0 +}; + +[version=0.0] +describe { + /** Standard Ints. */ + int8_t; + int16_t; + int32_t; + int64_t; + uint8_t; + uint16_t; + uint32_t; + uint64_t; + /** Small and large floats. */ + double_t; + float_t; + + /** Native file handle (int). */ + handle_t; + + /** Interface object (void *). */ + interface_t; + + /** Used for padding, should be (u)int8_t */ + char; + + /** Pointer to memory (void *). */ + mem_t; + + /** Pointer to null terminated string (char *). */ + str_t; + + /** No return value. */ + void; +}; + diff --git a/ppapi/generators/test_cgen/structs.h b/ppapi/generators/test_cgen/structs.h new file mode 100644 index 0000000..bcc6b44 --- /dev/null +++ b/ppapi/generators/test_cgen/structs.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From test_cgen/structs.idl modified Mon Aug 22 15:15:38 2011. */ + +#ifndef PPAPI_C_TEST_CGEN_STRUCTS_H_ +#define PPAPI_C_TEST_CGEN_STRUCTS_H_ + +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/test_cgen/stdint.h" + +/** + * @file + * This file will test that the IDL snippet matches the comment. + */ + + +/** + * @addtogroup Typedefs + * @{ + */ +/* typedef uint8_t s_array[3]; */ +typedef uint8_t s_array[3]; +/** + * @} + */ + +/** + * @addtogroup Enums + * @{ + */ +/* typedef enum { esv1 = 1, esv2 = 2 } senum; */ +typedef enum { + esv1 = 1, + esv2 = 2 +} senum; +/** + * @} + */ + +/** + * @addtogroup Structs + * @{ + */ +/* struct st1 { int32_t i; senum j; }; */ +struct st1 { + int32_t i; + senum j; +}; + +/* struct st2 { s_array pixels[640][480]; }; */ +struct st2 { + s_array pixels[640][480]; +}; +/** + * @} + */ + +/** + * @addtogroup Typedefs + * @{ + */ +/* typedef float (*func_t)(const s_array data); */ +typedef float (*func_t)(const s_array data); + +/* typedef func_t (*findfunc_t)(const char* x); */ +typedef func_t (*findfunc_t)(const char* x); +/** + * @} + */ + +/** + * @addtogroup Structs + * @{ + */ +/* + * struct sfoo { + * s_array screen[480][640]; + * findfunc_t myfunc; + * }; + */ +struct sfoo { + s_array screen[480][640]; + findfunc_t myfunc; +}; +/** + * @} + */ + +#endif /* PPAPI_C_TEST_CGEN_STRUCTS_H_ */ + |