diff options
author | Jeremias Stotter <jeremias@stotter.eu> | 2023-10-15 21:43:12 +0200 |
---|---|---|
committer | Jeremias Stotter <jeremias@stotter.eu> | 2023-10-15 21:43:12 +0200 |
commit | 40adcb5686d1dc3d76a79e0a39c9631578074135 (patch) | |
tree | f69bbff420982dd41a72cedca2e263c4650428a8 | |
parent | 3ceded204ece41bd3599e5da2369d7e6795bd159 (diff) | |
download | network-simulator-40adcb5686d1dc3d76a79e0a39c9631578074135.tar.gz network-simulator-40adcb5686d1dc3d76a79e0a39c9631578074135.tar.bz2 network-simulator-40adcb5686d1dc3d76a79e0a39c9631578074135.zip |
Use userdata for the device pointer in lua
-rw-r--r-- | device.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -32,7 +32,7 @@ struct device* start_device = NULL; void dev_register_lua_function(struct device* dev, char* name, lua_CFunction fn) { - lua_pushinteger(dev->lua_vm, (unsigned long)dev); + lua_pushlightuserdata(dev->lua_vm, dev); lua_pushcclosure(dev->lua_vm, fn, 1); lua_setglobal(dev->lua_vm, name); } @@ -44,7 +44,7 @@ void rename_device(struct device* dev, const char* name) { } struct device* get_dev_in_cfunc(lua_State* lua_vm) { - return (struct device*)lua_tointeger(lua_vm, lua_upvalueindex(1)); + return (struct device*)lua_topointer(lua_vm, lua_upvalueindex(1)); } // Take in all the infos from the caller |