{"action":"created","comment":{"url":"https://api.github.com/repos/apiaryio/drafter/pulls/comments/25867651","id":25867651,"diff_hunk":"@@ -0,0 +1,56 @@\n+#include \"cdrafter.h\"\n+\n+#include \"snowcrash.h\"\n+#include \"sosJSON.h\"\n+\n+#include \"SerializeAST.h\"\n+#include \"SerializeSourceAnnotations.h\"\n+\n+#include <string.h>\n+\n+namespace sc = snowcrash;\n+\n+static char* ToString(const std::stringstream& stream) \n+{\n+    size_t length = stream.str().length() + 1;\n+    char* str = (char*)malloc(length);\n+    memcpy(str, stream.str().c_str(), length);\n+    return str;\n+}\n+\n+SC_API int drafter_c_parse(const char* source, \n+                           sc_blueprint_parser_options options, \n+                           char** report, \n+                           char** ast)\n+{\n+\n+    std::stringstream inputStream;\n+\n+    if (report) {\n+        options |= snowcrash::ExportSourcemapOption;\n+    } \n+\n+    inputStream << source;\n+\n+    sc::ParseResult<sc::Blueprint> blueprint;\n+    sc::parse(inputStream.str(), options, blueprint);\n+\n+    sos::SerializeJSON serializer;\n+\n+    if (ast) {\n+        std::stringstream astStream;\n+        serializer.process(drafter::WrapBlueprint(blueprint.node), astStream);\n+        astStream << \"\\n\";\n+        *ast = ToString(astStream);\n+    }\n+\n+\n+    if (report) {\n+        std::stringstream reportStream;\n+        serializer.process(drafter::WrapSourceAnnotations(blueprint.report, blueprint.sourceMap), reportStream);","path":"src/cdrafter.cc","position":50,"original_position":50,"commit_id":"b178b4323456ec13be39cde177a0fba2ce79c761","original_commit_id":"b178b4323456ec13be39cde177a0fba2ce79c761","user":{"login":"pksunkara","id":174703,"avatar_url":"https://avatars.githubusercontent.com/u/174703?v=3","gravatar_id":"","url":"https://api.github.com/users/pksunkara","html_url":"https://github.com/pksunkara","followers_url":"https://api.github.com/users/pksunkara/followers","following_url":"https://api.github.com/users/pksunkara/following{/other_user}","gists_url":"https://api.github.com/users/pksunkara/gists{/gist_id}","starred_url":"https://api.github.com/users/pksunkara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pksunkara/subscriptions","organizations_url":"https://api.github.com/users/pksunkara/orgs","repos_url":"https://api.github.com/users/pksunkara/repos","events_url":"https://api.github.com/users/pksunkara/events{/privacy}","received_events_url":"https://api.github.com/users/pksunkara/received_events","type":"User","site_admin":false},"body":"Why does allocation memory for `report` also gives back the `sourceMap`? I don't understand this.","created_at":"2015-03-05T14:42:01Z","updated_at":"2015-03-05T14:42:01Z","html_url":"https://github.com/apiaryio/drafter/pull/5#discussion_r25867651","pull_request_url":"https://api.github.com/repos/apiaryio/drafter/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/apiaryio/drafter/pulls/comments/25867651"},"html":{"href":"https://github.com/apiaryio/drafter/pull/5#discussion_r25867651"},"pull_request":{"href":"https://api.github.com/repos/apiaryio/drafter/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/apiaryio/drafter/pulls/5","id":30553967,"html_url":"https://github.com/apiaryio/drafter/pull/5","diff_url":"https://github.com/apiaryio/drafter/pull/5.diff","patch_url":"https://github.com/apiaryio/drafter/pull/5.patch","issue_url":"https://api.github.com/repos/apiaryio/drafter/issues/5","number":5,"state":"open","locked":false,"title":"Klokane/simplify c interface","user":{"login":"klokane","id":489973,"avatar_url":"https://avatars.githubusercontent.com/u/489973?v=3","gravatar_id":"","url":"https://api.github.com/users/klokane","html_url":"https://github.com/klokane","followers_url":"https://api.github.com/users/klokane/followers","following_url":"https://api.github.com/users/klokane/following{/other_user}","gists_url":"https://api.github.com/users/klokane/gists{/gist_id}","starred_url":"https://api.github.com/users/klokane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klokane/subscriptions","organizations_url":"https://api.github.com/users/klokane/orgs","repos_url":"https://api.github.com/users/klokane/repos","events_url":"https://api.github.com/users/klokane/events{/privacy}","received_events_url":"https://api.github.com/users/klokane/received_events","type":"User","site_admin":false},"body":"Implemented  c-interface.\r\nSerialization of parse result ","created_at":"2015-03-05T12:48:14Z","updated_at":"2015-03-05T14:42:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"77260d535a6aeaa0dec42d25342aef9b26417880","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apiaryio/drafter/pulls/5/commits","review_comments_url":"https://api.github.com/repos/apiaryio/drafter/pulls/5/comments","review_comment_url":"https://api.github.com/repos/apiaryio/drafter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apiaryio/drafter/issues/5/comments","statuses_url":"https://api.github.com/repos/apiaryio/drafter/statuses/b178b4323456ec13be39cde177a0fba2ce79c761","head":{"label":"klokane:klokane/simplify-c-interface","ref":"klokane/simplify-c-interface","sha":"b178b4323456ec13be39cde177a0fba2ce79c761","user":{"login":"klokane","id":489973,"avatar_url":"https://avatars.githubusercontent.com/u/489973?v=3","gravatar_id":"","url":"https://api.github.com/users/klokane","html_url":"https://github.com/klokane","followers_url":"https://api.github.com/users/klokane/followers","following_url":"https://api.github.com/users/klokane/following{/other_user}","gists_url":"https://api.github.com/users/klokane/gists{/gist_id}","starred_url":"https://api.github.com/users/klokane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klokane/subscriptions","organizations_url":"https://api.github.com/users/klokane/orgs","repos_url":"https://api.github.com/users/klokane/repos","events_url":"https://api.github.com/users/klokane/events{/privacy}","received_events_url":"https://api.github.com/users/klokane/received_events","type":"User","site_admin":false},"repo":{"id":30585658,"name":"drafter","full_name":"klokane/drafter","owner":{"login":"klokane","id":489973,"avatar_url":"https://avatars.githubusercontent.com/u/489973?v=3","gravatar_id":"","url":"https://api.github.com/users/klokane","html_url":"https://github.com/klokane","followers_url":"https://api.github.com/users/klokane/followers","following_url":"https://api.github.com/users/klokane/following{/other_user}","gists_url":"https://api.github.com/users/klokane/gists{/gist_id}","starred_url":"https://api.github.com/users/klokane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klokane/subscriptions","organizations_url":"https://api.github.com/users/klokane/orgs","repos_url":"https://api.github.com/users/klokane/repos","events_url":"https://api.github.com/users/klokane/events{/privacy}","received_events_url":"https://api.github.com/users/klokane/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/klokane/drafter","description":"Snow Crash parser harness","fork":true,"url":"https://api.github.com/repos/klokane/drafter","forks_url":"https://api.github.com/repos/klokane/drafter/forks","keys_url":"https://api.github.com/repos/klokane/drafter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/klokane/drafter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/klokane/drafter/teams","hooks_url":"https://api.github.com/repos/klokane/drafter/hooks","issue_events_url":"https://api.github.com/repos/klokane/drafter/issues/events{/number}","events_url":"https://api.github.com/repos/klokane/drafter/events","assignees_url":"https://api.github.com/repos/klokane/drafter/assignees{/user}","branches_url":"https://api.github.com/repos/klokane/drafter/branches{/branch}","tags_url":"https://api.github.com/repos/klokane/drafter/tags","blobs_url":"https://api.github.com/repos/klokane/drafter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/klokane/drafter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/klokane/drafter/git/refs{/sha}","trees_url":"https://api.github.com/repos/klokane/drafter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/klokane/drafter/statuses/{sha}","languages_url":"https://api.github.com/repos/klokane/drafter/languages","stargazers_url":"https://api.github.com/repos/klokane/drafter/stargazers","contributors_url":"https://api.github.com/repos/klokane/drafter/contributors","subscribers_url":"https://api.github.com/repos/klokane/drafter/subscribers","subscription_url":"https://api.github.com/repos/klokane/drafter/subscription","commits_url":"https://api.github.com/repos/klokane/drafter/commits{/sha}","git_commits_url":"https://api.github.com/repos/klokane/drafter/git/commits{/sha}","comments_url":"https://api.github.com/repos/klokane/drafter/comments{/number}","issue_comment_url":"https://api.github.com/repos/klokane/drafter/issues/comments{/number}","contents_url":"https://api.github.com/repos/klokane/drafter/contents/{+path}","compare_url":"https://api.github.com/repos/klokane/drafter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/klokane/drafter/merges","archive_url":"https://api.github.com/repos/klokane/drafter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/klokane/drafter/downloads","issues_url":"https://api.github.com/repos/klokane/drafter/issues{/number}","pulls_url":"https://api.github.com/repos/klokane/drafter/pulls{/number}","milestones_url":"https://api.github.com/repos/klokane/drafter/milestones{/number}","notifications_url":"https://api.github.com/repos/klokane/drafter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/klokane/drafter/labels{/name}","releases_url":"https://api.github.com/repos/klokane/drafter/releases{/id}","created_at":"2015-02-10T09:52:48Z","updated_at":"2015-02-10T06:59:31Z","pushed_at":"2015-03-05T12:46:06Z","git_url":"git://github.com/klokane/drafter.git","ssh_url":"git@github.com:klokane/drafter.git","clone_url":"https://github.com/klokane/drafter.git","svn_url":"https://github.com/klokane/drafter","homepage":"","size":212,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apiaryio:master","ref":"master","sha":"d891d73093b73987a8949018783a994ba8fc8bc6","user":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?v=3","gravatar_id":"","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"repo":{"id":30541396,"name":"drafter","full_name":"apiaryio/drafter","owner":{"login":"apiaryio","id":765943,"avatar_url":"https://avatars.githubusercontent.com/u/765943?v=3","gravatar_id":"","url":"https://api.github.com/users/apiaryio","html_url":"https://github.com/apiaryio","followers_url":"https://api.github.com/users/apiaryio/followers","following_url":"https://api.github.com/users/apiaryio/following{/other_user}","gists_url":"https://api.github.com/users/apiaryio/gists{/gist_id}","starred_url":"https://api.github.com/users/apiaryio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiaryio/subscriptions","organizations_url":"https://api.github.com/users/apiaryio/orgs","repos_url":"https://api.github.com/users/apiaryio/repos","events_url":"https://api.github.com/users/apiaryio/events{/privacy}","received_events_url":"https://api.github.com/users/apiaryio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apiaryio/drafter","description":"Snow Crash parser harness","fork":false,"url":"https://api.github.com/repos/apiaryio/drafter","forks_url":"https://api.github.com/repos/apiaryio/drafter/forks","keys_url":"https://api.github.com/repos/apiaryio/drafter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apiaryio/drafter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apiaryio/drafter/teams","hooks_url":"https://api.github.com/repos/apiaryio/drafter/hooks","issue_events_url":"https://api.github.com/repos/apiaryio/drafter/issues/events{/number}","events_url":"https://api.github.com/repos/apiaryio/drafter/events","assignees_url":"https://api.github.com/repos/apiaryio/drafter/assignees{/user}","branches_url":"https://api.github.com/repos/apiaryio/drafter/branches{/branch}","tags_url":"https://api.github.com/repos/apiaryio/drafter/tags","blobs_url":"https://api.github.com/repos/apiaryio/drafter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apiaryio/drafter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apiaryio/drafter/git/refs{/sha}","trees_url":"https://api.github.com/repos/apiaryio/drafter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apiaryio/drafter/statuses/{sha}","languages_url":"https://api.github.com/repos/apiaryio/drafter/languages","stargazers_url":"https://api.github.com/repos/apiaryio/drafter/stargazers","contributors_url":"https://api.github.com/repos/apiaryio/drafter/contributors","subscribers_url":"https://api.github.com/repos/apiaryio/drafter/subscribers","subscription_url":"https://api.github.com/repos/apiaryio/drafter/subscription","commits_url":"https://api.github.com/repos/apiaryio/drafter/commits{/sha}","git_commits_url":"https://api.github.com/repos/apiaryio/drafter/git/commits{/sha}","comments_url":"https://api.github.com/repos/apiaryio/drafter/comments{/number}","issue_comment_url":"https://api.github.com/repos/apiaryio/drafter/issues/comments{/number}","contents_url":"https://api.github.com/repos/apiaryio/drafter/contents/{+path}","compare_url":"https://api.github.com/repos/apiaryio/drafter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apiaryio/drafter/merges","archive_url":"https://api.github.com/repos/apiaryio/drafter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apiaryio/drafter/downloads","issues_url":"https://api.github.com/repos/apiaryio/drafter/issues{/number}","pulls_url":"https://api.github.com/repos/apiaryio/drafter/pulls{/number}","milestones_url":"https://api.github.com/repos/apiaryio/drafter/milestones{/number}","notifications_url":"https://api.github.com/repos/apiaryio/drafter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apiaryio/drafter/labels{/name}","releases_url":"https://api.github.com/repos/apiaryio/drafter/releases{/id}","created_at":"2015-02-09T15:05:57Z","updated_at":"2015-02-27T15:38:43Z","pushed_at":"2015-02-27T15:38:44Z","git_url":"git://github.com/apiaryio/drafter.git","ssh_url":"git@github.com:apiaryio/drafter.git","clone_url":"https://github.com/apiaryio/drafter.git","svn_url":"https://github.com/apiaryio/drafter","homepage":"","size":347,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apiaryio/drafter/pulls/5"},"html":{"href":"https://github.com/apiaryio/drafter/pull/5"},"issue":{"href":"https://api.github.com/repos/apiaryio/drafter/issues/5"},"comments":{"href":"https://api.github.com/repos/apiaryio/drafter/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/apiaryio/drafter/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/apiaryio/drafter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apiaryio/drafter/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/apiaryio/drafter/statuses/b178b4323456ec13be39cde177a0fba2ce79c761"}}}}