Rewrite autoloader; implement optimizations and more features

Issue #1 new
Acecool repo owner created an issue

Starting to use the issue system to track todo's...

The new autoloader is around 95% complete, I'm just finishing up a few things and testing; I made clean it up a little more and use some additional helper functions and it is expected to be uploaded soon ( currently the newer version of the autoloader is on acecooldev_networking; but it isn't the current one which has working folder support etc.. )

  • Optimize autoloader ( Broad )

  • Reduce realm calculations from once per load-cycle / auto-refresh per folder and file to first-load ( cache realms for files and folders )

  • Add Base Directory helper-function / system to replace the current _gmfolder / _base dir argument. ( Set the base and it'll be added on to each file inclusion, AddCSLuaFile, etc; simplifies things )

  • Add Working Directory Helper-function / system as new feature ( Used in require_once )

  • Reduce number of times a file can be loaded per load-cycle from x to 1 ( Currently no file should be loaded more than once, but just in case AddFolder or whatever is used more than once, this is helpful; additionally this will help with dependency system )

  • Add dependency system to avoid needing to rely on alphabetical load-order or deepest-first which caused a few oddly named folders to get created, ie require_once function

  • Add: require_once( _path_to_file_name, _realm, _bUseWorkingDir ); where _path_to_file_name by default uses the Base Folder + _path_to_file_name to simplify loading files meaning the require_once first argument can be the same regardless of which file or folder it is added in.

_realm is the realm to use such as REALM_NOLOAD = prevent loading, REALM_UNKNOWN = recalculate realm, REALM_CLIENT = client file, REALM_SERVER = server file or REALM_SHARED for shared file ( both client and server ).

And finally where bUseWorkingDir will use the path where the currently executed file is loaded so if b.lua needs c.lua and they're in the same dir and because alphabetical loading wouldn't load c before b, b.lua can add: require_once( "c.lua", REALM*, true ); to the top of the file in order to load c.lua prior to loading the rest of b.lua and setting up a good load order. Also, regardless of require_once's being pointed to the same file, because of the caching system a maximum of 1 load per file will occur...

Still waiting to be done:

  • As I am using the same autoloader for addons, gamemodes, etc... I need to add a simple hook.Call / hook.Add system so that when ready ( Initialize hook or so ) it'll call a SetupAutoLoader hook and each hook will set up their base dir, base path, each dir to add, etc and run in succession. This way the same file in different areas won't cause issues with loading the files it is supposed to.

  • Misc. Cleanup

  • Misc Optimizations

Comments (0)

  1. Log in to comment