Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: nacl_bindings_generator/generate_nacl_bindings.py

Issue 988323004: NaCl: disable unimplmented Mojo APIs. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « nacl_bindings/mojo_syscall.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # pylint: disable=W0104,W0106,F0401,R0201 6 # pylint: disable=W0104,W0106,F0401,R0201
7 7
8 import errno 8 import errno
9 import os.path 9 import os.path
10 import sys 10 import sys
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 300
301 # A trusted wrapper that validates the arguments passed from untrusted code 301 # A trusted wrapper that validates the arguments passed from untrusted code
302 # before passing them to the underlying public Mojo API. 302 # before passing them to the underlying public Mojo API.
303 def GenerateMojoSyscall(functions, common_vars, out): 303 def GenerateMojoSyscall(functions, common_vars, out):
304 template = jinja_env.get_template('mojo_syscall.cc.tmpl') 304 template = jinja_env.get_template('mojo_syscall.cc.tmpl')
305 305
306 code = CodeWriter() 306 code = CodeWriter()
307 code.PushMargin() 307 code.PushMargin()
308 308
309 for f in functions: 309 for f in functions:
310 is_implemented = True
311
312 # Mojo API calls that take or return pointers are currently not supported.
313 # The underlying Mojo implementation is unaware of NaCl's address space. In
314 # addition, if we pass blindly pass the parameters through to the underlying
315 # Mojo API, memory corruption can result from pointer-size mistmatches.
316 for p in f.params:
317 if p.base_type.endswith("*"):
318 is_implemented = False
319
310 impls = [ImplForParam(p) for p in f.params] 320 impls = [ImplForParam(p) for p in f.params]
311 impls.append(ImplForParam(f.result_param)) 321 impls.append(ImplForParam(f.result_param))
312 322
313 code << 'case %d:' % f.uid 323 code << 'case %d:' % f.uid
314 324
325 if not is_implemented:
326 with code.Indent():
327 code << 'fprintf(stderr, "%s not implemented\\n");' % f.name
328 code << 'return -1;'
329 continue
330
315 code.PushMargin() 331 code.PushMargin()
316 332
317 code << '{' 333 code << '{'
318 334
319 with code.Indent(): 335 with code.Indent():
320 num_params = len(f.params) + 2 336 num_params = len(f.params) + 2
321 code << 'if (num_params != %d) {' % num_params 337 code << 'if (num_params != %d) {' % num_params
322 with code.Indent(): 338 with code.Indent():
323 code << 'return -1;' 339 code << 'return -1;'
324 code << '}' 340 code << '}'
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 GenerateMojoSyscall(mojo.functions, common_vars, out) 510 GenerateMojoSyscall(mojo.functions, common_vars, out)
495 511
496 out = OutFile(full_platform_dir, 'mojo_irt.h') 512 out = OutFile(full_platform_dir, 'mojo_irt.h')
497 GenerateMojoIrtHeader(mojo.functions, common_vars, out) 513 GenerateMojoIrtHeader(mojo.functions, common_vars, out)
498 514
499 out = OutFile(full_bindings_dir, 'mojo_irt.c') 515 out = OutFile(full_bindings_dir, 'mojo_irt.c')
500 GenerateMojoIrtImplementation(mojo.functions, common_vars, out) 516 GenerateMojoIrtImplementation(mojo.functions, common_vars, out)
501 517
502 if __name__ == '__main__': 518 if __name__ == '__main__':
503 main() 519 main()
OLDNEW
« no previous file with comments | « nacl_bindings/mojo_syscall.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698