Skip to content

Instantly share code, notes, and snippets.

#include "AE.h"
typedef struct{
AEStringHashTable(AETexture) textures;
}ResourceManager;
void ResourceManagerInit(ResourceManager* self);
void ResourceManagerDeinit(ResourceManager* self);
AETexture ResourceManagerLookup(ResourceManager* self, const char* filename);
void ResourceManagerRemove(ResourceManager* self, const char* filename);
init: func ~withAllArgs(=ano, =mes, =dia){}
init: func (ano := 2011, mes := 1, dia := 1) {
init~withAllArgs(ano, mes, dia)
}
//Triangulated Mesh Editing Utility
#pragma once
#include "AE.h"
typedef struct AEMesh AEMesh;
typedef struct AEMeshVertex AEMeshVertex;
typedef struct AEMeshTriangle AEMeshTriangle;
typedef enum{
AEMeshTypeTriangles,
@interface UI : NSObject {
AEVec2 windowSize;
UIFont* font;
AEVec2 mouse;
struct{
char left, middle, right, upwheel, downwheel;
}mouseButtons;
AETable* cache;
struct{
AETextBuffer* textBuffer;
AEArray(int) ints;
AEArrayInit(&ints);
AEArrayAdd(&ints, 1);
AEArrayAdd(&ints, 2);
AEArrayAdd(&ints, 3);
for(size_t i=0; i<AEArrayLength(&ints); i++)
printf("At Index %lu, we have %i\n", (unsigned long)i, AEArrayAsCArray(&ints)[i]);
AEArrayDeinit(&ints);
@od0x0
od0x0 / PIEC.c
Created September 15, 2010 21:03
/*
Platform Independent Endian Converter
Copyright (c) 2010 Oliver Daids
3-clause BSD
Note: This was not designed for speed, nor cleanliness, it was just a quick experiment to see if I could get a platform independent endian converter.
*/
#include <stdint.h>
Vec3: class{
x, y, z: Float
allocWith: static func(allocator: Func(SizeT)->Pointer) -> This{
object := allocator(Vec3 as Class instanceSize) as This
if(object) object class = This
return object
}
init: func(=x,=y,=z) -> This { this }
/opt/rock/sdk/threading/native/MutexUnix.ooc: In function ‘threading_native_MutexUnix__MutexUnix_new’:
/opt/rock/sdk/threading/native/MutexUnix.ooc:32: error: ‘__SIZEOF_PTHREAD_MUTEX_T’ undeclared (first use in this function)
/opt/rock/sdk/threading/native/MutexUnix.ooc:32: error: (Each undeclared identifier is reported only once
/opt/rock/sdk/threading/native/MutexUnix.ooc:32: error: for each function it appears in.)
/opt/rock/sdk/threading/native/MutexUnix.ooc: In function ‘threading_native_MutexUnix__RecursiveMutexUnix_new’:
/opt/rock/sdk/threading/native/MutexUnix.ooc:54: error: ‘__SIZEOF_PTHREAD_MUTEX_T’ undeclared (first use in this function)
C compiler failed (with code 1), aborting compilation process
dereferenceIntPointer: func(pointer: Int*, jmpbufstate: JmpBuf){
if(pointer==NULL) jmpbufstate restore(Exception new("Woah dude, assign your pointers!"))
return pointer@
}
try(|state|
i = 0 : Int
printf("%i\n",dereferenceIntPointer(i&,state))
)//Returns an Exception
catch(Exception /*The class that this catch will catch*/,|exception,stateForRethrowing|
dereferenceIntPointer: func(pointer: Int*, jmpbufstate: JmpBuf){
if(pointer==NULL) jmpbufstate restore(Exception new("Woah dude, assign your pointers!"))
return pointer@
}
try(|state|
i = 0 : Int
printf("%i\n",dereferenceIntPointer(i&,state))
)//Returns an Exception
catch(Exception /*The class that this catch will catch*/,|exception,stateForRethrowing|