Skip to content

Instantly share code, notes, and snippets.

🏳️‍🌈
Breaking things

Noel Cower nilium

🏳️‍🌈
Breaking things
Block or report user

Report or block nilium

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nilium
nilium / gist:79287
Created Mar 15, 2009
Alternate method of handling exceptions in TMonoMethod.Invoke
View gist:79287
Rem
bbdoc: Invoke the method. If an exception is passed, its internal pointer must be Null.
returns: A mono object containing the return data, or Null if an exception is thrown.
End Rem
Method Invoke:TMonoObject(obj:TMonoObject, params:Byte Ptr[], exception:TMonoObject)
Return InvokeByPointer(obj._pointer, params, exception)
End Method
Rem
@nilium
nilium / lua_test.bmx
Created Mar 16, 2009
Example of calling Lua functions and Lua calling C functions in BlitzMax
View lua_test.bmx
' lua_test.bmx
Strict
Import Axe.Lua
' Available to lua
Function lua_KeyHit( lvm@ Ptr )
' Get the number of arguments to the function
@nilium
nilium / test.bmx
Created Mar 16, 2009
Example of Lua reflection code
View test.bmx
' test.bmx
Type Foo {expose}
Method Bazzle( obj:Bar )
If obj = Null Then
Print "Null obj"
Else
Print obj.ToString()
EndIf
View gist:82766
IDENTIFIER_REGEX=/[a-zA-Z_]\w*/
TYPENAME_REGEX=/(?ix)
# type shortcut
(?:
( [!#%] | @{1,2} | \$[zw]? )
|
: \s* ([a-zA-Z_]\w*)
)
# pointer
@nilium
nilium / regexps.rb
Created Mar 21, 2009
Regular expressions used in the BBDocugen documentation generator for BlitzMax
View regexps.rb
# BBDocugen - BlitzMax Documentation Generator
# Copyright (C) 2009 Noel Cower
#
# BBDocugen is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BBDocugen is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
View gist:87633
// ignore this, just include bits as usual
#import <list>
#import <stdint.h>
// this is just an example class, don't read too much into it
class Object
{
private:
uint32_t m_refs;
View main.cc
#include <stdio.h>
#include "test.h"
int main(int argc, char ** argv)
{
int i = globalVariable;
globalVariable = 50;
View sampleOutput.txt
Last login: Tue Apr 7 02:56:43 on ttys002
/Users/noel/Source/Misc/bmax/lua-reflection/test ; exit;
[noel@Ouroboros ~]$ /Users/noel/Source/Misc/bmax/lua-reflection/test ; exit;
~>Unhandled Exception:Not handling this shit
~>
t
~>StackTrace{
~>@/Users/noel/Source/Misc/bmax/lua-reflection/test.bmx<26,1>
~>Function test
~>Global Running:Int=1
View require.bmx
SuperStrict
Function Script_Require:Int( lvm:Byte Ptr )
Local fname:String
While lua_gettop(lvm) > 0
fname = lua_tostring(lvm, -1)
lua_settop(lvm, -2)
If Not fname Then Throw "Invalid argument to require - nil"
If FileType(fname) <> FILETYPE_FILE Then Throw "Script ~q"+fname+"~q does not exist"
If lual_dofile(lvm, fname) Then Throw "Error executing script ~q"+fname+"~q: "+lua_tostring(lvm, -1)
View binor.bmx
Function script_binor:Int(lvm:Byte Ptr)
Local result:Int = 0
While lua_gettop(lvm)
result :| lua_tointeger(lvm, -1)
lua_settop(lvm,-2)
Wend
lua_pushinteger(lvm, result)
Return 1
End Function
You can’t perform that action at this time.