Skip to content

Instantly share code, notes, and snippets.

@dhh1128
dhh1128 / id_validator_mark
Last active August 29, 2015 14:04
id validator mark
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:
@dhh1128
dhh1128 / gpl_example_pseudocode
Last active August 29, 2015 14:04
python-like pseudocode for marks that implement
# 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):
// 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
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
}
@dhh1128
dhh1128 / hello.i
Created February 17, 2014 18:45
hello world in intent
hello: application
Main:
does:
Print("Hello, World!")