lounge_lizard 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Guardfile +33 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +43 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/circle.yml +14 -0
- data/ext/drafter/CHANGELOG.md +278 -0
- data/ext/drafter/Dockerfile +17 -0
- data/ext/drafter/Makefile +62 -0
- data/ext/drafter/appveyor.yml +17 -0
- data/ext/drafter/bin/drafter +0 -0
- data/ext/drafter/build/Makefile +387 -0
- data/ext/drafter/build/drafter.Makefile +6 -0
- data/ext/drafter/build/drafter.target.mk +159 -0
- data/ext/drafter/build/ext/snowcrash/libmarkdownparser.target.mk +141 -0
- data/ext/drafter/build/ext/snowcrash/libsnowcrash.target.mk +154 -0
- data/ext/drafter/build/ext/snowcrash/libsundown.target.mk +149 -0
- data/ext/drafter/build/ext/snowcrash/perf-libsnowcrash.target.mk +147 -0
- data/ext/drafter/build/ext/snowcrash/snowcrash.Makefile +6 -0
- data/ext/drafter/build/gyp-mac-tool +606 -0
- data/ext/drafter/build/libdrafter.target.mk +186 -0
- data/ext/drafter/build/libsos.target.mk +137 -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/drafter/build/out/Release/libsundown.a +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/ConversionContext.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/NamedTypesRegistry.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractAPI.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractDataStructure.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractElementFactory.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractSourceMap.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/Render.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/drafter.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/drafter_private.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/ComparableVisitor.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/Element.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/ExpandVisitor.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/IsExpandableVisitor.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/JSONSchemaVisitor.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/PrintVisitor.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/Query.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/Registry.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/RenderJSONVisitor.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/SerializeCompactVisitor.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/SerializeVisitor.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/TypeQueryVisitor.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/VisitorUtils.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/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html_smartypants.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.o +0 -0
- data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.o +0 -0
- data/ext/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 +32 -0
- data/ext/drafter/config.gypi +10 -0
- data/ext/drafter/config.mk +5 -0
- data/ext/drafter/configure +224 -0
- data/ext/drafter/drafter.gyp +189 -0
- data/ext/drafter/drafter.xcworkspace/contents.xcworkspacedata +13 -0
- data/ext/drafter/ext/snowcrash/Makefile +58 -0
- data/ext/drafter/ext/snowcrash/appveyor.yml +7 -0
- data/ext/drafter/ext/snowcrash/common.gypi +165 -0
- data/ext/drafter/ext/snowcrash/configure +197 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/Makefile +90 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/CONTRIBUTING.md +10 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/Makefile +84 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/Makefile.win +33 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/examples/smartypants.c +72 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/examples/sundown.c +80 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini.h +37 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_href_e.c +108 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_html_e.c +84 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.c +647 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.h +77 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html_smartypants.c +389 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html_block_names.txt +25 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.c +297 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.h +51 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.c +225 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.h +96 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/html_blocks.h +206 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.c +2726 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.h +147 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/src_map.c +204 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/src_map.h +58 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.c +81 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.h +29 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/sundown.def +20 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/msvc/markdown/markdown.vcproj +188 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/msvc/msvc.sln +38 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/msvc/sundown/sundown.vcproj +206 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.cc +160 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.h +90 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.cc +152 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.h +103 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.cc +388 -0
- data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.h +106 -0
- data/ext/drafter/ext/snowcrash/snowcrash.gyp +196 -0
- data/ext/drafter/ext/snowcrash/src/ActionParser.h +560 -0
- data/ext/drafter/ext/snowcrash/src/AssetParser.h +123 -0
- data/ext/drafter/ext/snowcrash/src/AttributesParser.h +123 -0
- data/ext/drafter/ext/snowcrash/src/Blueprint.cc +90 -0
- data/ext/drafter/ext/snowcrash/src/Blueprint.h +489 -0
- data/ext/drafter/ext/snowcrash/src/BlueprintParser.h +845 -0
- data/ext/drafter/ext/snowcrash/src/BlueprintSourcemap.cc +81 -0
- data/ext/drafter/ext/snowcrash/src/BlueprintSourcemap.h +345 -0
- data/ext/drafter/ext/snowcrash/src/BlueprintUtility.h +111 -0
- data/ext/drafter/ext/snowcrash/src/CodeBlockUtility.h +276 -0
- data/ext/drafter/ext/snowcrash/src/DataStructureGroupParser.h +157 -0
- data/ext/drafter/ext/snowcrash/src/HTTP.cc +49 -0
- data/ext/drafter/ext/snowcrash/src/HTTP.h +108 -0
- data/ext/drafter/ext/snowcrash/src/HeadersParser.cc +117 -0
- data/ext/drafter/ext/snowcrash/src/HeadersParser.h +377 -0
- data/ext/drafter/ext/snowcrash/src/MSON.cc +272 -0
- data/ext/drafter/ext/snowcrash/src/MSON.h +405 -0
- data/ext/drafter/ext/snowcrash/src/MSONMixinParser.h +103 -0
- data/ext/drafter/ext/snowcrash/src/MSONNamedTypeParser.h +135 -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 +166 -0
- data/ext/drafter/ext/snowcrash/src/MSONPropertyMemberParser.h +106 -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 +506 -0
- data/ext/drafter/ext/snowcrash/src/MSONValueMemberParser.cc +214 -0
- data/ext/drafter/ext/snowcrash/src/MSONValueMemberParser.h +390 -0
- data/ext/drafter/ext/snowcrash/src/ModelTable.h +87 -0
- data/ext/drafter/ext/snowcrash/src/ParameterParser.h +516 -0
- data/ext/drafter/ext/snowcrash/src/ParametersParser.h +222 -0
- data/ext/drafter/ext/snowcrash/src/PayloadParser.h +733 -0
- data/ext/drafter/ext/snowcrash/src/Platform.h +33 -0
- data/ext/drafter/ext/snowcrash/src/RegexMatch.h +32 -0
- data/ext/drafter/ext/snowcrash/src/RelationParser.h +87 -0
- data/ext/drafter/ext/snowcrash/src/ResourceGroupParser.h +297 -0
- data/ext/drafter/ext/snowcrash/src/ResourceParser.h +536 -0
- data/ext/drafter/ext/snowcrash/src/Section.cc +48 -0
- data/ext/drafter/ext/snowcrash/src/Section.h +60 -0
- data/ext/drafter/ext/snowcrash/src/SectionParser.h +246 -0
- data/ext/drafter/ext/snowcrash/src/SectionParserData.h +109 -0
- data/ext/drafter/ext/snowcrash/src/SectionProcessor.h +299 -0
- data/ext/drafter/ext/snowcrash/src/Signature.cc +75 -0
- data/ext/drafter/ext/snowcrash/src/Signature.h +103 -0
- data/ext/drafter/ext/snowcrash/src/SignatureSectionProcessor.h +442 -0
- data/ext/drafter/ext/snowcrash/src/SourceAnnotation.h +166 -0
- data/ext/drafter/ext/snowcrash/src/StringUtility.h +323 -0
- data/ext/drafter/ext/snowcrash/src/UriTemplateParser.cc +195 -0
- data/ext/drafter/ext/snowcrash/src/UriTemplateParser.h +240 -0
- data/ext/drafter/ext/snowcrash/src/ValuesParser.h +111 -0
- data/ext/drafter/ext/snowcrash/src/posix/RegexMatch.cc +99 -0
- data/ext/drafter/ext/snowcrash/src/snowcrash.cc +90 -0
- data/ext/drafter/ext/snowcrash/src/snowcrash.h +44 -0
- data/ext/drafter/ext/snowcrash/src/win/RegexMatch.cc +78 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/AUTHORS +12 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/DEPS +23 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/OWNERS +1 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/PRESUBMIT.py +137 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/buildbot/buildbot_run.py +136 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/buildbot/commit_queue/OWNERS +6 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/buildbot/commit_queue/cq_config.json +15 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/codereview.settings +10 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/data/win/large-pdb-shim.cc +12 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/gyp +8 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/gyp.bat +5 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/gyp_main.py +16 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSNew.py +340 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSProject.py +208 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSSettings.py +1096 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSToolFile.py +58 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUserFile.py +147 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.py +270 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.py +445 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/__init__.py +548 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/common.py +608 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/easy_xml.py +157 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/flock_tool.py +54 -0
- data/ext/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/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/analyzer.py +741 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/android.py +1069 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/cmake.py +1248 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/dump_dependency_json.py +99 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/eclipse.py +425 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypd.py +94 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypsh.py +56 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.py +2218 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/msvs.py +3467 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.py +2427 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.py +1300 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/input.py +2899 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/mac_tool.py +605 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.py +1093 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.py +160 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/ordered_dict.py +289 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/simple_copy.py +46 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/simple_copy.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/win_tool.py +314 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.py +1664 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_ninja.py +276 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_ninja.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.py +2927 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xml_fix.py +69 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/pylintrc +307 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/samples/samples +81 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/samples/samples.bat +5 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/setup.py +19 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec +27 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec +226 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/tools/emacs/gyp.el +275 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/tools/graphviz.py +100 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/tools/pretty_gyp.py +155 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/tools/pretty_sln.py +169 -0
- data/ext/drafter/ext/snowcrash/tools/gyp/tools/pretty_vcproj.py +329 -0
- data/ext/drafter/ext/snowcrash/vcbuild.bat +139 -0
- data/ext/drafter/ext/sos/Makefile +62 -0
- data/ext/drafter/ext/sos/src/sos.cc +235 -0
- data/ext/drafter/ext/sos/src/sos.h +188 -0
- data/ext/drafter/ext/sos/src/sosJSON.h +121 -0
- data/ext/drafter/ext/sos/src/sosYAML.h +105 -0
- data/ext/drafter/src/ConversionContext.cc +39 -0
- data/ext/drafter/src/ConversionContext.h +34 -0
- data/ext/drafter/src/NamedTypesRegistry.cc +405 -0
- data/ext/drafter/src/NamedTypesRegistry.h +28 -0
- data/ext/drafter/src/NodeInfo.h +143 -0
- data/ext/drafter/src/RefractAPI.cc +579 -0
- data/ext/drafter/src/RefractAPI.h +28 -0
- data/ext/drafter/src/RefractDataStructure.cc +1199 -0
- data/ext/drafter/src/RefractDataStructure.h +26 -0
- data/ext/drafter/src/RefractElementFactory.cc +107 -0
- data/ext/drafter/src/RefractElementFactory.h +67 -0
- data/ext/drafter/src/RefractSourceMap.cc +29 -0
- data/ext/drafter/src/RefractSourceMap.h +57 -0
- data/ext/drafter/src/Render.cc +157 -0
- data/ext/drafter/src/Render.h +40 -0
- data/ext/drafter/src/Serialize.cc +160 -0
- data/ext/drafter/src/Serialize.h +289 -0
- data/ext/drafter/src/SerializeAST.cc +507 -0
- data/ext/drafter/src/SerializeAST.h +29 -0
- data/ext/drafter/src/SerializeResult.cc +170 -0
- data/ext/drafter/src/SerializeResult.h +34 -0
- data/ext/drafter/src/SerializeSourcemap.cc +331 -0
- data/ext/drafter/src/SerializeSourcemap.h +21 -0
- data/ext/drafter/src/Version.h +40 -0
- data/ext/drafter/src/config.cc +91 -0
- data/ext/drafter/src/config.h +38 -0
- data/ext/drafter/src/drafter.cc +137 -0
- data/ext/drafter/src/drafter.h +102 -0
- data/ext/drafter/src/drafter_private.cc +85 -0
- data/ext/drafter/src/drafter_private.h +34 -0
- data/ext/drafter/src/main.cc +137 -0
- data/ext/drafter/src/refract/AppendDecorator.h +58 -0
- data/ext/drafter/src/refract/Build.h +67 -0
- data/ext/drafter/src/refract/ComparableVisitor.cc +43 -0
- data/ext/drafter/src/refract/ComparableVisitor.h +62 -0
- data/ext/drafter/src/refract/Element.cc +409 -0
- data/ext/drafter/src/refract/Element.h +656 -0
- data/ext/drafter/src/refract/ElementFwd.h +37 -0
- data/ext/drafter/src/refract/ElementInserter.h +59 -0
- data/ext/drafter/src/refract/Exception.h +31 -0
- data/ext/drafter/src/refract/ExpandVisitor.cc +359 -0
- data/ext/drafter/src/refract/ExpandVisitor.h +58 -0
- data/ext/drafter/src/refract/FilterVisitor.h +52 -0
- data/ext/drafter/src/refract/IsExpandableVisitor.cc +140 -0
- data/ext/drafter/src/refract/IsExpandableVisitor.h +31 -0
- data/ext/drafter/src/refract/Iterate.h +160 -0
- data/ext/drafter/src/refract/JSONSchemaVisitor.cc +675 -0
- data/ext/drafter/src/refract/JSONSchemaVisitor.h +73 -0
- data/ext/drafter/src/refract/PrintVisitor.cc +164 -0
- data/ext/drafter/src/refract/PrintVisitor.h +50 -0
- data/ext/drafter/src/refract/Query.cc +13 -0
- data/ext/drafter/src/refract/Query.h +38 -0
- data/ext/drafter/src/refract/Registry.cc +114 -0
- data/ext/drafter/src/refract/Registry.h +43 -0
- data/ext/drafter/src/refract/RenderJSONVisitor.cc +255 -0
- data/ext/drafter/src/refract/RenderJSONVisitor.h +51 -0
- data/ext/drafter/src/refract/SerializeCompactVisitor.cc +167 -0
- data/ext/drafter/src/refract/SerializeCompactVisitor.h +56 -0
- data/ext/drafter/src/refract/SerializeVisitor.cc +214 -0
- data/ext/drafter/src/refract/SerializeVisitor.h +55 -0
- data/ext/drafter/src/refract/TypeQueryVisitor.cc +46 -0
- data/ext/drafter/src/refract/TypeQueryVisitor.h +110 -0
- data/ext/drafter/src/refract/Visitor.h +126 -0
- data/ext/drafter/src/refract/VisitorUtils.cc +63 -0
- data/ext/drafter/src/refract/VisitorUtils.h +231 -0
- data/ext/drafter/src/reporting.cc +263 -0
- data/ext/drafter/src/reporting.h +39 -0
- data/ext/drafter/src/stream.h +148 -0
- data/ext/drafter/tools/homebrew/drafter.rb +18 -0
- data/ext/drafter/tools/make-tarball.sh +39 -0
- data/ext/drafter/tools/refract-filter.py +96 -0
- data/ext/drafter/tools/release.sh +17 -0
- data/ext/drafter/vcbuild.bat +203 -0
- data/lib/lounge_lizard/binding.rb +29 -0
- data/lib/lounge_lizard/version.rb +3 -0
- data/lib/lounge_lizard.rb +18 -0
- data/lounge_lizard.gemspec +37 -0
- metadata +547 -0
@@ -0,0 +1,675 @@
|
|
1
|
+
//
|
2
|
+
// refract/JSONSchemaVisitor.cc
|
3
|
+
// librefract
|
4
|
+
//
|
5
|
+
// Created by Vilibald Wanča on 09/11/15.
|
6
|
+
// Copyright (c) 2015, 2016 Apiary Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#include "VisitorUtils.h"
|
10
|
+
#include "sosJSON.h"
|
11
|
+
#include <sstream>
|
12
|
+
#include <iostream>
|
13
|
+
#include <map>
|
14
|
+
|
15
|
+
#include "RenderJSONVisitor.h"
|
16
|
+
#include "JSONSchemaVisitor.h"
|
17
|
+
#include "SerializeCompactVisitor.h"
|
18
|
+
|
19
|
+
namespace refract
|
20
|
+
{
|
21
|
+
|
22
|
+
template <typename T>
|
23
|
+
void CloneMembers(T* a, const RefractElements* val)
|
24
|
+
{
|
25
|
+
for (RefractElements::const_iterator it = val->begin();
|
26
|
+
it != val->end();
|
27
|
+
++it) {
|
28
|
+
|
29
|
+
if ((*it)->empty()) {
|
30
|
+
continue;
|
31
|
+
}
|
32
|
+
|
33
|
+
RenderJSONVisitor v;
|
34
|
+
Visit(v, *(*it));
|
35
|
+
IElement *e = v.getOwnership();
|
36
|
+
e->renderType(IElement::rCompact);
|
37
|
+
a->push_back(e);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
template <typename T>
|
43
|
+
void IncludeMembers(const T& element, typename T::ValueType& members)
|
44
|
+
{
|
45
|
+
const typename T::ValueType* val = GetValue<T>(element);
|
46
|
+
|
47
|
+
if (!val) {
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
|
51
|
+
for (typename T::ValueType::const_iterator it = val->begin();
|
52
|
+
it != val->end();
|
53
|
+
++it) {
|
54
|
+
|
55
|
+
if (!(*it) || (*it)->empty()) {
|
56
|
+
continue;
|
57
|
+
}
|
58
|
+
|
59
|
+
if ((*it)->element() == "ref") {
|
60
|
+
HandleRefWhenFetchingMembers<T>(*it, members, IncludeMembers<T>);
|
61
|
+
continue;
|
62
|
+
}
|
63
|
+
|
64
|
+
members.push_back(*it);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
JSONSchemaVisitor::JSONSchemaVisitor(ObjectElement *pDefinitions /*= NULL*/,
|
69
|
+
bool _fixed /*= false*/,
|
70
|
+
bool _fixedType /*= false*/)
|
71
|
+
: pDefs(pDefinitions), fixed(_fixed), fixedType(_fixedType)
|
72
|
+
{
|
73
|
+
pObj = new ObjectElement;
|
74
|
+
pObj->renderType(IElement::rCompact);
|
75
|
+
|
76
|
+
if (!pDefs) {
|
77
|
+
pDefs = new ObjectElement;
|
78
|
+
pDefs->renderType(IElement::rCompact);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
JSONSchemaVisitor::~JSONSchemaVisitor()
|
83
|
+
{
|
84
|
+
if (NULL != pObj) {
|
85
|
+
delete pObj;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
void JSONSchemaVisitor::setFixed(bool _fixed)
|
91
|
+
{
|
92
|
+
fixed = _fixed;
|
93
|
+
}
|
94
|
+
|
95
|
+
void JSONSchemaVisitor::setFixedType(bool _fixedType)
|
96
|
+
{
|
97
|
+
fixedType = _fixedType;
|
98
|
+
}
|
99
|
+
|
100
|
+
template<>
|
101
|
+
void JSONSchemaVisitor::setPrimitiveType(const BooleanElement& e)
|
102
|
+
{
|
103
|
+
setSchemaType("boolean");
|
104
|
+
}
|
105
|
+
|
106
|
+
template<>
|
107
|
+
void JSONSchemaVisitor::setPrimitiveType(const StringElement& e)
|
108
|
+
{
|
109
|
+
setSchemaType("string");
|
110
|
+
}
|
111
|
+
|
112
|
+
template<>
|
113
|
+
void JSONSchemaVisitor::setPrimitiveType(const NumberElement& e)
|
114
|
+
{
|
115
|
+
setSchemaType("number");
|
116
|
+
}
|
117
|
+
|
118
|
+
void JSONSchemaVisitor::setSchemaType(const std::string& type)
|
119
|
+
{
|
120
|
+
addMember("type",
|
121
|
+
new StringElement(
|
122
|
+
type,
|
123
|
+
IElement::rCompact));
|
124
|
+
}
|
125
|
+
|
126
|
+
void JSONSchemaVisitor::addSchemaType(const std::string& type)
|
127
|
+
{
|
128
|
+
// FIXME: this will not work corretly if "type" attribute will already
|
129
|
+
// have more members
|
130
|
+
// need to check if type is it is Array and for already pushed types
|
131
|
+
MemberElement *m = FindMemberByKey(*pObj, "type");
|
132
|
+
|
133
|
+
if (m && m->value.second) {
|
134
|
+
IElement *t = m->value.second;
|
135
|
+
ArrayElement *a = new ArrayElement;
|
136
|
+
a->push_back(t);
|
137
|
+
a->push_back(IElement::Create(type));
|
138
|
+
m->value.second = a;
|
139
|
+
} else {
|
140
|
+
setSchemaType(type);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
void JSONSchemaVisitor::addMember(const std::string& key, IElement *val)
|
145
|
+
{
|
146
|
+
pObj->push_back(new MemberElement(
|
147
|
+
key,
|
148
|
+
val,
|
149
|
+
IElement::rCompact));
|
150
|
+
}
|
151
|
+
|
152
|
+
bool JSONSchemaVisitor::allItemsEmpty(const ArrayElement::ValueType* val)
|
153
|
+
{
|
154
|
+
return std::find_if(val->begin(),val->end(), std::not1(std::mem_fun(&refract::IElement::empty))) == val->end();
|
155
|
+
}
|
156
|
+
|
157
|
+
template<typename T>
|
158
|
+
void JSONSchemaVisitor::primitiveType(const T& e)
|
159
|
+
{
|
160
|
+
const typename T::ValueType *value = GetValue<T>(e);
|
161
|
+
|
162
|
+
if (value) {
|
163
|
+
setPrimitiveType(e);
|
164
|
+
|
165
|
+
if (fixed) {
|
166
|
+
ArrayElement *a = new ArrayElement;
|
167
|
+
a->push_back(IElement::Create(*value));
|
168
|
+
addMember("enum", a);
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
void JSONSchemaVisitor::operator()(const IElement& e)
|
174
|
+
{
|
175
|
+
VisitBy(e, *this);
|
176
|
+
}
|
177
|
+
|
178
|
+
void JSONSchemaVisitor::operator()(const MemberElement& e)
|
179
|
+
{
|
180
|
+
JSONSchemaVisitor renderer(pDefs);
|
181
|
+
|
182
|
+
if (e.value.second) {
|
183
|
+
if (IsTypeAttribute(e, "fixed") || fixed) {
|
184
|
+
renderer.setFixed(true);
|
185
|
+
}
|
186
|
+
|
187
|
+
renderer.setFixedType(IsTypeAttribute(e, "fixedType"));
|
188
|
+
Visit(renderer, *e.value.second);
|
189
|
+
}
|
190
|
+
|
191
|
+
StringElement* str = TypeQueryVisitor::as<StringElement>(e.value.first);
|
192
|
+
ExtendElement* ext = TypeQueryVisitor::as<ExtendElement>(e.value.first);
|
193
|
+
|
194
|
+
if (ext) {
|
195
|
+
IElement* merged = ext->merge();
|
196
|
+
str = TypeQueryVisitor::as<StringElement>(merged);
|
197
|
+
|
198
|
+
if (!str) {
|
199
|
+
delete merged;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
if (str) {
|
204
|
+
IElement *desc = GetDescription(e);
|
205
|
+
|
206
|
+
if (desc) {
|
207
|
+
IElement *d = desc->clone();
|
208
|
+
d->renderType(IElement::rCompact);
|
209
|
+
renderer.addMember("description", d);
|
210
|
+
}
|
211
|
+
|
212
|
+
if (IsTypeAttribute(e, "nullable")) {
|
213
|
+
renderer.addSchemaType("null");
|
214
|
+
}
|
215
|
+
|
216
|
+
// Check for primitive types
|
217
|
+
StringElement* strSecond = TypeQueryVisitor::as<StringElement>(e.value.second);
|
218
|
+
NumberElement* numSecond = TypeQueryVisitor::as<NumberElement>(e.value.second);
|
219
|
+
BooleanElement* boolSecond = TypeQueryVisitor::as<BooleanElement>(e.value.second);
|
220
|
+
|
221
|
+
if (e.value.second && (strSecond || numSecond || boolSecond)) {
|
222
|
+
IElement::MemberElementCollection::const_iterator defaultIt = e.value.second->attributes.find("default");
|
223
|
+
|
224
|
+
if (defaultIt != e.value.second->attributes.end()) {
|
225
|
+
renderer.addMember("default", (*defaultIt)->clone());
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
addMember(str->value, renderer.getOwnership());
|
230
|
+
}
|
231
|
+
else {
|
232
|
+
throw LogicError("A property's key in the object is not of type string");
|
233
|
+
}
|
234
|
+
|
235
|
+
if (ext && str) {
|
236
|
+
delete str; // if Extend -> remove resolved (merged) element
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
ObjectElement* JSONSchemaVisitor::definitionFromVariableProperty(JSONSchemaVisitor& renderer)
|
241
|
+
{
|
242
|
+
ObjectElement* definition = new ObjectElement();
|
243
|
+
|
244
|
+
definition->push_back(new MemberElement(
|
245
|
+
"type",
|
246
|
+
new StringElement("object", IElement::rCompact),
|
247
|
+
IElement::rCompact));
|
248
|
+
definition->push_back(new MemberElement(
|
249
|
+
"patternProperties",
|
250
|
+
new ObjectElement(
|
251
|
+
new MemberElement("", renderer.getOwnership(), IElement::rCompact),
|
252
|
+
IElement::rCompact),
|
253
|
+
IElement::rCompact));
|
254
|
+
|
255
|
+
return definition;
|
256
|
+
}
|
257
|
+
|
258
|
+
ArrayElement* JSONSchemaVisitor::arrayFromProps(std::vector<MemberElement*>& props)
|
259
|
+
{
|
260
|
+
ArrayElement *a = new ArrayElement;
|
261
|
+
a->renderType(IElement::rCompact);
|
262
|
+
|
263
|
+
for (std::vector<MemberElement *>::const_iterator i = props.begin();
|
264
|
+
i != props.end();
|
265
|
+
++i) {
|
266
|
+
|
267
|
+
StringElement *str = TypeQueryVisitor::as<StringElement>((*i)->value.first);
|
268
|
+
|
269
|
+
if (str) {
|
270
|
+
bool fixedType = IsTypeAttribute(*(*i), "fixedType");
|
271
|
+
JSONSchemaVisitor renderer(pDefs, fixed, fixedType);
|
272
|
+
Visit(renderer, *(*i)->value.second);
|
273
|
+
|
274
|
+
pDefs->push_back(new MemberElement(
|
275
|
+
str->value,
|
276
|
+
definitionFromVariableProperty(renderer),
|
277
|
+
IElement::rCompact));
|
278
|
+
|
279
|
+
a->push_back(new ObjectElement(
|
280
|
+
new MemberElement(
|
281
|
+
"$ref",
|
282
|
+
new StringElement(
|
283
|
+
"#/definitions/" + str->value,
|
284
|
+
IElement::rCompact),
|
285
|
+
IElement::rCompact),
|
286
|
+
IElement::rCompact));
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
return a;
|
291
|
+
}
|
292
|
+
|
293
|
+
void JSONSchemaVisitor::addVariableProps(std::vector<MemberElement*>& props,
|
294
|
+
ObjectElement *o)
|
295
|
+
{
|
296
|
+
if (o->empty() && props.size() == 1) {
|
297
|
+
StringElement *str = TypeQueryVisitor::as<StringElement>(props[0]->value.first);
|
298
|
+
|
299
|
+
if (str) {
|
300
|
+
bool fixedType = IsTypeAttribute(*props.front(), "fixedType");
|
301
|
+
JSONSchemaVisitor renderer(pDefs, fixed, fixedType);
|
302
|
+
Visit(renderer, *props.front()->value.second);
|
303
|
+
|
304
|
+
pDefs->push_back(new MemberElement(
|
305
|
+
str->value,
|
306
|
+
definitionFromVariableProperty(renderer),
|
307
|
+
IElement::rCompact));
|
308
|
+
|
309
|
+
addMember("$ref", new StringElement("#/definitions/" + str->value, IElement::rCompact));
|
310
|
+
}
|
311
|
+
}
|
312
|
+
else {
|
313
|
+
ArrayElement *a = arrayFromProps(props);
|
314
|
+
|
315
|
+
if (!o->empty()) {
|
316
|
+
a->push_back(new ObjectElement(
|
317
|
+
new MemberElement(
|
318
|
+
"properties",
|
319
|
+
o,
|
320
|
+
IElement::rCompact),
|
321
|
+
IElement::rCompact));
|
322
|
+
}
|
323
|
+
|
324
|
+
addMember("allOf", a);
|
325
|
+
}
|
326
|
+
}
|
327
|
+
|
328
|
+
|
329
|
+
void JSONSchemaVisitor::operator()(const ObjectElement& e)
|
330
|
+
{
|
331
|
+
ObjectElement::ValueType val;
|
332
|
+
IncludeMembers(e, val);
|
333
|
+
|
334
|
+
ObjectElement *o = new ObjectElement;
|
335
|
+
ArrayElement::ValueType reqVals;
|
336
|
+
std::vector<MemberElement*> varProps;
|
337
|
+
RefractElements oneOfMembers;
|
338
|
+
|
339
|
+
o->renderType(IElement::rCompact);
|
340
|
+
|
341
|
+
if (IsTypeAttribute(e, "fixed")) {
|
342
|
+
fixed = true;
|
343
|
+
}
|
344
|
+
|
345
|
+
if (IsTypeAttribute(e, "fixedType")) {
|
346
|
+
fixedType = true;
|
347
|
+
}
|
348
|
+
|
349
|
+
for (std::vector<refract::IElement*>::const_iterator it = val.begin();
|
350
|
+
it != val.end();
|
351
|
+
++it) {
|
352
|
+
|
353
|
+
if (!*it) {
|
354
|
+
continue;
|
355
|
+
}
|
356
|
+
|
357
|
+
TypeQueryVisitor type;
|
358
|
+
Visit(type, *(*it));
|
359
|
+
|
360
|
+
switch (type.get()) {
|
361
|
+
case TypeQueryVisitor::Member: {
|
362
|
+
MemberElement *mr = static_cast<MemberElement*>(*it);
|
363
|
+
if (IsTypeAttribute(*(*it), "required") ||
|
364
|
+
IsTypeAttribute(*(*it), "fixed") ||
|
365
|
+
((fixed || fixedType) && !IsTypeAttribute(*(*it), "optional"))) {
|
366
|
+
|
367
|
+
StringElement *str = TypeQueryVisitor::as<StringElement>(mr->value.first);
|
368
|
+
if (str) {
|
369
|
+
reqVals.push_back(IElement::Create(str->value));
|
370
|
+
}
|
371
|
+
}
|
372
|
+
|
373
|
+
if (IsVariableProperty(*mr->value.first)) {
|
374
|
+
varProps.push_back(mr);
|
375
|
+
}
|
376
|
+
else {
|
377
|
+
JSONSchemaVisitor renderer(pDefs, fixed);
|
378
|
+
Visit(renderer, *(*it));
|
379
|
+
ObjectElement *o1 = TypeQueryVisitor::as<ObjectElement>(renderer.get());
|
380
|
+
if (!o1->value.empty()) {
|
381
|
+
MemberElement *m1 = TypeQueryVisitor::as<MemberElement>(o1->value[0]->clone());
|
382
|
+
if (m1) {
|
383
|
+
m1->renderType(IElement::rCompact);
|
384
|
+
o->push_back(m1);
|
385
|
+
}
|
386
|
+
|
387
|
+
}
|
388
|
+
}
|
389
|
+
}
|
390
|
+
break;
|
391
|
+
|
392
|
+
case TypeQueryVisitor::Select:
|
393
|
+
{
|
394
|
+
SelectElement* sel = static_cast<SelectElement*>(*it);
|
395
|
+
|
396
|
+
// FIXME: there is no valid solution for multiple "SelectElement" in one object.
|
397
|
+
|
398
|
+
for (SelectElement::ValueType::const_iterator it = sel->value.begin() ; it != sel->value.end() ; ++it) {
|
399
|
+
JSONSchemaVisitor v(pDefs);
|
400
|
+
VisitBy(*(*it), v);
|
401
|
+
oneOfMembers.push_back(v.getOwnership());
|
402
|
+
}
|
403
|
+
}
|
404
|
+
break;
|
405
|
+
|
406
|
+
default:
|
407
|
+
throw LogicError("Invalid member type of object in MSON definition");
|
408
|
+
}
|
409
|
+
}
|
410
|
+
|
411
|
+
if (!varProps.empty()) {
|
412
|
+
addVariableProps(varProps, o);
|
413
|
+
if (o->value.empty()) {
|
414
|
+
delete o;
|
415
|
+
}
|
416
|
+
}
|
417
|
+
else {
|
418
|
+
setSchemaType("object");
|
419
|
+
addMember("properties", o);
|
420
|
+
}
|
421
|
+
|
422
|
+
if (!reqVals.empty()) {
|
423
|
+
addMember("required", new ArrayElement(reqVals, IElement::rCompact));
|
424
|
+
}
|
425
|
+
|
426
|
+
if (!oneOfMembers.empty()) {
|
427
|
+
addMember("oneOf", new ArrayElement(oneOfMembers, IElement::rCompact));
|
428
|
+
}
|
429
|
+
|
430
|
+
if (fixed || fixedType) {
|
431
|
+
addMember("additionalProperties", IElement::Create(false));
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
435
|
+
void JSONSchemaVisitor::anyOf(std::map<std::string, std::vector<IElement*> >& types, std::vector<std::string>& typesOrder)
|
436
|
+
{
|
437
|
+
ArrayElement *a = new ArrayElement;
|
438
|
+
a->renderType(IElement::rCompact);
|
439
|
+
|
440
|
+
for (std::vector<std::string>::const_iterator i = typesOrder.begin();
|
441
|
+
i != typesOrder.end();
|
442
|
+
++i) {
|
443
|
+
|
444
|
+
const std::vector<IElement*>& items = types[*i];
|
445
|
+
|
446
|
+
IElement *elm = items.front();
|
447
|
+
JSONSchemaVisitor v(pDefs);
|
448
|
+
Visit(v, *elm);
|
449
|
+
|
450
|
+
if (TypeQueryVisitor::as<EnumElement>(elm)){
|
451
|
+
v.addMember("enum", elm->clone());
|
452
|
+
}
|
453
|
+
else if (!TypeQueryVisitor::as<ObjectElement>(elm)) {
|
454
|
+
ArrayElement::ValueType enmVals;
|
455
|
+
CloneMembers(&enmVals, &items);
|
456
|
+
|
457
|
+
if (!enmVals.empty()) {
|
458
|
+
ArrayElement *enm = new ArrayElement;
|
459
|
+
enm->set(enmVals);
|
460
|
+
v.addMember("enum", enm);
|
461
|
+
}
|
462
|
+
}
|
463
|
+
|
464
|
+
a->push_back(v.getOwnership());
|
465
|
+
}
|
466
|
+
addMember("anyOf", a);
|
467
|
+
}
|
468
|
+
|
469
|
+
void JSONSchemaVisitor::operator()(const ArrayElement& e) {
|
470
|
+
const ArrayElement::ValueType* val = GetValue<ArrayElement>(e);
|
471
|
+
|
472
|
+
if (!val || val->empty()) {
|
473
|
+
return;
|
474
|
+
}
|
475
|
+
|
476
|
+
JSONSchemaVisitor renderer(pDefs);
|
477
|
+
setSchemaType("array");
|
478
|
+
|
479
|
+
if (IsTypeAttribute(e, "fixed")) {
|
480
|
+
fixed = true;
|
481
|
+
}
|
482
|
+
|
483
|
+
if (IsTypeAttribute(e, "fixedType")) {
|
484
|
+
fixedType = true;
|
485
|
+
}
|
486
|
+
|
487
|
+
if (fixed || fixedType) {
|
488
|
+
ArrayElement::ValueType av;
|
489
|
+
bool allEmpty = allItemsEmpty(val);
|
490
|
+
|
491
|
+
for (ArrayElement::ValueType::const_iterator it = val->begin();
|
492
|
+
it != val->end();
|
493
|
+
++it) {
|
494
|
+
|
495
|
+
if (*it) {
|
496
|
+
// if all items are just type items then we
|
497
|
+
// want them in the schema, otherwise skip
|
498
|
+
// empty ones
|
499
|
+
if (allEmpty || !(*it)->empty()) {
|
500
|
+
JSONSchemaVisitor v(pDefs, fixed);
|
501
|
+
Visit(v, *(*it));
|
502
|
+
av.push_back(v.getOwnership());
|
503
|
+
}
|
504
|
+
}
|
505
|
+
}
|
506
|
+
|
507
|
+
if (!av.empty()) {
|
508
|
+
if (av.size() == 1) {
|
509
|
+
addMember("items",av[0]);
|
510
|
+
|
511
|
+
} else {
|
512
|
+
ArrayElement *a = new ArrayElement;
|
513
|
+
a->set(av);
|
514
|
+
addMember("items", a);
|
515
|
+
}
|
516
|
+
}
|
517
|
+
}
|
518
|
+
|
519
|
+
const ArrayElement *def = GetDefault(e);
|
520
|
+
|
521
|
+
if (def && !def->empty()) {
|
522
|
+
ArrayElement *d = static_cast<ArrayElement*>(def->clone());
|
523
|
+
d->renderType(IElement::rCompact);
|
524
|
+
SetRenderFlag(d->value, IElement::rCompact);
|
525
|
+
addMember("default", d);
|
526
|
+
}
|
527
|
+
}
|
528
|
+
|
529
|
+
void JSONSchemaVisitor::operator()(const EnumElement& e) {
|
530
|
+
const EnumElement::ValueType* val = GetValue<EnumElement>(e);
|
531
|
+
|
532
|
+
if (!val || val->empty()) {
|
533
|
+
return;
|
534
|
+
}
|
535
|
+
|
536
|
+
std::map<std::string, std::vector<IElement*> > types;
|
537
|
+
std::vector<std::string> typesOrder;
|
538
|
+
|
539
|
+
for (ArrayElement::ValueType::const_iterator it = val->begin();
|
540
|
+
it != val->end();
|
541
|
+
++it) {
|
542
|
+
|
543
|
+
if (*it) {
|
544
|
+
std::vector<IElement*>& items = types[(*it)->element()];
|
545
|
+
|
546
|
+
if (items.empty()) {
|
547
|
+
typesOrder.push_back((*it)->element());
|
548
|
+
}
|
549
|
+
|
550
|
+
items.push_back(*it);
|
551
|
+
}
|
552
|
+
}
|
553
|
+
|
554
|
+
if (types.size() > 1) {
|
555
|
+
anyOf(types, typesOrder);
|
556
|
+
}
|
557
|
+
else {
|
558
|
+
const EnumElement* def = GetDefault(e);
|
559
|
+
if (!e.empty() || (def && !def->empty())) {
|
560
|
+
ArrayElement *a = new ArrayElement;
|
561
|
+
a->renderType(IElement::rCompact);
|
562
|
+
CloneMembers(a, val);
|
563
|
+
setSchemaType(types.begin()->first);
|
564
|
+
addMember("enum", a);
|
565
|
+
}
|
566
|
+
}
|
567
|
+
|
568
|
+
const EnumElement *def = GetDefault(e);
|
569
|
+
|
570
|
+
if (def && !def->empty() && !def->value.empty()) {
|
571
|
+
IElement *d = def->value.front()->clone();
|
572
|
+
d->renderType(IElement::rCompact);
|
573
|
+
addMember("default", d);
|
574
|
+
}
|
575
|
+
}
|
576
|
+
|
577
|
+
void JSONSchemaVisitor::operator()(const NullElement& e)
|
578
|
+
{
|
579
|
+
addMember("type", new NullElement);
|
580
|
+
}
|
581
|
+
|
582
|
+
void JSONSchemaVisitor::operator()(const StringElement& e)
|
583
|
+
{
|
584
|
+
primitiveType(e);
|
585
|
+
}
|
586
|
+
|
587
|
+
void JSONSchemaVisitor::operator()(const NumberElement& e)
|
588
|
+
{
|
589
|
+
primitiveType(e);
|
590
|
+
}
|
591
|
+
|
592
|
+
void JSONSchemaVisitor::operator()(const BooleanElement& e)
|
593
|
+
{
|
594
|
+
primitiveType(e);
|
595
|
+
}
|
596
|
+
|
597
|
+
void JSONSchemaVisitor::operator()(const ExtendElement& e)
|
598
|
+
{
|
599
|
+
IElement* merged = e.merge();
|
600
|
+
if (!merged) {
|
601
|
+
return;
|
602
|
+
}
|
603
|
+
|
604
|
+
Visit(*this, *merged);
|
605
|
+
delete merged;
|
606
|
+
}
|
607
|
+
|
608
|
+
void JSONSchemaVisitor::operator()(const OptionElement& e)
|
609
|
+
{
|
610
|
+
ObjectElement* props = pObj;
|
611
|
+
RefractElements members;
|
612
|
+
RefractElements oneOfMembers;
|
613
|
+
IncludeMembers(e, members);
|
614
|
+
|
615
|
+
for (OptionElement::ValueType::const_iterator it = members.begin() ; it != members.end() ; ++it) {
|
616
|
+
if (SelectElement* sel = TypeQueryVisitor::as<SelectElement>(*it)) {
|
617
|
+
for (SelectElement::ValueType::const_iterator it = sel->value.begin() ; it != sel->value.end() ; ++it) {
|
618
|
+
JSONSchemaVisitor v(pDefs);
|
619
|
+
VisitBy(*(*it), v);
|
620
|
+
oneOfMembers.push_back(v.getOwnership());
|
621
|
+
}
|
622
|
+
}
|
623
|
+
else {
|
624
|
+
Visit(*this, *(*it));
|
625
|
+
}
|
626
|
+
}
|
627
|
+
|
628
|
+
pObj = new ObjectElement;
|
629
|
+
pObj->renderType(IElement::rCompact);
|
630
|
+
|
631
|
+
addMember("properties", props);
|
632
|
+
if (!oneOfMembers.empty()) {
|
633
|
+
addMember("oneOf", new ArrayElement(oneOfMembers, IElement::rCompact));
|
634
|
+
}
|
635
|
+
}
|
636
|
+
|
637
|
+
IElement* JSONSchemaVisitor::get()
|
638
|
+
{
|
639
|
+
return pObj;
|
640
|
+
}
|
641
|
+
|
642
|
+
IElement* JSONSchemaVisitor::getOwnership()
|
643
|
+
{
|
644
|
+
IElement* ret = pObj;
|
645
|
+
pObj = NULL;
|
646
|
+
return ret;
|
647
|
+
}
|
648
|
+
|
649
|
+
std::string JSONSchemaVisitor::getSchema(const IElement& e)
|
650
|
+
{
|
651
|
+
addMember("$schema",
|
652
|
+
new StringElement(
|
653
|
+
"http://json-schema.org/draft-04/schema#",
|
654
|
+
IElement::rCompact));
|
655
|
+
setSchemaType("object");
|
656
|
+
|
657
|
+
Visit(*this, e);
|
658
|
+
|
659
|
+
if (!pDefs->empty()) {
|
660
|
+
addMember("definitions", pDefs);
|
661
|
+
} else {
|
662
|
+
delete pDefs;
|
663
|
+
}
|
664
|
+
|
665
|
+
sos::SerializeJSON s;
|
666
|
+
std::stringstream ss;
|
667
|
+
// FIXME: remove SosSerializeCompactVisitor dependency
|
668
|
+
SosSerializeCompactVisitor sv(false);
|
669
|
+
VisitBy(*pObj, sv);
|
670
|
+
|
671
|
+
s.process(sv.value(), ss);
|
672
|
+
|
673
|
+
return ss.str();
|
674
|
+
}
|
675
|
+
}
|