redsnow 0.3.7 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +4 -4
- data/ext/drafter/Makefile +54 -0
- data/ext/drafter/appveyor.yml +10 -0
- data/ext/drafter/bin/drafter +0 -0
- data/ext/{snowcrash → drafter}/build/Makefile +29 -14
- data/ext/{snowcrash/build/snowcrash.Makefile → drafter/build/drafter.Makefile} +1 -1
- data/ext/{snowcrash/build/snowcrash.target.mk → drafter/build/drafter.target.mk} +25 -23
- data/ext/{snowcrash/build → drafter/build/ext/snowcrash}/libmarkdownparser.target.mk +7 -7
- data/ext/drafter/build/ext/snowcrash/libsnowcrash.target.mk +152 -0
- data/ext/{snowcrash/build → drafter/build/ext/snowcrash}/libsundown.target.mk +13 -13
- data/ext/{snowcrash/build → drafter/build/ext/snowcrash}/perf-libsnowcrash.target.mk +14 -20
- data/ext/drafter/build/ext/snowcrash/snowcrash.Makefile +6 -0
- data/ext/{snowcrash → drafter}/build/gyp-mac-tool +0 -0
- data/ext/{snowcrash/build/libsnowcrash.target.mk → drafter/build/libdrafter.target.mk} +29 -36
- data/ext/drafter/build/libsos.target.mk +133 -0
- data/ext/drafter/build/out/Release/drafter +0 -0
- data/ext/drafter/build/out/Release/libdrafter.dylib +0 -0
- data/ext/drafter/build/out/Release/libmarkdownparser.a +0 -0
- data/ext/drafter/build/out/Release/libsnowcrash.a +0 -0
- data/ext/drafter/build/out/Release/libsos.a +0 -0
- data/ext/{snowcrash → drafter}/build/out/Release/libsundown.a +0 -0
- data/ext/{snowcrash → drafter}/build/out/Release/linker.lock +0 -0
- data/ext/drafter/build/out/Release/obj.target/drafter/src/config.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/drafter/src/main.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/drafter/src/reporting.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/Serialize.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/SerializeAST.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/SerializeResult.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/SerializeSourcemap.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/cdrafter.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/drafter.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libmarkdownparser/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libmarkdownparser/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libmarkdownparser/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/Blueprint.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/BlueprintSourcemap.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/HTTP.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/HeadersParser.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSON.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONOneOfParser.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONSourcemap.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONTypeSectionParser.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONValueMemberParser.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/Section.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/Signature.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/UriTemplateParser.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/posix/RegexMatch.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/snowcrash.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsos/ext/sos/src/sos.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_href_e.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_html_e.o +0 -0
- data/ext/{snowcrash/build/out/Release/obj.target/libsundown → drafter/build/out/Release/obj.target/libsundown/ext/snowcrash}/ext/markdown-parser/ext/sundown/html/html.o +0 -0
- data/ext/{snowcrash/build/out/Release/obj.target/libsundown → drafter/build/out/Release/obj.target/libsundown/ext/snowcrash}/ext/markdown-parser/ext/sundown/html/html_smartypants.o +0 -0
- data/ext/{snowcrash/build/out/Release/obj.target/libsundown → drafter/build/out/Release/obj.target/libsundown/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/autolink.o +0 -0
- data/ext/{snowcrash/build/out/Release/obj.target/libsundown → drafter/build/out/Release/obj.target/libsundown/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/buffer.o +0 -0
- data/ext/{snowcrash/build/out/Release/obj.target/libsundown → drafter/build/out/Release/obj.target/libsundown/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/markdown.o +0 -0
- data/ext/{snowcrash/build/out/Release/obj.target/libsundown → drafter/build/out/Release/obj.target/libsundown/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/src_map.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.o +0 -0
- data/ext/drafter/circle.yml +12 -0
- data/ext/{snowcrash → drafter}/config.gypi +1 -1
- data/ext/{snowcrash → drafter}/config.mk +0 -0
- data/ext/{snowcrash → drafter}/configure +16 -5
- data/ext/drafter/drafter.gyp +118 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/Makefile +4 -12
- data/ext/{snowcrash → drafter/ext/snowcrash}/Vagrantfile +14 -4
- data/ext/drafter/ext/snowcrash/appveyor.yml +7 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/common.gypi +0 -0
- data/ext/drafter/ext/snowcrash/configure +197 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/Makefile +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/CONTRIBUTING.md +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/Makefile +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/Makefile.win +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/examples/smartypants.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/examples/sundown.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/html/houdini.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/html/houdini_href_e.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/html/houdini_html_e.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/html/html.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/html/html.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/html/html_smartypants.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/html_block_names.txt +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/autolink.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/autolink.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/buffer.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/buffer.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/html_blocks.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/markdown.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/markdown.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/src_map.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/src_map.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/stack.c +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/src/stack.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/ext/sundown/sundown.def +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/msvc/markdown/markdown.vcproj +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/msvc/msvc.sln +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/msvc/sundown/sundown.vcproj +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/src/ByteBuffer.cc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/src/ByteBuffer.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/src/MarkdownNode.cc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/src/MarkdownNode.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/src/MarkdownParser.cc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/ext/markdown-parser/src/MarkdownParser.h +10 -2
- data/ext/{snowcrash → drafter/ext/snowcrash}/provisioning.sh +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/snowcrash.gyp +41 -39
- data/ext/{snowcrash → drafter/ext/snowcrash}/snowcrash.xcworkspace/contents.xcworkspacedata +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/ActionParser.h +50 -6
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/AssetParser.h +1 -12
- data/ext/drafter/ext/snowcrash/src/AttributesParser.h +121 -0
- data/ext/drafter/ext/snowcrash/src/Blueprint.cc +90 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/Blueprint.h +169 -33
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/BlueprintParser.h +305 -48
- data/ext/drafter/ext/snowcrash/src/BlueprintSourcemap.cc +81 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/BlueprintSourcemap.h +130 -39
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/BlueprintUtility.h +10 -4
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/CodeBlockUtility.h +1 -1
- data/ext/drafter/ext/snowcrash/src/DataStructureGroupParser.h +154 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/HTTP.cc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/HTTP.h +0 -0
- data/ext/drafter/ext/snowcrash/src/HeadersParser.cc +110 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/HeadersParser.h +123 -54
- data/ext/drafter/ext/snowcrash/src/MSON.cc +272 -0
- data/ext/drafter/ext/snowcrash/src/MSON.h +399 -0
- data/ext/drafter/ext/snowcrash/src/MSONMixinParser.h +95 -0
- data/ext/drafter/ext/snowcrash/src/MSONNamedTypeParser.h +108 -0
- data/ext/drafter/ext/snowcrash/src/MSONOneOfParser.cc +132 -0
- data/ext/drafter/ext/snowcrash/src/MSONOneOfParser.h +80 -0
- data/ext/drafter/ext/snowcrash/src/MSONParameterParser.h +232 -0
- data/ext/drafter/ext/snowcrash/src/MSONPropertyMemberParser.h +91 -0
- data/ext/drafter/ext/snowcrash/src/MSONSourcemap.cc +141 -0
- data/ext/drafter/ext/snowcrash/src/MSONSourcemap.h +181 -0
- data/ext/drafter/ext/snowcrash/src/MSONTypeSectionParser.cc +209 -0
- data/ext/drafter/ext/snowcrash/src/MSONTypeSectionParser.h +213 -0
- data/ext/drafter/ext/snowcrash/src/MSONUtility.h +423 -0
- data/ext/drafter/ext/snowcrash/src/MSONValueMemberParser.cc +179 -0
- data/ext/drafter/ext/snowcrash/src/MSONValueMemberParser.h +346 -0
- data/ext/drafter/ext/snowcrash/src/ModelTable.h +87 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/ParameterParser.h +120 -61
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/ParametersParser.h +17 -18
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/PayloadParser.h +36 -18
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/Platform.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/RegexMatch.h +0 -0
- data/ext/drafter/ext/snowcrash/src/RelationParser.h +75 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/ResourceGroupParser.h +127 -33
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/ResourceParser.h +126 -33
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/Section.cc +6 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/Section.h +15 -2
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/SectionParser.h +3 -1
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/SectionParserData.h +15 -5
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/SectionProcessor.h +24 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/Signature.cc +14 -0
- data/ext/drafter/ext/snowcrash/src/Signature.h +80 -0
- data/ext/drafter/ext/snowcrash/src/SignatureSectionProcessor.h +439 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/SourceAnnotation.h +3 -2
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/StringUtility.h +103 -6
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/UriTemplateParser.cc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/UriTemplateParser.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/ValuesParser.h +1 -13
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/posix/RegexMatch.cc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/snowcrash.cc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/snowcrash.h +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/src/win/RegexMatch.cc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/AUTHORS +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/DEPS +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/OWNERS +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/PRESUBMIT.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/buildbot/buildbot_run.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/codereview.settings +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/data/win/large-pdb-shim.cc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/gyp +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/gyp.bat +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/gyp_main.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/MSVSNew.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/MSVSProject.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/MSVSSettings.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/MSVSToolFile.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/MSVSUserFile.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/MSVSUtil.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/MSVSVersion.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/__init__.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/__init__.pyc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/common.py +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/easy_xml.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/flock_tool.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/__init__.py +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/android.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/cmake.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/eclipse.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/gypd.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/gypsh.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/make.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/msvs.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/ninja.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/xcode.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/input.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/input.pyc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/mac_tool.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/msvs_emulation.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/ninja_syntax.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/ordered_dict.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/win_tool.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/xcode_emulation.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/xcodeproj_file.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylib/gyp/xml_fix.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/pylintrc +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/samples/samples +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/samples/samples.bat +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/setup.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/tools/emacs/gyp.el +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/tools/graphviz.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/tools/pretty_gyp.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/tools/pretty_sln.py +0 -0
- data/ext/{snowcrash → drafter/ext/snowcrash}/tools/gyp/tools/pretty_vcproj.py +0 -0
- data/ext/drafter/ext/snowcrash/vcbuild.bat +139 -0
- data/ext/drafter/ext/sos/Makefile +57 -0
- data/ext/drafter/ext/sos/src/sos.cc +200 -0
- data/ext/drafter/ext/sos/src/sos.h +179 -0
- data/ext/drafter/ext/sos/src/sosJSON.h +105 -0
- data/ext/drafter/ext/sos/src/sosYAML.h +104 -0
- data/ext/{snowcrash → drafter}/src/Serialize.cc +30 -15
- data/ext/drafter/src/Serialize.h +135 -0
- data/ext/drafter/src/SerializeAST.cc +775 -0
- data/ext/drafter/src/SerializeAST.h +19 -0
- data/ext/drafter/src/SerializeResult.cc +67 -0
- data/ext/drafter/src/SerializeResult.h +26 -0
- data/ext/drafter/src/SerializeSourcemap.cc +446 -0
- data/ext/drafter/src/SerializeSourcemap.h +19 -0
- data/ext/drafter/src/Version.h +38 -0
- data/ext/drafter/src/cdrafter.cc +44 -0
- data/ext/drafter/src/cdrafter.h +55 -0
- data/ext/drafter/src/config.cc +80 -0
- data/ext/drafter/src/config.h +35 -0
- data/ext/drafter/src/drafter.cc +22 -0
- data/ext/drafter/src/drafter.h +38 -0
- data/ext/drafter/src/main.cc +91 -0
- data/ext/drafter/src/reporting.cc +162 -0
- data/ext/drafter/src/reporting.h +28 -0
- data/ext/drafter/src/stream.h +146 -0
- data/ext/drafter/tools/homebrew/drafter.rb +12 -0
- data/ext/{snowcrash → drafter}/vcbuild.bat +3 -3
- data/lib/redsnow.rb +6 -11
- data/lib/redsnow/binding.rb +11 -201
- data/lib/redsnow/blueprint.rb +104 -169
- data/lib/redsnow/parseresult.rb +28 -42
- data/lib/redsnow/sourcemap.rb +92 -177
- data/lib/redsnow/version.rb +1 -1
- data/redsnow.gemspec +1 -1
- metadata +249 -197
- data/ext/snowcrash/bin/snowcrash +0 -0
- data/ext/snowcrash/build/out/Release/libmarkdownparser.a +0 -0
- data/ext/snowcrash/build/out/Release/libsnowcrash.dylib +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libmarkdownparser/ext/markdown-parser/src/ByteBuffer.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libmarkdownparser/ext/markdown-parser/src/MarkdownNode.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libmarkdownparser/ext/markdown-parser/src/MarkdownParser.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/CBlueprint.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/CBlueprintSourcemap.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/CSourceAnnotation.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/HTTP.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/Section.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/Serialize.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/SerializeJSON.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/SerializeYAML.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/Signature.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/UriTemplateParser.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/csnowcrash.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/posix/RegexMatch.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsnowcrash/src/snowcrash.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsundown/ext/markdown-parser/ext/sundown/html/houdini_href_e.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsundown/ext/markdown-parser/ext/sundown/html/houdini_html_e.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/libsundown/ext/markdown-parser/ext/sundown/src/stack.o +0 -0
- data/ext/snowcrash/build/out/Release/obj.target/snowcrash/src/snowcrash/snowcrash.o +0 -0
- data/ext/snowcrash/build/out/Release/snowcrash +0 -0
- data/ext/snowcrash/src/CBlueprint.cc +0 -628
- data/ext/snowcrash/src/CBlueprint.h +0 -366
- data/ext/snowcrash/src/CBlueprintSourcemap.cc +0 -630
- data/ext/snowcrash/src/CBlueprintSourcemap.h +0 -351
- data/ext/snowcrash/src/CSourceAnnotation.cc +0 -154
- data/ext/snowcrash/src/CSourceAnnotation.h +0 -106
- data/ext/snowcrash/src/Serialize.h +0 -71
- data/ext/snowcrash/src/SerializeJSON.cc +0 -1221
- data/ext/snowcrash/src/SerializeJSON.h +0 -24
- data/ext/snowcrash/src/SerializeYAML.cc +0 -702
- data/ext/snowcrash/src/SerializeYAML.h +0 -24
- data/ext/snowcrash/src/Signature.h +0 -32
- data/ext/snowcrash/src/SymbolTable.h +0 -94
- data/ext/snowcrash/src/Version.h +0 -39
- data/ext/snowcrash/src/csnowcrash.cc +0 -29
- data/ext/snowcrash/src/csnowcrash.h +0 -40
- data/ext/snowcrash/src/snowcrash/snowcrash.cc +0 -200
- 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/homebrew/snowcrash.rb +0 -12
@@ -0,0 +1,104 @@
|
|
1
|
+
//
|
2
|
+
// sosYAML.h
|
3
|
+
// sos
|
4
|
+
//
|
5
|
+
// Created by Pavan Kumar Sunkara on 12/01/15.
|
6
|
+
// Copyright (c) 2015 Apiary Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#ifndef SOS_YAML_H
|
10
|
+
#define SOS_YAML_H
|
11
|
+
|
12
|
+
#include "sos.h"
|
13
|
+
|
14
|
+
namespace sos {
|
15
|
+
|
16
|
+
struct SerializeYAML : public Serialize {
|
17
|
+
|
18
|
+
virtual void indent(size_t level, std::ostream& os) {
|
19
|
+
|
20
|
+
for (size_t i = 0; i < level; ++i) {
|
21
|
+
os << " ";
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
virtual void null(std::ostream& os) {
|
26
|
+
|
27
|
+
os << " " << "null";
|
28
|
+
}
|
29
|
+
|
30
|
+
virtual void string(const std::string& value, std::ostream& os) {
|
31
|
+
|
32
|
+
std::string normalized = escapeDoubleQuotes(value);
|
33
|
+
normalized = escapeNewlines(normalized);
|
34
|
+
|
35
|
+
os << " " << "\"" << normalized << "\"";
|
36
|
+
}
|
37
|
+
|
38
|
+
virtual void number(double value, std::ostream& os) {
|
39
|
+
|
40
|
+
os << " " << value;
|
41
|
+
}
|
42
|
+
|
43
|
+
virtual void boolean(bool value, std::ostream& os) {
|
44
|
+
|
45
|
+
os << " " << (value ? "true" : "false");
|
46
|
+
}
|
47
|
+
|
48
|
+
virtual void array(const Base& value, std::ostream& os, size_t level) {
|
49
|
+
|
50
|
+
if (!value.array().empty()) {
|
51
|
+
|
52
|
+
if (level > 0) {
|
53
|
+
os << "\n";
|
54
|
+
}
|
55
|
+
|
56
|
+
size_t i = 0;
|
57
|
+
|
58
|
+
for (Bases::const_iterator it = value.array().begin(); it != value.array().end(); ++i, ++it) {
|
59
|
+
|
60
|
+
if (i > 0 && i < value.array().size()) {
|
61
|
+
os << "\n";
|
62
|
+
}
|
63
|
+
|
64
|
+
indent(level, os);
|
65
|
+
os << "-";
|
66
|
+
process(*it, os, level + 1);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
os << " []";
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
virtual void object(const Base& value, std::ostream& os, size_t level) {
|
75
|
+
|
76
|
+
if (!value.keys.empty()) {
|
77
|
+
|
78
|
+
if (level > 0) {
|
79
|
+
os << "\n";
|
80
|
+
}
|
81
|
+
|
82
|
+
size_t i = 0;
|
83
|
+
|
84
|
+
for (Keys::const_iterator it = value.keys.begin(); it != value.keys.end(); ++i, ++it) {
|
85
|
+
|
86
|
+
if (i > 0 && i < value.keys.size()) {
|
87
|
+
os << "\n";
|
88
|
+
}
|
89
|
+
|
90
|
+
indent(level, os);
|
91
|
+
os << *it;
|
92
|
+
|
93
|
+
os << ":";
|
94
|
+
process(value.object().at(*it), os, level + 1);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
os << " {}";
|
99
|
+
}
|
100
|
+
}
|
101
|
+
};
|
102
|
+
}
|
103
|
+
|
104
|
+
#endif
|
@@ -1,21 +1,16 @@
|
|
1
1
|
//
|
2
2
|
// Serialize.cc
|
3
|
-
//
|
3
|
+
// drafter
|
4
4
|
//
|
5
5
|
// Created by Zdenek Nemec on 5/3/13.
|
6
6
|
// Copyright (c) 2013 Apiary Inc. All rights reserved.
|
7
7
|
//
|
8
8
|
|
9
|
-
#include <string>
|
10
|
-
#include <sstream>
|
11
|
-
#include <algorithm>
|
12
|
-
#include <iterator>
|
13
9
|
#include "Serialize.h"
|
14
10
|
#include "StringUtility.h"
|
15
11
|
|
16
|
-
using namespace
|
12
|
+
using namespace drafter;
|
17
13
|
|
18
|
-
const std::string SerializeKey::ASTVersion = "_version";
|
19
14
|
const std::string SerializeKey::Metadata = "metadata";
|
20
15
|
const std::string SerializeKey::Reference = "reference";
|
21
16
|
const std::string SerializeKey::Id = "id";
|
@@ -25,8 +20,11 @@ const std::string SerializeKey::ResourceGroups = "resourceGroups";
|
|
25
20
|
const std::string SerializeKey::Resources = "resources";
|
26
21
|
const std::string SerializeKey::URI = "uri";
|
27
22
|
const std::string SerializeKey::URITemplate = "uriTemplate";
|
23
|
+
const std::string SerializeKey::Assets = "assets";
|
28
24
|
const std::string SerializeKey::Actions = "actions";
|
29
25
|
const std::string SerializeKey::Action = "action";
|
26
|
+
const std::string SerializeKey::Relation = "relation";
|
27
|
+
const std::string SerializeKey::Attributes = "attributes";
|
30
28
|
const std::string SerializeKey::Method = "method";
|
31
29
|
const std::string SerializeKey::Examples = "examples";
|
32
30
|
const std::string SerializeKey::Requests = "requests";
|
@@ -43,12 +41,29 @@ const std::string SerializeKey::Default = "default";
|
|
43
41
|
const std::string SerializeKey::Example = "example";
|
44
42
|
const std::string SerializeKey::Values = "values";
|
45
43
|
|
46
|
-
std::string
|
47
|
-
|
48
|
-
return ReplaceString(input, "\n", "\\n");
|
49
|
-
}
|
44
|
+
const std::string SerializeKey::Source = "source";
|
45
|
+
const std::string SerializeKey::Resolved = "resolved";
|
50
46
|
|
51
|
-
std::string
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
const std::string SerializeKey::Literal = "literal";
|
48
|
+
const std::string SerializeKey::Variable = "variable";
|
49
|
+
const std::string SerializeKey::TypeDefinition = "typeDefinition";
|
50
|
+
const std::string SerializeKey::TypeSpecification = "typeSpecification";
|
51
|
+
const std::string SerializeKey::NestedTypes = "nestedTypes";
|
52
|
+
const std::string SerializeKey::Sections = "sections";
|
53
|
+
const std::string SerializeKey::Class = "class";
|
54
|
+
const std::string SerializeKey::Content = "content";
|
55
|
+
const std::string SerializeKey::ValueDefinition = "valueDefinition";
|
56
|
+
|
57
|
+
const std::string SerializeKey::Element = "element";
|
58
|
+
const std::string SerializeKey::Role = "role";
|
59
|
+
|
60
|
+
const std::string SerializeKey::Version = "_version";
|
61
|
+
const std::string SerializeKey::Ast = "ast";
|
62
|
+
const std::string SerializeKey::SourceMap= "sourcemap";
|
63
|
+
const std::string SerializeKey::Error = "error";
|
64
|
+
const std::string SerializeKey::Warnings = "warnings";
|
65
|
+
const std::string SerializeKey::AnnotationCode = "code";
|
66
|
+
const std::string SerializeKey::AnnotationMessage = "message";
|
67
|
+
const std::string SerializeKey::AnnotationLocation = "location";
|
68
|
+
const std::string SerializeKey::AnnotationLocationIndex = "index";
|
69
|
+
const std::string SerializeKey::AnnotationLocationLength = "length";
|
@@ -0,0 +1,135 @@
|
|
1
|
+
//
|
2
|
+
// Serialize.h
|
3
|
+
// drafter
|
4
|
+
//
|
5
|
+
// Created by Zdenek Nemec on 5/3/13.
|
6
|
+
// Copyright (c) 2013 Apiary Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#ifndef DRAFTER_SERIALIZE_H
|
10
|
+
#define DRAFTER_SERIALIZE_H
|
11
|
+
|
12
|
+
#include <string>
|
13
|
+
#include "BlueprintSourcemap.h"
|
14
|
+
#include "sos.h"
|
15
|
+
|
16
|
+
/** Version of API Blueprint serialization */
|
17
|
+
#define AST_SERIALIZATION_VERSION "3.0"
|
18
|
+
#define PARSE_RESULT_SERIALIZATION_VERSION "2.1"
|
19
|
+
|
20
|
+
namespace drafter {
|
21
|
+
|
22
|
+
/**
|
23
|
+
* AST entities serialization keys
|
24
|
+
*/
|
25
|
+
struct SerializeKey {
|
26
|
+
static const std::string Metadata;
|
27
|
+
static const std::string Reference;
|
28
|
+
static const std::string Id;
|
29
|
+
static const std::string Name;
|
30
|
+
static const std::string Description;
|
31
|
+
static const std::string ResourceGroups;
|
32
|
+
static const std::string Resources;
|
33
|
+
static const std::string URI;
|
34
|
+
static const std::string URITemplate;
|
35
|
+
static const std::string Assets;
|
36
|
+
static const std::string Actions;
|
37
|
+
static const std::string Action;
|
38
|
+
static const std::string Relation;
|
39
|
+
static const std::string Attributes;
|
40
|
+
static const std::string Examples;
|
41
|
+
static const std::string Transaction;
|
42
|
+
static const std::string Method;
|
43
|
+
static const std::string Requests;
|
44
|
+
static const std::string Responses;
|
45
|
+
static const std::string Body;
|
46
|
+
static const std::string Schema;
|
47
|
+
static const std::string Headers;
|
48
|
+
static const std::string Model;
|
49
|
+
static const std::string Value;
|
50
|
+
static const std::string Parameters;
|
51
|
+
static const std::string Type;
|
52
|
+
static const std::string Required;
|
53
|
+
static const std::string Default;
|
54
|
+
static const std::string Example;
|
55
|
+
static const std::string Values;
|
56
|
+
|
57
|
+
static const std::string Source;
|
58
|
+
static const std::string Resolved;
|
59
|
+
|
60
|
+
static const std::string Literal;
|
61
|
+
static const std::string Variable;
|
62
|
+
static const std::string TypeDefinition;
|
63
|
+
static const std::string TypeSpecification;
|
64
|
+
static const std::string NestedTypes;
|
65
|
+
static const std::string Sections;
|
66
|
+
static const std::string Class;
|
67
|
+
static const std::string Content;
|
68
|
+
static const std::string ValueDefinition;
|
69
|
+
|
70
|
+
static const std::string Element;
|
71
|
+
static const std::string Role;
|
72
|
+
|
73
|
+
static const std::string Version;
|
74
|
+
static const std::string Ast;
|
75
|
+
static const std::string SourceMap;
|
76
|
+
static const std::string Error;
|
77
|
+
static const std::string Warnings;
|
78
|
+
static const std::string AnnotationCode;
|
79
|
+
static const std::string AnnotationMessage;
|
80
|
+
static const std::string AnnotationLocation;
|
81
|
+
static const std::string AnnotationLocationIndex;
|
82
|
+
static const std::string AnnotationLocationLength;
|
83
|
+
};
|
84
|
+
|
85
|
+
|
86
|
+
/**
|
87
|
+
* \brief functor pattern to translate _collection_ into sos::Array on serialization
|
88
|
+
* \requests for collection - must define typedef member ::const_iterator
|
89
|
+
*
|
90
|
+
* usage:
|
91
|
+
*
|
92
|
+
* sos::Array elements = WrapCollection<mson::Element>()(getSomeListOfElements(), WrapMSONElement));
|
93
|
+
*
|
94
|
+
* operator()(const T& collection, Functor &wrapper)
|
95
|
+
* \param collection - it come typicaly from snowcrash
|
96
|
+
* \param wrapper - adaptee element before push to collection
|
97
|
+
* you have to write your own, for example \see SeriallizeAST.cc
|
98
|
+
*
|
99
|
+
*/
|
100
|
+
template<typename T, typename R = sos::Array>
|
101
|
+
struct WrapCollection {
|
102
|
+
|
103
|
+
typedef T value_type;
|
104
|
+
|
105
|
+
template<typename Collection, typename Functor>
|
106
|
+
R operator()(const Collection& collection, Functor &wrapper) const {
|
107
|
+
typedef typename Collection::const_iterator iterator_type;
|
108
|
+
R array;
|
109
|
+
|
110
|
+
for (iterator_type it = collection.begin(); it != collection.end(); ++it) {
|
111
|
+
array.push(wrapper(*it));
|
112
|
+
}
|
113
|
+
|
114
|
+
return array;
|
115
|
+
}
|
116
|
+
|
117
|
+
template<typename Collection, typename Functor, typename Predicate>
|
118
|
+
R operator()(const Collection& collection, Functor &wrapper, Predicate &predicate) const {
|
119
|
+
typedef typename Collection::const_iterator iterator_type;
|
120
|
+
R array;
|
121
|
+
|
122
|
+
for (iterator_type it = collection.begin(); it != collection.end(); ++it) {
|
123
|
+
if (predicate(*it)) {
|
124
|
+
array.push(wrapper(*it));
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
return array;
|
129
|
+
}
|
130
|
+
|
131
|
+
};
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
#endif
|
@@ -0,0 +1,775 @@
|
|
1
|
+
//
|
2
|
+
// SerializeAST.cc
|
3
|
+
// drafter
|
4
|
+
//
|
5
|
+
// Created by Pavan Kumar Sunkara on 18/01/15.
|
6
|
+
// Copyright (c) 2015 Apiary Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#include "StringUtility.h"
|
10
|
+
#include "SerializeAST.h"
|
11
|
+
|
12
|
+
using namespace drafter;
|
13
|
+
|
14
|
+
using snowcrash::AssetRole;
|
15
|
+
using snowcrash::BodyExampleAssetRole;
|
16
|
+
using snowcrash::BodySchemaAssetRole;
|
17
|
+
|
18
|
+
using snowcrash::Element;
|
19
|
+
using snowcrash::Elements;
|
20
|
+
using snowcrash::KeyValuePair;
|
21
|
+
using snowcrash::Metadata;
|
22
|
+
using snowcrash::Header;
|
23
|
+
using snowcrash::Reference;
|
24
|
+
using snowcrash::DataStructure;
|
25
|
+
using snowcrash::Asset;
|
26
|
+
using snowcrash::Payload;
|
27
|
+
using snowcrash::Value;
|
28
|
+
using snowcrash::Parameter;
|
29
|
+
using snowcrash::TransactionExample;
|
30
|
+
using snowcrash::Request;
|
31
|
+
using snowcrash::Response;
|
32
|
+
using snowcrash::Action;
|
33
|
+
using snowcrash::Resource;
|
34
|
+
using snowcrash::Blueprint;
|
35
|
+
|
36
|
+
sos::Object WrapValue(const mson::Value& value)
|
37
|
+
{
|
38
|
+
sos::Object valueObject;
|
39
|
+
|
40
|
+
// Literal
|
41
|
+
valueObject.set(SerializeKey::Literal, sos::String(value.literal));
|
42
|
+
|
43
|
+
// Variable
|
44
|
+
valueObject.set(SerializeKey::Variable, sos::Boolean(value.variable));
|
45
|
+
|
46
|
+
return valueObject;
|
47
|
+
}
|
48
|
+
|
49
|
+
sos::Object WrapSymbol(const mson::Symbol& symbol)
|
50
|
+
{
|
51
|
+
sos::Object symbolObject;
|
52
|
+
|
53
|
+
// Literal
|
54
|
+
symbolObject.set(SerializeKey::Literal, sos::String(symbol.literal));
|
55
|
+
|
56
|
+
// Variable
|
57
|
+
symbolObject.set(SerializeKey::Variable, sos::Boolean(symbol.variable));
|
58
|
+
|
59
|
+
return symbolObject;
|
60
|
+
}
|
61
|
+
|
62
|
+
sos::Base WrapTypeName(const mson::TypeName& typeName)
|
63
|
+
{
|
64
|
+
if (typeName.empty()) {
|
65
|
+
return sos::Null();
|
66
|
+
}
|
67
|
+
|
68
|
+
if (typeName.base != mson::UndefinedTypeName) {
|
69
|
+
|
70
|
+
std::string baseTypeName;
|
71
|
+
|
72
|
+
switch (typeName.base) {
|
73
|
+
|
74
|
+
case mson::BooleanTypeName:
|
75
|
+
baseTypeName = "boolean";
|
76
|
+
break;
|
77
|
+
|
78
|
+
case mson::StringTypeName:
|
79
|
+
baseTypeName = "string";
|
80
|
+
break;
|
81
|
+
|
82
|
+
case mson::NumberTypeName:
|
83
|
+
baseTypeName = "number";
|
84
|
+
break;
|
85
|
+
|
86
|
+
case mson::ArrayTypeName:
|
87
|
+
baseTypeName = "array";
|
88
|
+
break;
|
89
|
+
|
90
|
+
case mson::EnumTypeName:
|
91
|
+
baseTypeName = "enum";
|
92
|
+
break;
|
93
|
+
|
94
|
+
case mson::ObjectTypeName:
|
95
|
+
baseTypeName = "object";
|
96
|
+
break;
|
97
|
+
|
98
|
+
default:
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
|
102
|
+
return sos::String(baseTypeName);
|
103
|
+
}
|
104
|
+
|
105
|
+
return WrapSymbol(typeName.symbol);
|
106
|
+
}
|
107
|
+
|
108
|
+
|
109
|
+
sos::Object WrapTypeSpecification(const mson::TypeSpecification& typeSpecification)
|
110
|
+
{
|
111
|
+
sos::Object typeSpecificationObject;
|
112
|
+
|
113
|
+
// Name
|
114
|
+
typeSpecificationObject.set(SerializeKey::Name, WrapTypeName(typeSpecification.name));
|
115
|
+
|
116
|
+
// Nested Types
|
117
|
+
typeSpecificationObject.set(SerializeKey::NestedTypes,
|
118
|
+
WrapCollection<mson::TypeName>()(typeSpecification.nestedTypes, WrapTypeName));
|
119
|
+
|
120
|
+
return typeSpecificationObject;
|
121
|
+
}
|
122
|
+
|
123
|
+
sos::Array WrapTypeAttributes(const mson::TypeAttributes& typeAttributes)
|
124
|
+
{
|
125
|
+
sos::Array typeAttributesArray;
|
126
|
+
|
127
|
+
if (typeAttributes & mson::RequiredTypeAttribute) {
|
128
|
+
typeAttributesArray.push(sos::String("required"));
|
129
|
+
}
|
130
|
+
else if (typeAttributes & mson::OptionalTypeAttribute) {
|
131
|
+
typeAttributesArray.push(sos::String("optional"));
|
132
|
+
}
|
133
|
+
else if (typeAttributes & mson::DefaultTypeAttribute) {
|
134
|
+
typeAttributesArray.push(sos::String("default"));
|
135
|
+
}
|
136
|
+
else if (typeAttributes & mson::SampleTypeAttribute) {
|
137
|
+
typeAttributesArray.push(sos::String("sample"));
|
138
|
+
}
|
139
|
+
else if (typeAttributes & mson::FixedTypeAttribute) {
|
140
|
+
typeAttributesArray.push(sos::String("fixed"));
|
141
|
+
}
|
142
|
+
|
143
|
+
return typeAttributesArray;
|
144
|
+
}
|
145
|
+
|
146
|
+
sos::Object WrapTypeDefinition(const mson::TypeDefinition& typeDefinition)
|
147
|
+
{
|
148
|
+
sos::Object typeDefinitionObject;
|
149
|
+
|
150
|
+
// Type Specification
|
151
|
+
typeDefinitionObject.set(SerializeKey::TypeSpecification, WrapTypeSpecification(typeDefinition.typeSpecification));
|
152
|
+
|
153
|
+
// Type Attributes
|
154
|
+
typeDefinitionObject.set(SerializeKey::Attributes, WrapTypeAttributes(typeDefinition.attributes));
|
155
|
+
|
156
|
+
return typeDefinitionObject;
|
157
|
+
}
|
158
|
+
|
159
|
+
sos::Object WrapValueDefinition(const mson::ValueDefinition& valueDefinition)
|
160
|
+
{
|
161
|
+
sos::Object valueDefinitionObject;
|
162
|
+
|
163
|
+
// Values
|
164
|
+
valueDefinitionObject.set(SerializeKey::Values,
|
165
|
+
WrapCollection<mson::Value>()(valueDefinition.values, WrapValue));
|
166
|
+
|
167
|
+
// Type Definition
|
168
|
+
valueDefinitionObject.set(SerializeKey::TypeDefinition, WrapTypeDefinition(valueDefinition.typeDefinition));
|
169
|
+
|
170
|
+
return valueDefinitionObject;
|
171
|
+
}
|
172
|
+
|
173
|
+
sos::Object WrapPropertyName(const mson::PropertyName& propertyName)
|
174
|
+
{
|
175
|
+
sos::Object propertyNameObject;
|
176
|
+
|
177
|
+
if (!propertyName.literal.empty()) {
|
178
|
+
propertyNameObject.set(SerializeKey::Literal, sos::String(propertyName.literal));
|
179
|
+
}
|
180
|
+
else if (!propertyName.variable.empty()) {
|
181
|
+
propertyNameObject.set(SerializeKey::Variable, WrapValueDefinition(propertyName.variable));
|
182
|
+
}
|
183
|
+
|
184
|
+
return propertyNameObject;
|
185
|
+
}
|
186
|
+
|
187
|
+
// Forward declarations
|
188
|
+
sos::Object WrapTypeSection(const mson::TypeSection& typeSection);
|
189
|
+
|
190
|
+
const sos::String TypeSectionClassToString(const mson::TypeSection::Class& klass)
|
191
|
+
{
|
192
|
+
switch (klass) {
|
193
|
+
case mson::TypeSection::BlockDescriptionClass:
|
194
|
+
return sos::String("blockDescription");
|
195
|
+
|
196
|
+
case mson::TypeSection::MemberTypeClass:
|
197
|
+
return sos::String("memberType");
|
198
|
+
|
199
|
+
case mson::TypeSection::SampleClass:
|
200
|
+
return sos::String("sample");
|
201
|
+
|
202
|
+
case mson::TypeSection::DefaultClass:
|
203
|
+
return sos::String("default");
|
204
|
+
|
205
|
+
default:
|
206
|
+
return sos::String();
|
207
|
+
}
|
208
|
+
|
209
|
+
return sos::String();
|
210
|
+
}
|
211
|
+
|
212
|
+
sos::String AssetRoleToString(const AssetRole& role)
|
213
|
+
{
|
214
|
+
std::string str;
|
215
|
+
|
216
|
+
switch (role) {
|
217
|
+
case BodyExampleAssetRole:
|
218
|
+
str = "bodyExample";
|
219
|
+
break;
|
220
|
+
|
221
|
+
case BodySchemaAssetRole:
|
222
|
+
str = "bodySchema";
|
223
|
+
break;
|
224
|
+
|
225
|
+
default:
|
226
|
+
break;
|
227
|
+
}
|
228
|
+
|
229
|
+
return sos::String(str);
|
230
|
+
}
|
231
|
+
|
232
|
+
sos::String ElementClassToString(const Element::Class& element)
|
233
|
+
{
|
234
|
+
std::string str;
|
235
|
+
|
236
|
+
switch (element) {
|
237
|
+
case Element::CategoryElement:
|
238
|
+
str = "category";
|
239
|
+
break;
|
240
|
+
|
241
|
+
case Element::CopyElement:
|
242
|
+
str = "copy";
|
243
|
+
break;
|
244
|
+
|
245
|
+
case Element::ResourceElement:
|
246
|
+
str = "resource";
|
247
|
+
break;
|
248
|
+
|
249
|
+
case Element::DataStructureElement:
|
250
|
+
str = "dataStructure";
|
251
|
+
break;
|
252
|
+
|
253
|
+
case Element::AssetElement:
|
254
|
+
str = "asset";
|
255
|
+
break;
|
256
|
+
|
257
|
+
default:
|
258
|
+
break;
|
259
|
+
}
|
260
|
+
|
261
|
+
return sos::String(str);
|
262
|
+
}
|
263
|
+
|
264
|
+
sos::Object WrapNamedType(const mson::NamedType& namedType)
|
265
|
+
{
|
266
|
+
sos::Object namedTypeObject;
|
267
|
+
|
268
|
+
// Name
|
269
|
+
namedTypeObject.set(SerializeKey::Name, WrapTypeName(namedType.name));
|
270
|
+
|
271
|
+
// Type Definition
|
272
|
+
namedTypeObject.set(SerializeKey::TypeDefinition, WrapTypeDefinition(namedType.typeDefinition));
|
273
|
+
|
274
|
+
// Type Sections
|
275
|
+
namedTypeObject.set(SerializeKey::Sections,
|
276
|
+
WrapCollection<mson::TypeSection>()(namedType.sections, WrapTypeSection));
|
277
|
+
|
278
|
+
return namedTypeObject;
|
279
|
+
}
|
280
|
+
|
281
|
+
sos::Object WrapKeyValue(const KeyValuePair& keyValue)
|
282
|
+
{
|
283
|
+
sos::Object keyValueObject;
|
284
|
+
|
285
|
+
// Name
|
286
|
+
keyValueObject.set(SerializeKey::Name, sos::String(keyValue.first));
|
287
|
+
|
288
|
+
// Value
|
289
|
+
keyValueObject.set(SerializeKey::Value, sos::String(keyValue.second));
|
290
|
+
|
291
|
+
return keyValueObject;
|
292
|
+
}
|
293
|
+
|
294
|
+
sos::Object WrapMetadata(const Metadata& metadata)
|
295
|
+
{
|
296
|
+
return WrapKeyValue(metadata);
|
297
|
+
}
|
298
|
+
|
299
|
+
sos::Object WrapHeader(const Header& header)
|
300
|
+
{
|
301
|
+
return WrapKeyValue(header);
|
302
|
+
}
|
303
|
+
|
304
|
+
sos::Object WrapReference(const Reference& reference)
|
305
|
+
{
|
306
|
+
sos::Object referenceObject;
|
307
|
+
|
308
|
+
// Id
|
309
|
+
referenceObject.set(SerializeKey::Id, sos::String(reference.id));
|
310
|
+
|
311
|
+
return referenceObject;
|
312
|
+
}
|
313
|
+
|
314
|
+
sos::Object WrapPropertyMember(const mson::PropertyMember& propertyMember)
|
315
|
+
{
|
316
|
+
sos::Object propertyMemberObject;
|
317
|
+
|
318
|
+
// Name
|
319
|
+
propertyMemberObject.set(SerializeKey::Name, WrapPropertyName(propertyMember.name));
|
320
|
+
|
321
|
+
// Description
|
322
|
+
propertyMemberObject.set(SerializeKey::Description, sos::String(propertyMember.description));
|
323
|
+
|
324
|
+
// Value Definition
|
325
|
+
propertyMemberObject.set(SerializeKey::ValueDefinition, WrapValueDefinition(propertyMember.valueDefinition));
|
326
|
+
|
327
|
+
// Type Sections
|
328
|
+
propertyMemberObject.set(SerializeKey::Sections,
|
329
|
+
WrapCollection<mson::TypeSection>()(propertyMember.sections, WrapTypeSection));
|
330
|
+
|
331
|
+
return propertyMemberObject;
|
332
|
+
}
|
333
|
+
|
334
|
+
sos::Object WrapValueMember(const mson::ValueMember& valueMember)
|
335
|
+
{
|
336
|
+
sos::Object valueMemberObject;
|
337
|
+
|
338
|
+
// Description
|
339
|
+
valueMemberObject.set(SerializeKey::Description, sos::String(valueMember.description));
|
340
|
+
|
341
|
+
// Value Definition
|
342
|
+
valueMemberObject.set(SerializeKey::ValueDefinition, WrapValueDefinition(valueMember.valueDefinition));
|
343
|
+
|
344
|
+
// Type Sections
|
345
|
+
valueMemberObject.set(SerializeKey::Sections,
|
346
|
+
WrapCollection<mson::TypeSection>()(valueMember.sections, WrapTypeSection));
|
347
|
+
|
348
|
+
return valueMemberObject;
|
349
|
+
}
|
350
|
+
|
351
|
+
sos::Object WrapMixin(const mson::Mixin& mixin)
|
352
|
+
{
|
353
|
+
return WrapTypeDefinition(mixin);
|
354
|
+
}
|
355
|
+
|
356
|
+
sos::Object WrapMSONElement(const mson::Element& element)
|
357
|
+
{
|
358
|
+
sos::Object elementObject;
|
359
|
+
std::string klass;
|
360
|
+
|
361
|
+
switch (element.klass) {
|
362
|
+
|
363
|
+
case mson::Element::PropertyClass:
|
364
|
+
{
|
365
|
+
klass = "property";
|
366
|
+
elementObject.set(SerializeKey::Content, WrapPropertyMember(element.content.property));
|
367
|
+
break;
|
368
|
+
}
|
369
|
+
|
370
|
+
case mson::Element::ValueClass:
|
371
|
+
{
|
372
|
+
klass = "value";
|
373
|
+
elementObject.set(SerializeKey::Content, WrapValueMember(element.content.value));
|
374
|
+
break;
|
375
|
+
}
|
376
|
+
|
377
|
+
case mson::Element::MixinClass:
|
378
|
+
{
|
379
|
+
klass = "mixin";
|
380
|
+
elementObject.set(SerializeKey::Content, WrapMixin(element.content.mixin));
|
381
|
+
break;
|
382
|
+
}
|
383
|
+
|
384
|
+
case mson::Element::OneOfClass:
|
385
|
+
{
|
386
|
+
klass = "oneOf";
|
387
|
+
elementObject.set(SerializeKey::Content,
|
388
|
+
WrapCollection<mson::Element>()(element.content.oneOf(), WrapMSONElement));
|
389
|
+
break;
|
390
|
+
}
|
391
|
+
|
392
|
+
case mson::Element::GroupClass:
|
393
|
+
{
|
394
|
+
klass = "group";
|
395
|
+
elementObject.set(SerializeKey::Content,
|
396
|
+
WrapCollection<mson::Element>()(element.content.elements(), WrapMSONElement));
|
397
|
+
break;
|
398
|
+
}
|
399
|
+
|
400
|
+
default:
|
401
|
+
break;
|
402
|
+
}
|
403
|
+
|
404
|
+
elementObject.set(SerializeKey::Class, sos::String(klass));
|
405
|
+
|
406
|
+
return elementObject;
|
407
|
+
}
|
408
|
+
|
409
|
+
sos::Object WrapTypeSection(const mson::TypeSection& section)
|
410
|
+
{
|
411
|
+
sos::Object object;
|
412
|
+
|
413
|
+
// Class
|
414
|
+
object.set(SerializeKey::Class, TypeSectionClassToString(section.klass));
|
415
|
+
|
416
|
+
// Content
|
417
|
+
if (!section.content.description.empty()) {
|
418
|
+
object.set(SerializeKey::Content, sos::String(section.content.description));
|
419
|
+
}
|
420
|
+
else if (!section.content.value.empty()) {
|
421
|
+
object.set(SerializeKey::Content, sos::String(section.content.value));
|
422
|
+
}
|
423
|
+
else if (!section.content.elements().empty()) {
|
424
|
+
object.set(SerializeKey::Content,
|
425
|
+
WrapCollection<mson::Element>()(section.content.elements(), WrapMSONElement));
|
426
|
+
}
|
427
|
+
|
428
|
+
return object;
|
429
|
+
}
|
430
|
+
|
431
|
+
sos::Object WrapDataStructure(const DataStructure& dataStructure)
|
432
|
+
{
|
433
|
+
sos::Object dataStructureObject;
|
434
|
+
|
435
|
+
// Element
|
436
|
+
dataStructureObject.set(SerializeKey::Element, ElementClassToString(Element::DataStructureElement));
|
437
|
+
|
438
|
+
// Name
|
439
|
+
dataStructureObject.set(SerializeKey::Name, WrapTypeName(dataStructure.name));
|
440
|
+
|
441
|
+
// Type Definition
|
442
|
+
dataStructureObject.set(SerializeKey::TypeDefinition, WrapTypeDefinition(dataStructure.typeDefinition));
|
443
|
+
|
444
|
+
// Type Sections
|
445
|
+
dataStructureObject.set(SerializeKey::Sections,
|
446
|
+
WrapCollection<mson::TypeSection>()(dataStructure.sections, WrapTypeSection));
|
447
|
+
|
448
|
+
return dataStructureObject;
|
449
|
+
}
|
450
|
+
|
451
|
+
sos::Object WrapAsset(const Asset& asset, const AssetRole& role)
|
452
|
+
{
|
453
|
+
sos::Object assetObject;
|
454
|
+
|
455
|
+
// Element
|
456
|
+
assetObject.set(SerializeKey::Element, ElementClassToString(Element::AssetElement));
|
457
|
+
|
458
|
+
// Attributes
|
459
|
+
sos::Object attributes;
|
460
|
+
|
461
|
+
/// Role
|
462
|
+
attributes.set(SerializeKey::Role, AssetRoleToString(role));
|
463
|
+
|
464
|
+
assetObject.set(SerializeKey::Attributes, attributes);
|
465
|
+
|
466
|
+
// Content
|
467
|
+
assetObject.set(SerializeKey::Content, sos::String(asset));
|
468
|
+
|
469
|
+
return assetObject;
|
470
|
+
}
|
471
|
+
|
472
|
+
sos::Object WrapPayload(const Payload& payload)
|
473
|
+
{
|
474
|
+
sos::Object payloadObject;
|
475
|
+
|
476
|
+
// Reference
|
477
|
+
if (!payload.reference.id.empty()) {
|
478
|
+
payloadObject.set(SerializeKey::Reference, WrapReference(payload.reference));
|
479
|
+
}
|
480
|
+
|
481
|
+
// Name
|
482
|
+
payloadObject.set(SerializeKey::Name, sos::String(payload.name));
|
483
|
+
|
484
|
+
// Description
|
485
|
+
payloadObject.set(SerializeKey::Description, sos::String(payload.description));
|
486
|
+
|
487
|
+
// Headers
|
488
|
+
payloadObject.set(SerializeKey::Headers,
|
489
|
+
WrapCollection<Header>()(payload.headers, WrapHeader));
|
490
|
+
|
491
|
+
// Body
|
492
|
+
payloadObject.set(SerializeKey::Body, sos::String(payload.body));
|
493
|
+
|
494
|
+
// Schema
|
495
|
+
payloadObject.set(SerializeKey::Schema, sos::String(payload.schema));
|
496
|
+
|
497
|
+
// Content
|
498
|
+
sos::Array content;
|
499
|
+
|
500
|
+
/// Attributes
|
501
|
+
if (!payload.attributes.empty()) {
|
502
|
+
content.push(WrapDataStructure(payload.attributes));
|
503
|
+
}
|
504
|
+
|
505
|
+
/// Asset 'bodyExample'
|
506
|
+
if (!payload.body.empty()) {
|
507
|
+
content.push(WrapAsset(payload.body, BodyExampleAssetRole));
|
508
|
+
}
|
509
|
+
|
510
|
+
/// Asset 'bodySchema'
|
511
|
+
if (!payload.schema.empty()) {
|
512
|
+
content.push(WrapAsset(payload.schema, BodySchemaAssetRole));
|
513
|
+
}
|
514
|
+
|
515
|
+
payloadObject.set(SerializeKey::Content, content);
|
516
|
+
|
517
|
+
return payloadObject;
|
518
|
+
}
|
519
|
+
|
520
|
+
sos::Object WrapParameterValue(const Value& value)
|
521
|
+
{
|
522
|
+
sos::Object object;
|
523
|
+
object.set(SerializeKey::Value, sos::String(value.c_str()));
|
524
|
+
|
525
|
+
return object;
|
526
|
+
}
|
527
|
+
|
528
|
+
sos::Object WrapParameter(const Parameter& parameter)
|
529
|
+
{
|
530
|
+
sos::Object parameterObject;
|
531
|
+
|
532
|
+
// Name
|
533
|
+
parameterObject.set(SerializeKey::Name, sos::String(parameter.name));
|
534
|
+
|
535
|
+
// Description
|
536
|
+
parameterObject.set(SerializeKey::Description, sos::String(parameter.description));
|
537
|
+
|
538
|
+
// Type
|
539
|
+
parameterObject.set(SerializeKey::Type, sos::String(parameter.type));
|
540
|
+
|
541
|
+
// Use
|
542
|
+
parameterObject.set(SerializeKey::Required, sos::Boolean(parameter.use != snowcrash::OptionalParameterUse));
|
543
|
+
|
544
|
+
// Default Value
|
545
|
+
parameterObject.set(SerializeKey::Default, sos::String(parameter.defaultValue));
|
546
|
+
|
547
|
+
// Example Value
|
548
|
+
parameterObject.set(SerializeKey::Example, sos::String(parameter.exampleValue));
|
549
|
+
|
550
|
+
// Values
|
551
|
+
parameterObject.set(SerializeKey::Values,
|
552
|
+
WrapCollection<Value>()(parameter.values, WrapParameterValue));
|
553
|
+
|
554
|
+
return parameterObject;
|
555
|
+
}
|
556
|
+
|
557
|
+
sos::Object WrapTransactionExample(const TransactionExample& example)
|
558
|
+
{
|
559
|
+
sos::Object exampleObject;
|
560
|
+
|
561
|
+
// Name
|
562
|
+
exampleObject.set(SerializeKey::Name, sos::String(example.name));
|
563
|
+
|
564
|
+
// Description
|
565
|
+
exampleObject.set(SerializeKey::Description, sos::String(example.description));
|
566
|
+
|
567
|
+
// Requests
|
568
|
+
exampleObject.set(SerializeKey::Requests,
|
569
|
+
WrapCollection<Request>()(example.requests, WrapPayload));
|
570
|
+
|
571
|
+
// Responses
|
572
|
+
exampleObject.set(SerializeKey::Responses,
|
573
|
+
WrapCollection<Response>()(example.responses, WrapPayload));
|
574
|
+
|
575
|
+
return exampleObject;
|
576
|
+
}
|
577
|
+
|
578
|
+
sos::Object WrapAction(const Action& action)
|
579
|
+
{
|
580
|
+
sos::Object actionObject;
|
581
|
+
|
582
|
+
// Name
|
583
|
+
actionObject.set(SerializeKey::Name, sos::String(action.name));
|
584
|
+
|
585
|
+
// Description
|
586
|
+
actionObject.set(SerializeKey::Description, sos::String(action.description));
|
587
|
+
|
588
|
+
// HTTP Method
|
589
|
+
actionObject.set(SerializeKey::Method, sos::String(action.method));
|
590
|
+
|
591
|
+
// Parameters
|
592
|
+
actionObject.set(SerializeKey::Parameters,
|
593
|
+
WrapCollection<Parameter>()(action.parameters, WrapParameter));
|
594
|
+
|
595
|
+
// Attributes
|
596
|
+
sos::Object attributes;
|
597
|
+
|
598
|
+
/// Relation
|
599
|
+
attributes.set(SerializeKey::Relation, sos::String(action.relation.str));
|
600
|
+
|
601
|
+
/// URI Template
|
602
|
+
attributes.set(SerializeKey::URITemplate, sos::String(action.uriTemplate));
|
603
|
+
|
604
|
+
actionObject.set(SerializeKey::Attributes, attributes);
|
605
|
+
|
606
|
+
// Content
|
607
|
+
sos::Array content;
|
608
|
+
|
609
|
+
if (!action.attributes.empty()) {
|
610
|
+
content.push(WrapDataStructure(action.attributes));
|
611
|
+
}
|
612
|
+
|
613
|
+
actionObject.set(SerializeKey::Content, content);
|
614
|
+
|
615
|
+
// Transaction Examples
|
616
|
+
actionObject.set(SerializeKey::Examples,
|
617
|
+
WrapCollection<TransactionExample>()(action.examples, WrapTransactionExample));
|
618
|
+
|
619
|
+
return actionObject;
|
620
|
+
}
|
621
|
+
|
622
|
+
sos::Object WrapResource(const Resource& resource)
|
623
|
+
{
|
624
|
+
sos::Object resourceObject;
|
625
|
+
|
626
|
+
// Element
|
627
|
+
resourceObject.set(SerializeKey::Element, ElementClassToString(Element::ResourceElement));
|
628
|
+
|
629
|
+
// Name
|
630
|
+
resourceObject.set(SerializeKey::Name, sos::String(resource.name));
|
631
|
+
|
632
|
+
// Description
|
633
|
+
resourceObject.set(SerializeKey::Description, sos::String(resource.description));
|
634
|
+
|
635
|
+
// URI Template
|
636
|
+
resourceObject.set(SerializeKey::URITemplate, sos::String(resource.uriTemplate));
|
637
|
+
|
638
|
+
// Model
|
639
|
+
sos::Object model = (resource.model.name.empty() ? sos::Object() : WrapPayload(resource.model));
|
640
|
+
resourceObject.set(SerializeKey::Model, model);
|
641
|
+
|
642
|
+
// Parameters
|
643
|
+
resourceObject.set(SerializeKey::Parameters,
|
644
|
+
WrapCollection<Parameter>()(resource.parameters, WrapParameter));
|
645
|
+
|
646
|
+
// Actions
|
647
|
+
resourceObject.set(SerializeKey::Actions,
|
648
|
+
WrapCollection<Action>()(resource.actions, WrapAction));
|
649
|
+
|
650
|
+
// Content
|
651
|
+
sos::Array content;
|
652
|
+
|
653
|
+
if (!resource.attributes.empty()) {
|
654
|
+
content.push(WrapDataStructure(resource.attributes));
|
655
|
+
}
|
656
|
+
|
657
|
+
resourceObject.set(SerializeKey::Content, content);
|
658
|
+
|
659
|
+
return resourceObject;
|
660
|
+
}
|
661
|
+
|
662
|
+
sos::Object WrapResourceGroup(const Element& resourceGroup)
|
663
|
+
{
|
664
|
+
sos::Object resourceGroupObject;
|
665
|
+
|
666
|
+
// Name
|
667
|
+
resourceGroupObject.set(SerializeKey::Name, sos::String(resourceGroup.attributes.name));
|
668
|
+
|
669
|
+
// Description && Resources
|
670
|
+
std::string description;
|
671
|
+
sos::Array resources;
|
672
|
+
|
673
|
+
for (Elements::const_iterator it = resourceGroup.content.elements().begin();
|
674
|
+
it != resourceGroup.content.elements().end();
|
675
|
+
++it) {
|
676
|
+
|
677
|
+
if (it->element == Element::ResourceElement) {
|
678
|
+
resources.push(WrapResource(it->content.resource));
|
679
|
+
}
|
680
|
+
else if (it->element == Element::CopyElement) {
|
681
|
+
|
682
|
+
if (!description.empty()) {
|
683
|
+
snowcrash::TwoNewLines(description);
|
684
|
+
}
|
685
|
+
|
686
|
+
description += it->content.copy;
|
687
|
+
}
|
688
|
+
}
|
689
|
+
|
690
|
+
resourceGroupObject.set(SerializeKey::Description, sos::String(description));
|
691
|
+
resourceGroupObject.set(SerializeKey::Resources, resources);
|
692
|
+
|
693
|
+
return resourceGroupObject;
|
694
|
+
}
|
695
|
+
|
696
|
+
sos::Object WrapElement(const Element& element)
|
697
|
+
{
|
698
|
+
sos::Object elementObject;
|
699
|
+
|
700
|
+
elementObject.set(SerializeKey::Element, ElementClassToString(element.element));
|
701
|
+
|
702
|
+
if (!element.attributes.name.empty()) {
|
703
|
+
|
704
|
+
sos::Object attributes;
|
705
|
+
|
706
|
+
attributes.set(SerializeKey::Name, sos::String(element.attributes.name));
|
707
|
+
elementObject.set(SerializeKey::Attributes, attributes);
|
708
|
+
}
|
709
|
+
|
710
|
+
switch (element.element) {
|
711
|
+
case Element::CopyElement:
|
712
|
+
{
|
713
|
+
elementObject.set(SerializeKey::Content, sos::String(element.content.copy));
|
714
|
+
break;
|
715
|
+
}
|
716
|
+
|
717
|
+
case Element::CategoryElement:
|
718
|
+
{
|
719
|
+
elementObject.set(SerializeKey::Content,
|
720
|
+
WrapCollection<Element>()(element.content.elements(), WrapElement));
|
721
|
+
break;
|
722
|
+
}
|
723
|
+
|
724
|
+
case Element::DataStructureElement:
|
725
|
+
{
|
726
|
+
return WrapDataStructure(element.content.dataStructure);
|
727
|
+
}
|
728
|
+
|
729
|
+
case Element::ResourceElement:
|
730
|
+
{
|
731
|
+
return WrapResource(element.content.resource);
|
732
|
+
}
|
733
|
+
|
734
|
+
default:
|
735
|
+
break;
|
736
|
+
}
|
737
|
+
|
738
|
+
return elementObject;
|
739
|
+
}
|
740
|
+
|
741
|
+
bool IsElementResourceGroup(const Element& element)
|
742
|
+
{
|
743
|
+
return element.element == Element::CategoryElement && element.category == Element::ResourceGroupCategory;
|
744
|
+
}
|
745
|
+
|
746
|
+
sos::Object drafter::WrapBlueprint(const Blueprint& blueprint)
|
747
|
+
{
|
748
|
+
sos::Object blueprintObject;
|
749
|
+
|
750
|
+
// Version
|
751
|
+
blueprintObject.set(SerializeKey::Version, sos::String(AST_SERIALIZATION_VERSION));
|
752
|
+
|
753
|
+
// Metadata
|
754
|
+
blueprintObject.set(SerializeKey::Metadata,
|
755
|
+
WrapCollection<Metadata>()(blueprint.metadata, WrapKeyValue));
|
756
|
+
|
757
|
+
// Name
|
758
|
+
blueprintObject.set(SerializeKey::Name, sos::String(blueprint.name));
|
759
|
+
|
760
|
+
// Description
|
761
|
+
blueprintObject.set(SerializeKey::Description, sos::String(blueprint.description));
|
762
|
+
|
763
|
+
// Element
|
764
|
+
blueprintObject.set(SerializeKey::Element, ElementClassToString(blueprint.element));
|
765
|
+
|
766
|
+
// Resource Groups
|
767
|
+
blueprintObject.set(SerializeKey::ResourceGroups,
|
768
|
+
WrapCollection<Element>()(blueprint.content.elements(), WrapResourceGroup, IsElementResourceGroup));
|
769
|
+
|
770
|
+
// Content
|
771
|
+
blueprintObject.set(SerializeKey::Content,
|
772
|
+
WrapCollection<Element>()(blueprint.content.elements(), WrapElement));
|
773
|
+
|
774
|
+
return blueprintObject;
|
775
|
+
}
|