redsnow 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/ext/snowcrash/bin/snowcrash +0 -0
- data/ext/snowcrash/snowcrash.xcworkspace/contents.xcworkspacedata +10 -0
- data/ext/snowcrash/src/ActionParser.h +35 -33
- data/ext/snowcrash/src/AssetParser.h +17 -17
- data/ext/snowcrash/src/Blueprint.h +101 -66
- data/ext/snowcrash/src/BlueprintParser.h +219 -10
- data/ext/snowcrash/src/BlueprintSourcemap.h +1 -1
- data/ext/snowcrash/src/BlueprintUtility.h +14 -14
- data/ext/snowcrash/src/CBlueprint.cc +29 -10
- data/ext/snowcrash/src/CBlueprint.h +19 -3
- data/ext/snowcrash/src/CBlueprintSourcemap.cc +20 -10
- data/ext/snowcrash/src/CBlueprintSourcemap.h +12 -3
- data/ext/snowcrash/src/CodeBlockUtility.h +25 -25
- data/ext/snowcrash/src/HTTP.cc +3 -0
- data/ext/snowcrash/src/HTTP.h +9 -6
- data/ext/snowcrash/src/HeadersParser.h +34 -14
- data/ext/snowcrash/src/ParameterParser.h +21 -21
- data/ext/snowcrash/src/ParametersParser.h +6 -5
- data/ext/snowcrash/src/PayloadParser.h +174 -129
- data/ext/snowcrash/src/RegexMatch.h +3 -3
- data/ext/snowcrash/src/ResourceGroupParser.h +5 -4
- data/ext/snowcrash/src/ResourceParser.h +30 -26
- data/ext/snowcrash/src/Section.cc +6 -6
- data/ext/snowcrash/src/Section.h +2 -2
- data/ext/snowcrash/src/SectionParser.h +41 -41
- data/ext/snowcrash/src/SectionParserData.h +10 -10
- data/ext/snowcrash/src/SectionProcessor.h +70 -30
- data/ext/snowcrash/src/Serialize.h +3 -3
- data/ext/snowcrash/src/SerializeJSON.cc +124 -96
- data/ext/snowcrash/src/SerializeJSON.h +1 -1
- data/ext/snowcrash/src/SerializeYAML.cc +71 -53
- data/ext/snowcrash/src/SerializeYAML.h +1 -1
- data/ext/snowcrash/src/Signature.cc +2 -2
- data/ext/snowcrash/src/Signature.h +1 -1
- data/ext/snowcrash/src/SourceAnnotation.h +23 -23
- data/ext/snowcrash/src/StringUtility.h +71 -9
- data/ext/snowcrash/src/SymbolTable.h +17 -17
- data/ext/snowcrash/src/UriTemplateParser.cc +5 -5
- data/ext/snowcrash/src/UriTemplateParser.h +9 -9
- data/ext/snowcrash/src/ValuesParser.h +2 -2
- data/ext/snowcrash/src/Version.h +1 -1
- data/ext/snowcrash/src/csnowcrash.cc +10 -8
- data/ext/snowcrash/src/snowcrash.cc +9 -9
- data/ext/snowcrash/src/snowcrash.h +6 -8
- data/ext/snowcrash/src/snowcrash/snowcrash.cc +14 -14
- data/ext/snowcrash/src/win/RegexMatch.cc +7 -7
- data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
- data/ext/snowcrash/tools/homebrew/snowcrash.rb +1 -1
- data/lib/redsnow/binding.rb +8 -2
- data/lib/redsnow/blueprint.rb +4 -3
- data/lib/redsnow/sourcemap.rb +6 -4
- data/lib/redsnow/version.rb +1 -1
- metadata +4 -17
@@ -32,14 +32,15 @@ namespace snowcrash {
|
|
32
32
|
const MarkdownNodes& siblings,
|
33
33
|
SectionParserData& pd,
|
34
34
|
SectionLayout& layout,
|
35
|
-
|
35
|
+
const ParseResultRef<Blueprint>& out) {
|
36
36
|
|
37
37
|
MarkdownNodeIterator cur = node;
|
38
38
|
|
39
39
|
while (cur != siblings.end() &&
|
40
40
|
cur->type == mdp::ParagraphMarkdownNodeType) {
|
41
41
|
|
42
|
-
|
42
|
+
IntermediateParseResult<MetadataCollection> metadata(out.report);
|
43
|
+
|
43
44
|
parseMetadata(cur, pd, metadata);
|
44
45
|
|
45
46
|
// First block is paragraph and is not metadata (no API name)
|
@@ -57,7 +58,7 @@ namespace snowcrash {
|
|
57
58
|
|
58
59
|
cur++;
|
59
60
|
}
|
60
|
-
|
61
|
+
|
61
62
|
// Ideally this parsing metadata should be handled by separate parser
|
62
63
|
// that way the following check would be covered in SectionParser::parse()
|
63
64
|
if (cur == siblings.end())
|
@@ -91,12 +92,13 @@ namespace snowcrash {
|
|
91
92
|
static MarkdownNodeIterator processNestedSection(const MarkdownNodeIterator& node,
|
92
93
|
const MarkdownNodes& siblings,
|
93
94
|
SectionParserData& pd,
|
94
|
-
|
95
|
+
const ParseResultRef<Blueprint>& out) {
|
95
96
|
|
96
97
|
if (pd.sectionContext() == ResourceGroupSectionType ||
|
97
98
|
pd.sectionContext() == ResourceSectionType) {
|
98
99
|
|
99
|
-
|
100
|
+
IntermediateParseResult<ResourceGroup> resourceGroup(out.report);
|
101
|
+
|
100
102
|
MarkdownNodeIterator cur = ResourceGroupParser::parse(node, siblings, pd, resourceGroup);
|
101
103
|
|
102
104
|
ResourceGroupIterator duplicate = findResourceGroup(out.node.resourceGroups, resourceGroup.node);
|
@@ -171,8 +173,10 @@ namespace snowcrash {
|
|
171
173
|
|
172
174
|
static void finalize(const MarkdownNodeIterator& node,
|
173
175
|
SectionParserData& pd,
|
174
|
-
|
175
|
-
|
176
|
+
const ParseResultRef<Blueprint>& out) {
|
177
|
+
|
178
|
+
checkLazyReferencing(pd, out);
|
179
|
+
|
176
180
|
if (!out.node.name.empty())
|
177
181
|
return;
|
178
182
|
|
@@ -183,7 +187,7 @@ namespace snowcrash {
|
|
183
187
|
out.report.error = Error(ExpectedAPINameMessage,
|
184
188
|
BusinessError,
|
185
189
|
sourceMap);
|
186
|
-
|
190
|
+
|
187
191
|
}
|
188
192
|
else if (!out.node.description.empty()) {
|
189
193
|
mdp::CharactersRangeSet sourceMap = mdp::BytesRangeSetToCharactersRangeSet(node->sourceMap, pd.sourceData);
|
@@ -195,7 +199,7 @@ namespace snowcrash {
|
|
195
199
|
|
196
200
|
static bool isUnexpectedNode(const MarkdownNodeIterator& node,
|
197
201
|
SectionType sectionType) {
|
198
|
-
|
202
|
+
|
199
203
|
// Since Blueprint is currently top-level node any unprocessed node should be reported
|
200
204
|
return true;
|
201
205
|
}
|
@@ -203,7 +207,7 @@ namespace snowcrash {
|
|
203
207
|
|
204
208
|
static void parseMetadata(const MarkdownNodeIterator& node,
|
205
209
|
SectionParserData& pd,
|
206
|
-
|
210
|
+
const ParseResultRef<MetadataCollection>& out) {
|
207
211
|
|
208
212
|
mdp::ByteBuffer content = node->text;
|
209
213
|
TrimStringEnd(content);
|
@@ -278,6 +282,211 @@ namespace snowcrash {
|
|
278
282
|
resourceGroups.end(),
|
279
283
|
std::bind2nd(MatchName<ResourceGroup>(), resourceGroup));
|
280
284
|
}
|
285
|
+
|
286
|
+
/**
|
287
|
+
* \brief Checks both blueprint and source map AST to resolve references with `Pending` state (Lazy referencing)
|
288
|
+
* \param pd Section parser state
|
289
|
+
* \param out Processed output
|
290
|
+
*/
|
291
|
+
static void checkLazyReferencing(SectionParserData& pd,
|
292
|
+
const ParseResultRef<Blueprint>& out) {
|
293
|
+
|
294
|
+
Collection<SourceMap<ResourceGroup> >::iterator resourceGroupSourceMapIt;
|
295
|
+
|
296
|
+
if (pd.exportSourceMap()) {
|
297
|
+
resourceGroupSourceMapIt = out.sourceMap.resourceGroups.collection.begin();
|
298
|
+
}
|
299
|
+
|
300
|
+
for (ResourceGroups::iterator resourceGroupIt = out.node.resourceGroups.begin();
|
301
|
+
resourceGroupIt != out.node.resourceGroups.end();
|
302
|
+
++resourceGroupIt) {
|
303
|
+
|
304
|
+
checkResourceLazyReferencing(*resourceGroupIt, resourceGroupSourceMapIt, pd, out);
|
305
|
+
|
306
|
+
if (pd.exportSourceMap()) {
|
307
|
+
resourceGroupSourceMapIt++;
|
308
|
+
}
|
309
|
+
}
|
310
|
+
}
|
311
|
+
|
312
|
+
/** Traverses Resource Collection to resolve references with `Pending` state (Lazy referencing) */
|
313
|
+
static void checkResourceLazyReferencing(ResourceGroup& resourceGroup,
|
314
|
+
Collection<SourceMap<ResourceGroup> >::iterator resourceGroupSourceMapIt,
|
315
|
+
SectionParserData& pd,
|
316
|
+
const ParseResultRef<Blueprint>& out) {
|
317
|
+
|
318
|
+
Collection<SourceMap<Resource> >::iterator resourceSourceMapIt;
|
319
|
+
|
320
|
+
if (pd.exportSourceMap()) {
|
321
|
+
resourceSourceMapIt = resourceGroupSourceMapIt->resources.collection.begin();
|
322
|
+
}
|
323
|
+
|
324
|
+
for (Resources::iterator resourceIt = resourceGroup.resources.begin();
|
325
|
+
resourceIt != resourceGroup.resources.end();
|
326
|
+
++resourceIt) {
|
327
|
+
|
328
|
+
checkActionLazyReferencing(*resourceIt, resourceSourceMapIt, pd, out);
|
329
|
+
|
330
|
+
if (pd.exportSourceMap()) {
|
331
|
+
resourceSourceMapIt++;
|
332
|
+
}
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
/** Traverses Action Collection to resolve references with `Pending` state (Lazy referencing) */
|
337
|
+
static void checkActionLazyReferencing(Resource& resource,
|
338
|
+
Collection<SourceMap<Resource> >::iterator resourceSourceMapIt,
|
339
|
+
SectionParserData& pd,
|
340
|
+
const ParseResultRef<Blueprint>& out) {
|
341
|
+
|
342
|
+
Collection<SourceMap<Action> >::iterator actionSourceMapIt;
|
343
|
+
|
344
|
+
if (pd.exportSourceMap()) {
|
345
|
+
actionSourceMapIt = resourceSourceMapIt->actions.collection.begin();
|
346
|
+
}
|
347
|
+
|
348
|
+
for (Actions::iterator actionIt = resource.actions.begin();
|
349
|
+
actionIt != resource.actions.end();
|
350
|
+
++actionIt) {
|
351
|
+
|
352
|
+
checkExampleLazyReferencing(*actionIt, actionSourceMapIt, pd, out);
|
353
|
+
|
354
|
+
if (pd.exportSourceMap()) {
|
355
|
+
actionSourceMapIt++;
|
356
|
+
}
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
/** Traverses Transaction Example Collection AST to resolve references with `Pending` state (Lazy referencing) */
|
361
|
+
static void checkExampleLazyReferencing(Action& action,
|
362
|
+
Collection<SourceMap<Action> >::iterator actionSourceMapIt,
|
363
|
+
SectionParserData& pd,
|
364
|
+
const ParseResultRef<Blueprint>& out) {
|
365
|
+
|
366
|
+
Collection<SourceMap<TransactionExample> >::iterator exampleSourceMapIt;
|
367
|
+
|
368
|
+
if (pd.exportSourceMap()) {
|
369
|
+
exampleSourceMapIt = actionSourceMapIt->examples.collection.begin();
|
370
|
+
}
|
371
|
+
|
372
|
+
for (TransactionExamples::iterator transactionExampleIt = action.examples.begin();
|
373
|
+
transactionExampleIt != action.examples.end();
|
374
|
+
++transactionExampleIt) {
|
375
|
+
|
376
|
+
checkRequestLazyReferencing(*transactionExampleIt, exampleSourceMapIt, pd, out);
|
377
|
+
checkResponseLazyReferencing(*transactionExampleIt, exampleSourceMapIt, pd, out);
|
378
|
+
|
379
|
+
if (pd.exportSourceMap()) {
|
380
|
+
exampleSourceMapIt++;
|
381
|
+
}
|
382
|
+
}
|
383
|
+
}
|
384
|
+
|
385
|
+
/** Traverses Request Collection to resolve references with `Pending` state (Lazy referencing) */
|
386
|
+
static void checkRequestLazyReferencing(TransactionExample& transactionExample,
|
387
|
+
Collection<SourceMap<TransactionExample> >::iterator transactionExampleSourceMapIt,
|
388
|
+
SectionParserData& pd,
|
389
|
+
const ParseResultRef<Blueprint>& out) {
|
390
|
+
|
391
|
+
Collection<SourceMap<Request> >::iterator requestSourceMapIt;
|
392
|
+
|
393
|
+
if (pd.exportSourceMap()) {
|
394
|
+
requestSourceMapIt = transactionExampleSourceMapIt->requests.collection.begin();
|
395
|
+
}
|
396
|
+
|
397
|
+
for (Requests::iterator requestIt = transactionExample.requests.begin();
|
398
|
+
requestIt != transactionExample.requests.end();
|
399
|
+
++requestIt) {
|
400
|
+
|
401
|
+
if (!requestIt->reference.id.empty() &&
|
402
|
+
requestIt->reference.meta.state == Reference::StatePending) {
|
403
|
+
|
404
|
+
if (pd.exportSourceMap()) {
|
405
|
+
|
406
|
+
ParseResultRef<Payload> payload(out.report, *requestIt, *requestSourceMapIt);
|
407
|
+
resolvePendingSymbols(pd, payload);
|
408
|
+
SectionProcessor<Payload>::checkRequest(requestIt->reference.meta.node, pd, payload);
|
409
|
+
}
|
410
|
+
else {
|
411
|
+
|
412
|
+
SourceMap<Payload> tempSourceMap;
|
413
|
+
ParseResultRef<Payload> payload(out.report, *requestIt, tempSourceMap);
|
414
|
+
resolvePendingSymbols(pd, payload);
|
415
|
+
SectionProcessor<Payload>::checkRequest(requestIt->reference.meta.node, pd, payload);
|
416
|
+
}
|
417
|
+
}
|
418
|
+
|
419
|
+
if (pd.exportSourceMap()) {
|
420
|
+
requestSourceMapIt++;
|
421
|
+
}
|
422
|
+
}
|
423
|
+
}
|
424
|
+
|
425
|
+
/** Traverses Response Collection to resolve references with `Pending` state (Lazy referencing) */
|
426
|
+
static void checkResponseLazyReferencing(TransactionExample& transactionExample,
|
427
|
+
Collection<SourceMap<TransactionExample> >::iterator transactionExampleSourceMapIt,
|
428
|
+
SectionParserData& pd,
|
429
|
+
const ParseResultRef<Blueprint>& out) {
|
430
|
+
|
431
|
+
Collection<SourceMap<Response> >::iterator responseSourceMapIt;
|
432
|
+
|
433
|
+
if (pd.exportSourceMap()) {
|
434
|
+
responseSourceMapIt = transactionExampleSourceMapIt->responses.collection.begin();
|
435
|
+
}
|
436
|
+
|
437
|
+
for (Responses::iterator responseIt = transactionExample.responses.begin();
|
438
|
+
responseIt != transactionExample.responses.end();
|
439
|
+
++responseIt) {
|
440
|
+
|
441
|
+
if (!responseIt->reference.id.empty() &&
|
442
|
+
responseIt->reference.meta.state == Reference::StatePending) {
|
443
|
+
|
444
|
+
if (pd.exportSourceMap()) {
|
445
|
+
|
446
|
+
ParseResultRef<Payload> payload(out.report, *responseIt, *responseSourceMapIt);
|
447
|
+
resolvePendingSymbols(pd, payload);
|
448
|
+
SectionProcessor<Payload>::checkResponse(responseIt->reference.meta.node, pd, payload);
|
449
|
+
}
|
450
|
+
else {
|
451
|
+
|
452
|
+
SourceMap<Payload> tempSourceMap;
|
453
|
+
ParseResultRef<Payload> payload(out.report, *responseIt, tempSourceMap);
|
454
|
+
resolvePendingSymbols(pd, payload);
|
455
|
+
SectionProcessor<Payload>::checkResponse(responseIt->reference.meta.node, pd, payload);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
if (pd.exportSourceMap()) {
|
460
|
+
responseSourceMapIt++;
|
461
|
+
}
|
462
|
+
}
|
463
|
+
}
|
464
|
+
|
465
|
+
/**
|
466
|
+
* \brief Resolve pending references
|
467
|
+
* \param pd Section parser state
|
468
|
+
* \param out Processed output
|
469
|
+
*/
|
470
|
+
static void resolvePendingSymbols(SectionParserData& pd,
|
471
|
+
const ParseResultRef<Payload>& out) {
|
472
|
+
|
473
|
+
if (pd.symbolTable.resourceModels.find(out.node.reference.id) == pd.symbolTable.resourceModels.end()) {
|
474
|
+
|
475
|
+
// ERR: Undefined symbol
|
476
|
+
std::stringstream ss;
|
477
|
+
ss << "Undefined symbol " << out.node.reference.id;
|
478
|
+
|
479
|
+
mdp::CharactersRangeSet sourceMap = mdp::BytesRangeSetToCharactersRangeSet(out.node.reference.meta.node->sourceMap, pd.sourceData);
|
480
|
+
out.report.error = Error(ss.str(), SymbolError, sourceMap);
|
481
|
+
|
482
|
+
out.node.reference.meta.state = Reference::StateUnresolved;
|
483
|
+
}
|
484
|
+
else {
|
485
|
+
|
486
|
+
out.node.reference.meta.state = Reference::StateResolved;
|
487
|
+
SectionProcessor<Payload>::assingReferredPayload(pd, out);
|
488
|
+
}
|
489
|
+
}
|
281
490
|
};
|
282
491
|
|
283
492
|
/** Blueprint Parser */
|
@@ -15,29 +15,29 @@
|
|
15
15
|
#include "HTTP.h"
|
16
16
|
|
17
17
|
namespace snowcrash {
|
18
|
-
|
18
|
+
|
19
19
|
/**
|
20
20
|
* \brief Pair firsts matching predicate.
|
21
21
|
*
|
22
22
|
* Two pairs are a match if their %first matches.
|
23
23
|
*/
|
24
|
-
template <class T>
|
24
|
+
template <class T, class Predicate = std::equal_to<typename T::first_type> >
|
25
25
|
struct MatchFirsts : std::binary_function<T, T, bool> {
|
26
26
|
bool operator()(const T& left, const T& right) const {
|
27
|
-
return left.first
|
27
|
+
return Predicate()(left.first, right.first);
|
28
28
|
}
|
29
29
|
};
|
30
|
-
|
30
|
+
|
31
31
|
/**
|
32
32
|
* \brief Matches a pair's first against a value.
|
33
33
|
*/
|
34
|
-
template <class T, class R>
|
34
|
+
template <class T, class R = typename T::first_type, class Predicate = std::equal_to<R> >
|
35
35
|
struct MatchFirstWith : std::binary_function<T, R, bool> {
|
36
36
|
bool operator()(const T& left, const R& right) const {
|
37
|
-
return left.first
|
37
|
+
return Predicate()(left.first, right);
|
38
38
|
}
|
39
39
|
};
|
40
|
-
|
40
|
+
|
41
41
|
/** A name matching predicate. */
|
42
42
|
template <class T>
|
43
43
|
struct MatchName : std::binary_function<T, T, bool> {
|
@@ -45,7 +45,7 @@ namespace snowcrash {
|
|
45
45
|
return first.name == second.name;
|
46
46
|
}
|
47
47
|
};
|
48
|
-
|
48
|
+
|
49
49
|
/**
|
50
50
|
* \brief Payload matching predicate.
|
51
51
|
*
|
@@ -53,11 +53,11 @@ namespace snowcrash {
|
|
53
53
|
*/
|
54
54
|
struct MatchPayload : std::binary_function<Payload, Payload, bool> {
|
55
55
|
bool operator()(const first_argument_type& left, const second_argument_type& right) const {
|
56
|
-
|
56
|
+
|
57
57
|
|
58
58
|
if (left.name != right.name)
|
59
59
|
return false;
|
60
|
-
|
60
|
+
|
61
61
|
// Resolve left content type
|
62
62
|
Collection<Header>::const_iterator header;
|
63
63
|
|
@@ -70,7 +70,7 @@ namespace snowcrash {
|
|
70
70
|
|
71
71
|
if (header != left.headers.end())
|
72
72
|
leftContentType = header->second;
|
73
|
-
|
73
|
+
|
74
74
|
// Resolve right content type
|
75
75
|
header = std::find_if(right.headers.begin(),
|
76
76
|
right.headers.end(),
|
@@ -81,18 +81,18 @@ namespace snowcrash {
|
|
81
81
|
|
82
82
|
if (header != right.headers.end())
|
83
83
|
rightContentType = header->second;
|
84
|
-
|
84
|
+
|
85
85
|
return leftContentType == rightContentType;
|
86
86
|
}
|
87
87
|
};
|
88
|
-
|
88
|
+
|
89
89
|
/** URI matching predicate. */
|
90
90
|
struct MatchResource : std::binary_function<Resource, Resource, bool> {
|
91
91
|
bool operator()(const first_argument_type& first, const second_argument_type& second) const {
|
92
92
|
return first.uriTemplate == second.uriTemplate;
|
93
93
|
}
|
94
94
|
};
|
95
|
-
|
95
|
+
|
96
96
|
/** Action matching predicate. */
|
97
97
|
template <class T>
|
98
98
|
struct MatchAction : std::binary_function<T, T, bool> {
|
@@ -252,16 +252,6 @@ SC_API const char* sc_payload_name(const sc_payload_t* handle)
|
|
252
252
|
return p->name.c_str();
|
253
253
|
}
|
254
254
|
|
255
|
-
/** TODO: Need to change this to use the "Reference" data structure */
|
256
|
-
SC_API const char* sc_payload_symbol(const sc_payload_t* handle)
|
257
|
-
{
|
258
|
-
const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
|
259
|
-
if (!p)
|
260
|
-
return "";
|
261
|
-
|
262
|
-
return p->symbol.c_str();
|
263
|
-
}
|
264
|
-
|
265
255
|
SC_API const char* sc_payload_description(const sc_payload_t* handle)
|
266
256
|
{
|
267
257
|
const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
|
@@ -291,6 +281,35 @@ SC_API const char* sc_payload_schema(const sc_payload_t* handle)
|
|
291
281
|
|
292
282
|
/*----------------------------------------------------------------------*/
|
293
283
|
|
284
|
+
SC_API const sc_reference_t* sc_reference_handle_payload(const sc_payload_t* handle)
|
285
|
+
{
|
286
|
+
const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
|
287
|
+
if(!p)
|
288
|
+
return NULL;
|
289
|
+
|
290
|
+
return AS_CTYPE(sc_reference_t, &p->reference);
|
291
|
+
}
|
292
|
+
|
293
|
+
SC_API const char* sc_reference_id(const sc_reference_t* handle)
|
294
|
+
{
|
295
|
+
const snowcrash::Reference* p = AS_CTYPE(snowcrash::Reference, handle);
|
296
|
+
if (!p)
|
297
|
+
return "";
|
298
|
+
|
299
|
+
return p->id.c_str();
|
300
|
+
}
|
301
|
+
|
302
|
+
SC_API sc_reference_type_t sc_reference_type(const sc_reference_t* handle)
|
303
|
+
{
|
304
|
+
const snowcrash::Reference* p = AS_CTYPE(snowcrash::Reference, handle);
|
305
|
+
if (!p)
|
306
|
+
return (sc_reference_type_t)0;
|
307
|
+
|
308
|
+
return (sc_reference_type_t)p->type;
|
309
|
+
}
|
310
|
+
|
311
|
+
/*----------------------------------------------------------------------*/
|
312
|
+
|
294
313
|
SC_API const sc_parameter_collection_t* sc_parameter_collection_handle_payload(const sc_payload_t* handle)
|
295
314
|
{
|
296
315
|
const snowcrash::Payload* p = AS_CTYPE(snowcrash::Payload, handle);
|
@@ -34,6 +34,10 @@ extern "C" {
|
|
34
34
|
SC_REQUIRED_PARAMETER_USE
|
35
35
|
} sc_parameter_use;
|
36
36
|
|
37
|
+
typedef enum sc_reference_type_t {
|
38
|
+
SC_TYPE_SYMBOL_REFERENCE
|
39
|
+
} sc_reference_type_t;
|
40
|
+
|
37
41
|
/** Class Blueprint wrapper */
|
38
42
|
struct sc_blueprint_s;
|
39
43
|
typedef struct sc_blueprint_s sc_blueprint_t;
|
@@ -70,6 +74,10 @@ extern "C" {
|
|
70
74
|
struct sc_payload_collection_s;
|
71
75
|
typedef struct sc_payload_collection_s sc_payload_collection_t;
|
72
76
|
|
77
|
+
/** Class Reference wrapper */
|
78
|
+
struct sc_reference_s;
|
79
|
+
typedef struct sc_reference_s sc_reference_t;
|
80
|
+
|
73
81
|
/** Class Payload wrapper */
|
74
82
|
struct sc_payload_s;
|
75
83
|
typedef struct sc_payload_s sc_payload_t;
|
@@ -210,9 +218,6 @@ extern "C" {
|
|
210
218
|
/** \returns Payload name */
|
211
219
|
SC_API const char* sc_payload_name(const sc_payload_t* handle);
|
212
220
|
|
213
|
-
/** \returns Payload symbol name */
|
214
|
-
SC_API const char* sc_payload_symbol(const sc_payload_t* handle);
|
215
|
-
|
216
221
|
/** \returns Payload description */
|
217
222
|
SC_API const char* sc_payload_description(const sc_payload_t* handle);
|
218
223
|
|
@@ -224,6 +229,17 @@ extern "C" {
|
|
224
229
|
|
225
230
|
/*----------------------------------------------------------------------*/
|
226
231
|
|
232
|
+
/** \returns Reference handle from payload */
|
233
|
+
SC_API const sc_reference_t* sc_reference_handle_payload(const sc_payload_t* handle);
|
234
|
+
|
235
|
+
/** \returns Reference identifier */
|
236
|
+
SC_API const char* sc_reference_id(const sc_reference_t* handle);
|
237
|
+
|
238
|
+
/** \returns Reference identifier */
|
239
|
+
SC_API sc_reference_type_t sc_reference_type(const sc_reference_t* handle);
|
240
|
+
|
241
|
+
/*----------------------------------------------------------------------*/
|
242
|
+
|
227
243
|
/** \returns Parameter Collection handle from Payload */
|
228
244
|
SC_API const sc_parameter_collection_t* sc_parameter_collection_handle_payload(const sc_payload_t* handle);
|
229
245
|
|