Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created November 13, 2009 15:37
Show Gist options
  • Save jcromartie/233900 to your computer and use it in GitHub Desktop.
Save jcromartie/233900 to your computer and use it in GitHub Desktop.
int lmoaux_pushObjCRetValue(lua_State *L, NSInvocation *invocation) {
void *ret;
const char *pRetCode = [[invocation methodSignature] methodReturnType];
switch (*pRetCode) {
case '@':
ret = malloc(sizeof(id)); [invocation getReturnValue:ret]; lua_pushlightuserdata(L, (id)*ret);
break;
case 'f':
ret = malloc(sizeof(float)); [invocation getReturnValue:ret]; lua_pushnumber(L, (float)*ret);
break;
case 'i':
ret = malloc(sizeof(int)); [invocation getReturnValue:ret]; lua_pushinteger(L, (int)*ret);
break;
case 'l':
ret = malloc(sizeof(long)); [invocation getReturnValue:ret]; lua_pushnumber(L, (long)*ret);
break;
case 'd':
ret = malloc(sizeof(double)); [invocation getReturnValue:ret]; lua_pushnumber(L, (double)*ret);
default:
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment