summaryrefslogtreecommitdiffstats
path: root/ppapi/generators
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 17:43:49 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 17:43:49 +0000
commitfa8543dea596ab76cced0a2d3a26891b90585d4b (patch)
treeb0f58095386083b1229404e0b883956c1538bd24 /ppapi/generators
parent53b090e53be0403ef4498f9c8c2481969d8ac573 (diff)
downloadchromium_src-fa8543dea596ab76cced0a2d3a26891b90585d4b.zip
chromium_src-fa8543dea596ab76cced0a2d3a26891b90585d4b.tar.gz
chromium_src-fa8543dea596ab76cced0a2d3a26891b90585d4b.tar.bz2
Pepper: Fix thunk function names with versions.
Thunk files previously had buggy code when dealing with multiple versions of a function. It's easiest to explain with the example Yuzhu gave: The IDL file has three versions defined: label Chrome { M19 = 0.2, M25 = 0.3, M29 = 0.4 }; And the interface has: int32_t Open(...) [version=0.4] int32_t Open(...) The generated thunk defines Open_0_2() and Open(). But the v0.3 interface structure use Open_0_3() which isn't defined. This change makes the v0.3 interface above use Open_0_2, as intended. BUG=239984 Review URL: https://chromiumcodereview.appspot.com/14927016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202119 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/generators')
-rwxr-xr-xppapi/generators/idl_outfile.py1
-rwxr-xr-xppapi/generators/idl_thunk.py13
-rw-r--r--ppapi/generators/test_thunk/simple.idl7
-rw-r--r--ppapi/generators/test_thunk/simple_thunk.cc43
4 files changed, 50 insertions, 14 deletions
diff --git a/ppapi/generators/idl_outfile.py b/ppapi/generators/idl_outfile.py
index 538267f..61b678c 100755
--- a/ppapi/generators/idl_outfile.py
+++ b/ppapi/generators/idl_outfile.py
@@ -95,6 +95,7 @@ class IDLOutFile(object):
filename = os.path.realpath(self.filename)
self.open = False
outtext = ''.join(self.outlist)
+ oldtext = ''
if not self.always_write:
if os.path.isfile(filename):
diff --git a/ppapi/generators/idl_thunk.py b/ppapi/generators/idl_thunk.py
index 9121cb0..1bb0de0 100755
--- a/ppapi/generators/idl_thunk.py
+++ b/ppapi/generators/idl_thunk.py
@@ -536,10 +536,11 @@ class TGen(GeneratorByFile):
for child in members:
rtype, name, arrays, args = cgen.GetComponents(
child, build, 'return')
- if not _IsNewestMember(child, members, releases):
- version = node.GetVersion(build).replace('.', '_')
- name += '_' + version
if child.InReleases([build]):
+ if not _IsNewestMember(child, members, releases):
+ version = child.GetVersion(
+ child.first_release[build]).replace('.', '_')
+ name += '_' + version
generated_functions.append(name)
out.Write(',\n'.join([' &%s' % f for f in generated_functions]))
out.Write('\n};\n\n')
@@ -574,11 +575,11 @@ def Main(args):
idldir = os.path.join(idldir, 'test_thunk', '*.idl')
filenames = glob.glob(idldir)
ast = ParseFiles(filenames)
- if tgen.GenerateRange(ast, ['M13', 'M14'], {}):
- print "Golden file for M13-M14 failed."
+ if tgen.GenerateRange(ast, ['M13', 'M14', 'M15'], {}):
+ print "Golden file for M13-M15 failed."
failed = 1
else:
- print "Golden file for M13-M14 passed."
+ print "Golden file for M13-M15 passed."
return failed
diff --git a/ppapi/generators/test_thunk/simple.idl b/ppapi/generators/test_thunk/simple.idl
index 30beace..c4ce7b9 100644
--- a/ppapi/generators/test_thunk/simple.idl
+++ b/ppapi/generators/test_thunk/simple.idl
@@ -11,7 +11,8 @@
label Chrome {
M13 = 0.5,
- M14 = 1.0
+ M14 = 1.0,
+ M15 = 1.5
};
interface PPB_Simple {
@@ -24,6 +25,10 @@ interface PPB_Simple {
uint32_t DoUint32Instance([in] PP_Instance instance);
+ [version=1.5]
+ uint32_t DoUint32Instance([in] PP_Instance instance,
+ [in] PP_Resource resource);
+
uint32_t DoUint32Resource([in] PP_Resource instance);
[report_errors=False]
diff --git a/ppapi/generators/test_thunk/simple_thunk.cc b/ppapi/generators/test_thunk/simple_thunk.cc
index e6418f0..8fc2ba2 100644
--- a/ppapi/generators/test_thunk/simple_thunk.cc
+++ b/ppapi/generators/test_thunk/simple_thunk.cc
@@ -19,6 +19,7 @@ namespace thunk {
namespace {
PP_Resource Create(PP_Instance instance) {
+ VLOG(4) << "PPB_Simple::Create()";
EnterResourceCreation enter(instance);
if (enter.failed())
return 0;
@@ -26,24 +27,37 @@ PP_Resource Create(PP_Instance instance) {
}
PP_Bool IsSimple(PP_Resource resource) {
+ VLOG(4) << "PPB_Simple::IsSimple()";
EnterResource<PPB_Simple_API> enter(resource, false);
return PP_FromBool(enter.succeeded());
}
void PostMessage(PP_Instance instance, PP_Var message) {
+ VLOG(4) << "PPB_Simple::PostMessage()";
EnterInstance enter(instance);
- if (enter.succeeded())
- enter.functions()->PostMessage(instance, message);
+ if (enter.failed())
+ return;
+ enter.functions()->PostMessage(instance, message);
+}
+
+uint32_t DoUint32Instance_0_5(PP_Instance instance) {
+ VLOG(4) << "PPB_Simple::DoUint32Instance()";
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return 0;
+ return enter.functions()->DoUint32Instance0_5(instance);
}
-uint32_t DoUint32Instance(PP_Instance instance) {
+uint32_t DoUint32Instance(PP_Instance instance, PP_Resource resource) {
+ VLOG(4) << "PPB_Simple::DoUint32Instance()";
EnterInstance enter(instance);
if (enter.failed())
return 0;
- return enter.functions()->DoUint32Instance(instance);
+ return enter.functions()->DoUint32Instance(instance, resource);
}
uint32_t DoUint32Resource(PP_Resource instance) {
+ VLOG(4) << "PPB_Simple::DoUint32Resource()";
EnterResource<PPB_Simple_API> enter(instance, true);
if (enter.failed())
return 0;
@@ -51,6 +65,7 @@ uint32_t DoUint32Resource(PP_Resource instance) {
}
uint32_t DoUint32ResourceNoErrors(PP_Resource instance) {
+ VLOG(4) << "PPB_Simple::DoUint32ResourceNoErrors()";
EnterResource<PPB_Simple_API> enter(instance, false);
if (enter.failed())
return 0;
@@ -58,6 +73,7 @@ uint32_t DoUint32ResourceNoErrors(PP_Resource instance) {
}
int32_t OnFailure12(PP_Instance instance) {
+ VLOG(4) << "PPB_Simple::OnFailure12()";
EnterInstance enter(instance);
if (enter.failed())
return 12;
@@ -68,18 +84,27 @@ const PPB_Simple_0_5 g_ppb_simple_thunk_0_5 = {
&Create,
&IsSimple,
&PostMessage,
- &DoUint32Instance,
+ &DoUint32Instance_0_5,
&DoUint32Resource,
- &DoUint32ResourceNoErrors,
+ &DoUint32ResourceNoErrors
};
const PPB_Simple_1_0 g_ppb_simple_thunk_1_0 = {
&Create,
&IsSimple,
+ &DoUint32Instance_0_5,
+ &DoUint32Resource,
+ &DoUint32ResourceNoErrors,
+ &OnFailure12
+};
+
+const PPB_Simple_1_5 g_ppb_simple_thunk_1_5 = {
+ &Create,
+ &IsSimple,
&DoUint32Instance,
&DoUint32Resource,
&DoUint32ResourceNoErrors,
- &OnFailure12,
+ &OnFailure12
};
} // namespace
@@ -92,5 +117,9 @@ const PPB_Simple_1_0* GetPPB_Simple_1_0_Thunk() {
return &g_ppb_simple_thunk_1_0;
}
+const PPB_Simple_1_5* GetPPB_Simple_1_5_Thunk() {
+ return &g_ppb_simple_thunk_1_5;
+}
+
} // namespace thunk
} // namespace ppapi