Skip to content

Instantly share code, notes, and snippets.

View ThePhD's full-sized avatar
🐑
Ready to roll!

The Phantom Derpstorm ThePhD

🐑
Ready to roll!
View GitHub Profile
@ThePhD
ThePhD / Sol.Scratch.cpp
Created December 9, 2013 04:02
Tests against optimizations for Sol, albeit actual function storage problem is still unsolved
#include <sol.hpp>
#include <iostream>
#include <tuple>
std::string free_func_yo( ) {
std::cout << "free_func_yo()" << std::endl;
return "test";
}
struct member_test {
@ThePhD
ThePhD / sol.scratch.cpp
Created December 9, 2013 05:08
Sol all tests to date
#include <sol.hpp>
#include <iostream>
#include <tuple>
std::string free_func_yo() {
std::cout << "free_func_yo()" << std::endl;
return "test";
}
struct member_test {
// GC table
void** freshuserdata = static_cast<void**>( lua_newuserdata( state( ), sizeof( userdata ) ) );
*freshuserdata = userdata;
lua_newtable( state( ) ); /* create metatable. */
stack::push( state( ), "__gc" ); /* push key '__gc' */
stack::push( state( ), destroyfunc, 0 ); /* push gc method. */
lua_rawset( state( ), -3 ); /* metatable['__gc'] = userdata_gc_method */
lua_setmetatable( state( ), -2 ); /* set the userdata's metatable. */
// Actual function call we want
@ThePhD
ThePhD / sol.scratch.cpp
Created December 9, 2013 19:17
Sol Tuple and function tests
void breaking() {
std::cout << "Nice!~\n";
}
std::tuple<double, double> breaking_multi() {
return std::make_tuple(567.2, 2.567);
}
struct a_type {
std::tuple<double, double> breaking_multi() {
[1/2] Compiling sol.scratch.cpp
FAILED: g++ -MMD -MF obj/sol.scratch.o.d -std=c++11 -pedantic -pedantic-errors -Wextra -Wall -O2 -DNDEBUG -c sol.scratch.cpp -o obj/sol.scra
tch.o -I"." -I"./include" -I"." -I"./lua-5.2.2/src/" -I"./Catch/include/"
In file included from ./sol/table.hpp:26:0,
from ./sol/state.hpp:26,
from ./sol.hpp:25,
from sol.scratch.cpp:3:
./sol/lua_function.hpp: In instantiation of 'static int sol::static_lua_func<TFx>::typed_call(sol::types<Args ...>, sol::types<Args ...>, so
l::static_lua_func<TFx>::fx_t*, lua_State*) [with TRn = {int}; Args = {int, int, std::basic_string<char, std::char_traits<char>, std::alloca
tor<char> >}; TFx = int (&)(int, int, std::basic_string<char>); sol::static_lua_func<TFx>::fx_t = int(int, int, std::basic_string<char>); lu
public static void GetBytes ( UInt16 data, byte[] bytes, int offset ) {
bytes[ offset++ ] = (byte)( data & 0xFF );
bytes[ offset++ ] = (byte)( ( data >> 8 ) & 0xFF );
}
public class Endian {
public static readonly Endian Big = new Endian {
n20 = 1,
n21 = 0,
n40 = 3,
n41 = 2,
n42 = 1,
n43 = 0,
n80 = 7,
n81 = 6,
ptr<IDXGIFactory, release_deleter> factory = null;
r = CreateDXGIFactory( __uuidof( IDXGIFactory ), static_cast<void**>( &factory ) );
if ( r != 0 )
throw ErrorCodeException( "Unable to create a DXGI Factory.", r );
@ThePhD
ThePhD / WebSocketExtensionStack.cs
Created December 24, 2013 22:16
Web Extension Stack, yaay!
using System.Collections.Generic;
namespace LoungeChat.Server {
public class WebSocketExtensionStack {
private List<IWebSocketExtension> _extensionstack = null;
private List<IWebSocketExtension> _acceptedextensionstack = new List<IWebSocketExtension>( );
public WebSocketExtensionStack( IEnumerable<IWebSocketExtension> extensions ) {
@ThePhD
ThePhD / fixed_vector.c++
Last active January 1, 2016 13:39
To the maximum extent possible, this code is released to the ultra super public domain desu.
#pragma once
#include <cstddef>
#include <type_traits>
#include <initializer_list>
#include <algorithm>
namespace Furrovine {
template <typename T, std::size_t n, std::size_t a = std::alignment_of<T>::value>