Welcome to The Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

GLib Server Library


Recommended Posts

The most daunting aspect of developing binary modules for the server is dealing with the lua stack in order to retrieve, and pass return values to and from c functions. After an afternoon of boredom, I decided to write a library to make this process much easier. As far as i know (i havent actually checked) the name GLib isnt taken so thats what im gonna call it for now.

GLib provides an object oriented interface for the creation of binary modules, It automatically handles the complexity of retrieving function parameters, and sending return values. GLib isnt invasive, so if you still need to play around with the stack, you can.

GLib currently supports the following parameter types:

  • Booleans
  • Numbers
  • Strings
  • Vectors
  • Angles

Plans are in motion to add support for passing tables, entities, and other data types.

With this, i hope binary optimization of server code will be much easier to accomplish.

If you want to check it out, you can find the git repo here.

Just download the repo, and open the project file in visual studio. Everything should be set up for you to build the example plugin. An example lua script is also provided to test the example plugin.

Just a side note, due to a bug in Visual Studio 2019, this library will not work. You will need to use Visual Studio 2017 or older.

  • Like 2
Link to comment
Share on other sites

Just added a benchmark to the example lua test script. It shows the C++ function to calculate the dot product being about 4 times faster than a function written in lua. The speed increase is quite small here due to the function being simple, and the constant function call overhead taking a significant amount of that time. Functions that take longer to execute should see much larger gains written in C++.

  • Like 1
Link to comment
Share on other sites

GLib has been updated to support pretty much every data type available, as well as custom binary data. GLib now uses the ILuaObject interface provided by the garrysmod_common library. The parameter type filter has also been made optional, allowing functions to accept different parameter types.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share