~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to .pc/pythonpath.diff/emscripten.py

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-06-11 15:45:24 UTC
  • mfrom: (1.2.1) (2.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130611154524-rppb3w6tixlegv4n
Tags: 1.4.7~20130611~a1eb425-1
* New snapshot release
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
288
288
          exported_implemented_functions.add(key)
289
289
    for key, value in curr_forwarded_json['Functions']['unimplementedFunctions'].iteritems():
290
290
      forwarded_json['Functions']['unimplementedFunctions'][key] = value
 
291
    for key, value in curr_forwarded_json['Functions']['neededTables'].iteritems():
 
292
      forwarded_json['Functions']['neededTables'][key] = value
291
293
 
292
294
  if settings.get('ASM_JS'):
293
295
    parts = pre.split('// ASM_LIBRARY FUNCTIONS\n')
302
304
 
303
305
  # calculations on merged forwarded data
304
306
  forwarded_json['Functions']['indexedFunctions'] = {}
305
 
  i = 2
 
307
  i = 2 # universal counter
306
308
  if settings['ASM_JS']: i += 2*settings['RESERVED_FUNCTION_POINTERS']
 
309
  table_counters = {} # table-specific counters
 
310
  alias = settings['ASM_JS'] and settings['ALIASING_FUNCTION_POINTERS']
 
311
  sig = None
307
312
  for indexed in indexed_functions:
308
 
    #print >> sys.stderr, 'function indexing', indexed, i
309
 
    forwarded_json['Functions']['indexedFunctions'][indexed] = i # make sure not to modify this python object later - we use it in indexize
310
 
    i += 2
311
 
  forwarded_json['Functions']['nextIndex'] = i
 
313
    if alias:
 
314
      sig = forwarded_json['Functions']['implementedFunctions'].get(indexed) or forwarded_json['Functions']['unimplementedFunctions'].get(indexed)
 
315
      assert sig, indexed
 
316
      if sig not in table_counters:
 
317
        table_counters[sig] = 2 + 2*settings['RESERVED_FUNCTION_POINTERS']
 
318
      curr = table_counters[sig]
 
319
      table_counters[sig] += 2
 
320
    else:
 
321
      curr = i
 
322
      i += 2
 
323
    #print >> sys.stderr, 'function indexing', indexed, curr, sig
 
324
    forwarded_json['Functions']['indexedFunctions'][indexed] = curr # make sure not to modify this python object later - we use it in indexize
312
325
 
313
326
  def split_32(x):
314
327
    x = int(x)
365
378
    pre_tables = last_forwarded_json['Functions']['tables']['pre']
366
379
    del last_forwarded_json['Functions']['tables']['pre']
367
380
 
368
 
    # Find function table calls without function tables generated for them
369
 
    for funcs_js_item in funcs_js:
370
 
      for use in set(re.findall(r'{{{ FTM_[\w\d_$]+ }}}', funcs_js_item)):
371
 
        sig = use[8:len(use)-4]
372
 
        if sig not in last_forwarded_json['Functions']['tables']:
373
 
          if DEBUG: print >> sys.stderr, 'add empty function table', sig
374
 
          last_forwarded_json['Functions']['tables'][sig] = 'var FUNCTION_TABLE_' + sig + ' = [0,0];\n'
375
 
 
376
381
    def make_table(sig, raw):
377
382
      i = Counter.i
378
383
      Counter.i += 1
451
456
      asm_setup += '''
452
457
function invoke_%s(%s) {
453
458
  try {
454
 
    %sModule.dynCall_%s(%s);
 
459
    %sModule["dynCall_%s"](%s);
455
460
  } catch(e) {
456
461
    if (typeof e !== 'number' && e !== 'longjmp') throw e;
457
 
    asm.setThrew(1, 0);
 
462
    asm["setThrew"](1, 0);
458
463
  }
459
464
}
460
465
''' % (sig, args, 'return ' if sig[0] != 'v' else '', sig, args)
484
489
    asm_global_vars = ''.join(['  var ' + g + '=env.' + g + '|0;\n' for g in basic_vars + global_vars]) + \
485
490
                      ''.join(['  var ' + g + '=+env.' + g + ';\n' for g in basic_float_vars])
486
491
    # sent data
487
 
    the_global = '{ ' + ', '.join([math_fix(s) + ': ' + s for s in fundamentals]) + ' }'
488
 
    sending = '{ ' + ', '.join([math_fix(s) + ': ' + s for s in basic_funcs + global_funcs + basic_vars + basic_float_vars + global_vars]) + ' }'
 
492
    the_global = '{ ' + ', '.join(['"' + math_fix(s) + '": ' + s for s in fundamentals]) + ' }'
 
493
    sending = '{ ' + ', '.join(['"' + math_fix(s) + '": ' + s for s in basic_funcs + global_funcs + basic_vars + basic_float_vars + global_vars]) + ' }'
489
494
    # received
490
495
    if not simple:
491
 
      receiving = ';\n'.join(['var ' + s + ' = Module["' + s + '"] = asm.' + s for s in exported_implemented_functions + function_tables])
 
496
      receiving = ';\n'.join(['var ' + s + ' = Module["' + s + '"] = asm["' + s + '"]' for s in exported_implemented_functions + function_tables])
492
497
    else:
493
498
      receiving = 'var _main = Module["_main"] = asm;'
494
499
 
560
565
// EMSCRIPTEN_END_ASM
561
566
(%s, %s, buffer);
562
567
%s;
563
 
Runtime.stackAlloc = function(size) { return asm.stackAlloc(size) };
564
 
Runtime.stackSave = function() { return asm.stackSave() };
565
 
Runtime.stackRestore = function(top) { asm.stackRestore(top) };
 
568
Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
 
569
Runtime.stackSave = function() { return asm['stackSave']() };
 
570
Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
566
571
''' % (pre_tables + '\n'.join(function_tables_impls) + '\n' + function_tables_defs.replace('\n', '\n  '), exports, the_global, sending, receiving)]
567
572
 
568
573
    # Set function table masks
767
772
 
768
773
  if keywords.temp_dir is None:
769
774
    temp_files = get_configuration().get_temp_files()
 
775
    temp_dir = get_configuration().TEMP_DIR
770
776
  else:
771
777
    temp_dir = os.path.abspath(keywords.temp_dir)
772
778
    if not os.path.exists(temp_dir):