使用Emscripten,是否可以从JavaScript调用函数指针(即数字)?
该函数的签名是可变的,所以我不能写一个帮手并完成。使用Emscripten调用函数指针
一个例子来说明,我有这样的函数:
// Returns a function pointer to call, with the appropiate
// arguments, to initialize the demanded feature.
void* get_feature_activator(feature_t feat);
你应该使用它,如下所示:
// Initialize the speaker
void* activator = get_feature_activator(FEATURE_SPEAKER);
// We know this function needs one float, so we cast and call it
((void(*)(float))activator) (3.0);
做同样的JavaScript:
var activator = _get_feature_activator(constants.FEATURE_SPEAKER);
// TODO: Need to call this pointer with one float
哇!我之前看过这个函数,我知道你可以用它们来调用一个指针,但是......我认为它们是罗马数字xD – 2014-08-30 21:27:55