Created
November 11, 2010 21:57
-
-
Save erichocean/673275 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// core_main.c | |
// love | |
// | |
// Created by Erich Ocean on 11/10/10. | |
// Copyright (c) 2010 __MyCompanyName__. All rights reserved. | |
// | |
#include "core.h" | |
#include <Block.h> | |
#include <assert.h> | |
typedef struct MyObjectTag { | |
struct __obj_base base; | |
int32_t foo; | |
double bar; | |
} MyObject; | |
typedef MyObject * MyObjectRef; | |
static class_t MyObjectConstructor; | |
int main(int argc, const char **argv) | |
{ | |
pool_create(); | |
MyObjectConstructor = obj_extend(Object, MyObjectRef, | |
key foo_i32: STDGETSET(foo, int32_t) | |
key bar_d: STDGETSET(bar, double) | |
); | |
obj_t myobject = obj_create(sizeof(MyObject), MyObjectConstructor); | |
int32_t a = 4; | |
if (!set(myobject, foo_i32, &a)) | |
assert("Failed to set foo_i32"); | |
double b = 5.0; | |
if (!set(myobject, bar_d, &b)) | |
assert("Failed to set bar_d"); | |
int32_t c = 0; | |
if (!get(myobject, foo_i32, &c)) | |
assert("Failed to get foo_i32"); | |
double d = 0.0; | |
if (!get(myobject, bar_d, &d)) | |
assert("Failed to get bar_d"); | |
// Did we get back the values we set? | |
assert(a==c); | |
assert(b==d); | |
pool_release(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Key definitions:
KEY(bar, d)
KEY(foo, i32)