- print 'static inline ' + function.prototype('__' + function.name) + ' {'
- if function.type is stdapi.Void:
- ret = ''
- else:
- ret = 'return '
- self.get_true_pointer(function)
- pvalue = self.function_pointer_value(function)
- print ' %s%s(%s);' % (ret, pvalue, ', '.join([str(arg.name) for arg in function.args]))
- print '}'
- print
- print '#define %s __%s' % (function.name, function.name)
-
- def get_true_pointer(self, function):
- ptype = self.function_pointer_type(function)
- pvalue = self.function_pointer_value(function)
- if function.name in public_symbols:
- get_proc_address = '__getProcAddress'
- else:
- get_proc_address = '__glGetProcAddress'
- print ' if (!%s) {' % (pvalue,)
- print ' %s = (%s)%s("%s");' % (pvalue, ptype, get_proc_address, function.name)
- print ' if (!%s) {' % (pvalue,)
- self.fail_function(function)
- print ' }'
- print ' }'
-
- def fail_function(self, function):
- print ' std::cerr << "error: unavailable function \\"%s\\"\\n";' % function.name
- if function.fail is not None:
- if function.type is stdapi.Void:
- assert function.fail == ''
- print ' return;'
- else:
- assert function.fail != ''
- print ' return %s;' % function.fail
- else:
- print ' abort();'