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
hello: application | |
Main: | |
does: | |
Print("Hello, World!") |
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
int DoSomething( | |
Foo * foo, /* might be null; call GetDefaultFoo() if so */ | |
Bar ** bar /* if non-null, contains foo's associated Bar upon return */ ) | |
{ | |
... // body of function | |
} |
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
// mocking variant 1 | |
mock(1, int, Allocator::Run,(mjob_t *J, candidate_t * candidates[MAX_CAND_PER_ALLOC], | |
int *minTPN, int *maxTPN, char *attrMap, int *jobIndex, candidate_t **bestList, | |
int *taskCount, int *userCount)); | |
// mocking variant 2 | |
MOCK_CMETHOD4(int, IterateEvents, event_list_t const *, char **, mgevent_obj_t **, | |
event_iter_t); | |
// mocking variant 3 |
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
# Implementation of a mark that precludes gpl license | |
class no_gpl: mark | |
propagation = propagation_types.called_code or propagation_types.contained_code | |
# Override mark.can_bind(). Return reason why binding is | |
# impossible, or None on success. | |
def can_bind(site, attachment): | |
if attachment == mark_types.explicit_affirmative: | |
if site.type.scope >= scope_types.code_block: | |
if site.get_call_tree().is_marked('gpl', mark_types.explicit_affirmative): |
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
id_validator: mark | |
propagation: propagation_types.package | propagation_types.viral | |
# Override mark.infect() -- define what parts of code should acquire this mark | |
# automatically. Return a list of (site, mark_type) tuples. | |
def infect(site): | |
infected = [] | |
for module in site.package.modules: | |
for function in module.functions: | |
for param in function.parameters: |
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
void spaceship::take_evasive_action(list<threat> threats_by_proximity) { | |
course escape_vector = nullptr; | |
list<threat> weighted_threats = order_by_evasion_priority( | |
threats_by_proximity, multiply_by_threat_severity); | |
if (this->has_warp()) { | |
bool warp_is_practical = true; | |
double max_safe_warp = 1.0; | |
// do a bunch of calculations about whether warp is |
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
#define eprintf(fmt, ...) \ | |
fprintf(stderr, fmt, __VA_ARGS__) |
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
#define eprintf(fmt, ...) \ | |
fprintf(stderr, fmt, ##__VA_ARGS) |
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
// Accept any number of args >= N, but expand to just the Nth one. In this case, | |
// we have settled on 5 as N. We could pick a different number by adjusting | |
// the count of throwaway args before N. Note that this macro is preceded by | |
// an underscore--it's an implementation detail, not something we expect people | |
// to call directly. | |
#define _GET_NTH_ARG(_1, _2, _3, _4, N, ...) N | |
// Count how many args are in a variadic macro. Only works for up to N-1 args. | |
#define COUNT_VARARGS(...) _GET_NTH_ARG(__VA_ARGS__, 4, 3, 2, 1) |
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
// Accept any number of args >= N, but expand to just the Nth one. The macro | |
// that calls us still only supports 4 args, but the set of values we might | |
// need to return is 1 larger, so we increase N to 6. | |
#define _GET_NTH_ARG(_1, _2, _3, _4, _5, N, ...) N | |
// Count how many args are in a variadic macro. We now use GCC/Clang's extension to | |
// handle the case where ... expands to nothing. We must add a placeholder arg before | |
// ##__VA_ARGS__ (its value is totally irrelevant, but it's necessary to preserve | |
// the shifting offset we want). In addition, we must add 0 as a valid value to be in | |
// the N position. |
OlderNewer