Struct AttributedFunction(alias Function, alias StoredArgTypes)
Entry point for `funcattr` API.
Helper struct that takes care of calling given Function in a such
way that part of its arguments are evalutated by attached input attributes
(see `before
`) and output gets post-processed by output attribute
(see `after
`).
One such structure embeds single attributed function to call and specific argument type list that can be passed to attached functions.
Parameters
Name | Description |
---|---|
Function | attributed function |
StoredArgTypes | Group of argument types for attached functions |
Example
example
import std.conv; static string evaluator(string left, string right) { return left ~ right; } // all attribute function must accept same stored parameters static int modificator(int result, string unused1, string unused2) { return result * 2; } @before!evaluator("a") @before!evaluator("c") @after!modificator() static int sum(string a, int b, string c, double d) { return to!int(a) + to!int(b) + to!int(c) + to!int(d); } // ("10", "20") - stored arguments for evaluator() auto funcattr = createAttributedFunction!sum("10", "20"); // `b` and `d` are unattributed, thus `42` and `13.5` will be // used as their values int result = funcattr(42, 13.5); assert(result == (1020 + 42 + 1020 + to!int(13.5)) * 2);
Fields
Name | Type | Description |
---|---|---|
m_storedArgs
|
StoredArgTypes.expand |
Methods
Name | Description |
---|---|
opCall
|
Used to invoke configured function/method with all attached attribute functions. |
opCall
|
Convenience wrapper tha creates stub delegate for free functions. |
prepareInputAndCall
|
Does all the magic necessary to prepare argument list for attributed
function based on `input_attributes ` and `opCall ` argument list.
|
prepareInputAndCall
|
`prepareInputAndCall ` overload that operates on argument tuple that exactly
matches attributed function argument list and thus gets updated by
attached function instead of being merged with it
|
storeArgs
|
Stores argument tuple for attached function calls |
Aliases
Name | Description |
---|---|
FunctionDg
|
|
input_attributes
|
|
output_attributes
|
|
ParameterTypes
|
|
parameter_names
|
Authors
Михаил Страшун
Copyright
© 2013 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.