Last active
August 29, 2015 14:27
-
-
Save zbanks/104906ba778675c42a7f to your computer and use it in GitHub Desktop.
This file contains 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
// Common: | |
struct endpoint { | |
struct node * node; | |
pull_fn_pt pull; | |
//const type_t * type; // Maybe... | |
//const char * name; // Maybe... | |
}; | |
// Type 1: | |
struct node { | |
block_destroy_fn_pt destroy; | |
object_t * state; | |
size_t n_inputs; | |
struct endpoint ** inputs; | |
size_t n_outputs; | |
struct endpoint outputs[]; | |
}; | |
node = malloc(sizeof(struct node) + n_outputs * sizeof(struct endpoint)); | |
node->inputs = malloc(n_inputs * sizeof(struct endpoint *)); | |
node->inputs[i]->node... | |
node->outputs[o].node... | |
// Type 2: | |
struct node { | |
block_destroy_fn_pt destroy; | |
object_t * state; | |
size_t n_inputs; | |
size_t n_outputs; | |
union endpoint_or_ptr { | |
struct endpoint * input; | |
struct endpoint output; | |
} endpoints[]; | |
}; | |
node = malloc(sizeof(struct node) + (n_inputs + n_outputs) * sizeof(union endpoint_or_ptr)); | |
node->inputs[i].input->node... | |
node->outputs[n_inputs + o].output.node... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment