Raised This Month: $32 Target: $400
 8% 

[TOOLS] PySMX: Python SourcePawn Plug-in Reader and Abstract Machine


Post New Thread Reply   
 
Thread Tools Display Modes
BAILOPAN
Join Date: Jan 2004
Old 07-12-2012 , 22:34   Re: [TOOLS] Python SourcePawn Plug-in Reader
Reply With Quote #11

Ignore all heckling of usefulness! (Especially if it's from me.)
__________________
egg
BAILOPAN is offline
theY4Kman
Join Date: Jun 2007
Location: Yak
Old 07-15-2012 , 04:38   PySMX SourcePawn Plug-in Reader and Abstract Machine
Reply With Quote #12

Quote:
Originally Posted by BAILOPAN View Post
Ignore all heckling of usefulness! (Especially if it's from me.)
If I heeded heckling, there'd be a lot I never programmed. There would've also been a lot less drama earlier this year

I refactored the PySMX smxreader code a bunch, which made things pretty, but I somehow introduced a race condition. While it's unfortunate, and I still haven't figured it out, yet, I continued with development. I've implemented a small set of opcodes and a format-string-only PrintToServer native, which allows for the execution of the test plug-in in the repo.

You can check out the code here: https://github.com/theY4Kman/pysmx/tree/racecondition
Under the test/ directory you'll find test.py, which reads and executes the OnPluginStart public function in test.smx. The source to test.smx is available as well (the .smx being provided for quick testing).

The next steps are implementing the rest of the opcodes, writing the SourceMod core library in Python, and finally creating test runners and helpers (asserts and the such). When those steps are complete, you'll be able to setup a fake game environment, including players and entities, and unit test individual public functions in your plug-in.
__________________
http://y4kstudios.com
Is that loud enough? Oh, while I have you, check out Viper.
theY4Kman is offline
Send a message via ICQ to theY4Kman Send a message via AIM to theY4Kman Send a message via MSN to theY4Kman Send a message via Yahoo to theY4Kman Send a message via Skype™ to theY4Kman
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 07-18-2012 , 13:33   Re: PySMX SourcePawn Plug-in Reader and Abstract Machine
Reply With Quote #13

Quote:
Originally Posted by theY4Kman View Post
The next steps are implementing the rest of the opcodes, writing the SourceMod core library in Python, and finally creating test runners and helpers (asserts and the such). When those steps are complete, you'll be able to setup a fake game environment, including players and entities, and unit test individual public functions in your plug-in.
Sounds awesome.
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
theY4Kman
Join Date: Jun 2007
Location: Yak
Old 07-19-2012 , 05:26   Re: [TOOLS] PySMX: Python SourcePawn Plug-in Reader and Abstract Machine
Reply With Quote #14

Since my last post, I've implemented many more of the SourcePawn opcodes. This is the test plug-in I'm running now:
Code:
#include <sourcemod> public Plugin:myinfo = {     name = "PySMX Test",     author = "theY4Kman",     description = "Test plug-in for the PySMX VM",     version = "0.0",     url = "https://github.com/theY4Kman/pysmx/" }; public OnPluginStart() {     new percent = 100;     for (new i=0; i<10; i++)         percent += i;         PrintToServer("%s function%c work %d%% (+/- %.3f) of the time! No longer 0x%x -- now we're 0x%X!", "Format", 's', percent, 5.3, 0xdeadbeef, 0xcafed00d);     Test(); } Test() {     PrintToServer("Called Test()"); }

The Python test module:
Code:
import sys
sys.path.append('..')

if __name__ == '__main__':
    import os.path
    from smx import SourcePawnPlugin

    with open('test.smx', 'rb') as fp:
        plugin = SourcePawnPlugin(fp)
        print 'Loaded %s...' % plugin

        if os.path.exists('test.asm'):
            with open('test.asm', 'rb') as asm_fp:
                plugin.runtime.amx._verify_asm(asm_fp.read())

        plugin.run()
And finally, the output:
Quote:
Loaded PySMX Test by theY4Kman...
Format functions work 145% (+/- 5.300) of the time! No longer 0xdeadbeef -- now we're 0xCAFED00D!
Called Test()
0 verification faults
__________________
http://y4kstudios.com
Is that loud enough? Oh, while I have you, check out Viper.
theY4Kman is offline
Send a message via ICQ to theY4Kman Send a message via AIM to theY4Kman Send a message via MSN to theY4Kman Send a message via Yahoo to theY4Kman Send a message via Skype™ to theY4Kman
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:02.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode