{"action":"created","comment":{"url":"https://api.github.com/repos/ni/VireoSDK/pulls/comments/203401041","pull_request_review_id":138281862,"id":203401041,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMzQwMTA0MQ==","diff_hunk":"@@ -1064,14 +1064,45 @@ VIREO_FUNCTION_SIGNATUREV(WaitForEventsAndDispatch, WaitForEventsParamBlock)\n                 memcpy(esEventDataNode, &eventData, commonDataSize);\n                 *EventIndexFieldPtr(esEventDataNode) = eventIndex;\n                 if (eventData.eventDataType) {\n-                    Int32 alignment = eventData.eventDataType->AQAlignment();\n-                    commonDataSize = TypeManager::AlignAQOffset(commonDataSize, alignment);  // round up to alignment boundary\n-                    if (eventData.eventDataType->TopAQSize() == dataNodeSize - commonDataSize) {\n-                        // TODO(spathiwa) Should we also verify type of event data node matches event at run-time?\n-                        // When we support multiple events with a shared event case, this needs to be smarter\n-                        // and copy only common data, using a custom emit proc (which could verify types) and\n-                        // generate custom snippets for each event data node cluster.\n-                        eventData.eventDataType->CopyData(eventData.pEventData, (AQBlock1*)esEventDataNode + commonDataSize);\n+                    const UInt32 numCommonElements = EventCommonData::GetNumberOfCommonElements();\n+                    const UInt32 numDestElements = esEventDataNodeType->SubElementCount();\n+                    const UInt32 numSourceElements = eventData.eventDataType->SubElementCount();\n+                    UInt32 destElementIndex = numCommonElements, sourceElementIndex = 0;\n+                    if (numDestElements == numCommonElements + 1\n+                        && esEventDataNodeType->GetSubElement(destElementIndex)->IsA(eventData.eventDataType)) {\n+                        // Special case, all non-commmon data is encapsulated in a single cluster, for example, when\n+                        // User Event use the same cluster type which defined the user event to be to fire it and\n+                        // as a data element after the common portion (without inlining its fields).\n+                        TypeRef destElemType = esEventDataNodeType->GetSubElement(destElementIndex);\n+                        eventData.eventDataType->CopyData((AQBlock1*)eventData.pEventData,\n+                                                          (AQBlock1*)esEventDataNode + destElemType->ElementOffset());\n+                    } else {\n+                        // Loop through all elements in the destination event data cluster, and look for the matching\n+                        // source element in the fired event data.  We need to copy one element at a time because the\n+                        // alignment of the source and dest might not be the same because of the precense of leading\n+                        // common fields, and also to handle shared event cases which only expose event data common\n+                        // to all sources.\n+                        // Note, although this looks like an O(N^2) nested loop, it's actually O(N+M), the sum of\n+                        // the number of fields in the source (fired event data) and dest (cluster).\n+                        while (destElementIndex < numDestElements) {\n+                            // (TODO(spathiwa) We could use a custom emit proc to verify types and generate\n+                            // custom snippets for each event data node cluster so it doesn't have to check at run-time.)\n+                            TypeRef destElemType = esEventDataNodeType->GetSubElement(destElementIndex);\n+                            IntIndex destOffset = destElemType->ElementOffset();\n+                            while (sourceElementIndex < numSourceElements) {","path":"source/core/Events.cpp","position":37,"original_position":37,"commit_id":"1d72f1992126cefe116d8257c479f99233ea6273","original_commit_id":"1d72f1992126cefe116d8257c479f99233ea6273","user":{"login":"spathiwa","id":860388,"node_id":"MDQ6VXNlcjg2MDM4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/860388?v=4","gravatar_id":"","url":"https://api.github.com/users/spathiwa","html_url":"https://github.com/spathiwa","followers_url":"https://api.github.com/users/spathiwa/followers","following_url":"https://api.github.com/users/spathiwa/following{/other_user}","gists_url":"https://api.github.com/users/spathiwa/gists{/gist_id}","starred_url":"https://api.github.com/users/spathiwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spathiwa/subscriptions","organizations_url":"https://api.github.com/users/spathiwa/orgs","repos_url":"https://api.github.com/users/spathiwa/repos","events_url":"https://api.github.com/users/spathiwa/events{/privacy}","received_events_url":"https://api.github.com/users/spathiwa/received_events","type":"User","site_admin":false},"body":"Yes, this is required. NCG does the same thing.  ","created_at":"2018-07-18T14:29:32Z","updated_at":"2018-07-18T14:29:32Z","html_url":"https://github.com/ni/VireoSDK/pull/482#discussion_r203401041","pull_request_url":"https://api.github.com/repos/ni/VireoSDK/pulls/482","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ni/VireoSDK/pulls/comments/203401041"},"html":{"href":"https://github.com/ni/VireoSDK/pull/482#discussion_r203401041"},"pull_request":{"href":"https://api.github.com/repos/ni/VireoSDK/pulls/482"}},"in_reply_to_id":203388830},"pull_request":{"url":"https://api.github.com/repos/ni/VireoSDK/pulls/482","id":202138668,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyMTM4NjY4","html_url":"https://github.com/ni/VireoSDK/pull/482","diff_url":"https://github.com/ni/VireoSDK/pull/482.diff","patch_url":"https://github.com/ni/VireoSDK/pull/482.patch","issue_url":"https://api.github.com/repos/ni/VireoSDK/issues/482","number":482,"state":"open","locked":false,"title":"Fix alignment issues in copying event data.","user":{"login":"spathiwa","id":860388,"node_id":"MDQ6VXNlcjg2MDM4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/860388?v=4","gravatar_id":"","url":"https://api.github.com/users/spathiwa","html_url":"https://github.com/spathiwa","followers_url":"https://api.github.com/users/spathiwa/followers","following_url":"https://api.github.com/users/spathiwa/following{/other_user}","gists_url":"https://api.github.com/users/spathiwa/gists{/gist_id}","starred_url":"https://api.github.com/users/spathiwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spathiwa/subscriptions","organizations_url":"https://api.github.com/users/spathiwa/orgs","repos_url":"https://api.github.com/users/spathiwa/repos","events_url":"https://api.github.com/users/spathiwa/events{/privacy}","received_events_url":"https://api.github.com/users/spathiwa/received_events","type":"User","site_admin":false},"body":"If the event data in a user event is, say, a cluster of an Int32 and\r\nDouble, then platform alignment causes there to be 4 bytes of padding\r\nbetween the 2 fields so the Double can be 8-byte aligned.\r\nHowever, in the event data node cluster on the diagram (and associated\r\nVIA cluster), there are common event data fields (source, type, index,\r\ntimestamp, ref) that aren't explicitly part of the user-supplied user\r\nevent data.. When the User Event data is appended to this common\r\ndata, the resulting cluster does NOT need padding between the last Int32\r\nand the Double, because the Int32 was already 20 bytes offset into the\r\ncluster, so the next field, at 24 bytes offset, is already 8\r\nbyte-aligned.  This discrepancy is the source of this bug; the code\r\nassumed you only had to worry about alignment at the beginning of the\r\ncopy, and then the clusters could be copied in one operation.\r\n\r\nSolution is to copy the clusters one field at a time, in which case we\r\ndon't even need to explicitly handle alignment, because cluster types\r\nknow their elements' individual offsets. This is less performant than\r\ncopying the whole cluster, but we needed to do this eventually anyway\r\nto handle shared event cases between events with some but not all\r\ndata elements in common.","created_at":"2018-07-18T04:59:48Z","updated_at":"2018-07-18T14:29:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"21fd3d932ba8348d6a16bbe9752d0b9955613454","assignee":null,"assignees":[],"requested_reviewers":[{"login":"cglzaguilar","id":8452083,"node_id":"MDQ6VXNlcjg0NTIwODM=","avatar_url":"https://avatars3.githubusercontent.com/u/8452083?v=4","gravatar_id":"","url":"https://api.github.com/users/cglzaguilar","html_url":"https://github.com/cglzaguilar","followers_url":"https://api.github.com/users/cglzaguilar/followers","following_url":"https://api.github.com/users/cglzaguilar/following{/other_user}","gists_url":"https://api.github.com/users/cglzaguilar/gists{/gist_id}","starred_url":"https://api.github.com/users/cglzaguilar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cglzaguilar/subscriptions","organizations_url":"https://api.github.com/users/cglzaguilar/orgs","repos_url":"https://api.github.com/users/cglzaguilar/repos","events_url":"https://api.github.com/users/cglzaguilar/events{/privacy}","received_events_url":"https://api.github.com/users/cglzaguilar/received_events","type":"User","site_admin":false},{"login":"sanmut","id":23344166,"node_id":"MDQ6VXNlcjIzMzQ0MTY2","avatar_url":"https://avatars2.githubusercontent.com/u/23344166?v=4","gravatar_id":"","url":"https://api.github.com/users/sanmut","html_url":"https://github.com/sanmut","followers_url":"https://api.github.com/users/sanmut/followers","following_url":"https://api.github.com/users/sanmut/following{/other_user}","gists_url":"https://api.github.com/users/sanmut/gists{/gist_id}","starred_url":"https://api.github.com/users/sanmut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanmut/subscriptions","organizations_url":"https://api.github.com/users/sanmut/orgs","repos_url":"https://api.github.com/users/sanmut/repos","events_url":"https://api.github.com/users/sanmut/events{/privacy}","received_events_url":"https://api.github.com/users/sanmut/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ni/VireoSDK/pulls/482/commits","review_comments_url":"https://api.github.com/repos/ni/VireoSDK/pulls/482/comments","review_comment_url":"https://api.github.com/repos/ni/VireoSDK/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ni/VireoSDK/issues/482/comments","statuses_url":"https://api.github.com/repos/ni/VireoSDK/statuses/1d72f1992126cefe116d8257c479f99233ea6273","head":{"label":"spathiwa:UserEventAlignmentBug1","ref":"UserEventAlignmentBug1","sha":"1d72f1992126cefe116d8257c479f99233ea6273","user":{"login":"spathiwa","id":860388,"node_id":"MDQ6VXNlcjg2MDM4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/860388?v=4","gravatar_id":"","url":"https://api.github.com/users/spathiwa","html_url":"https://github.com/spathiwa","followers_url":"https://api.github.com/users/spathiwa/followers","following_url":"https://api.github.com/users/spathiwa/following{/other_user}","gists_url":"https://api.github.com/users/spathiwa/gists{/gist_id}","starred_url":"https://api.github.com/users/spathiwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spathiwa/subscriptions","organizations_url":"https://api.github.com/users/spathiwa/orgs","repos_url":"https://api.github.com/users/spathiwa/repos","events_url":"https://api.github.com/users/spathiwa/events{/privacy}","received_events_url":"https://api.github.com/users/spathiwa/received_events","type":"User","site_admin":false},"repo":{"id":58278036,"node_id":"MDEwOlJlcG9zaXRvcnk1ODI3ODAzNg==","name":"VireoSDK","full_name":"spathiwa/VireoSDK","owner":{"login":"spathiwa","id":860388,"node_id":"MDQ6VXNlcjg2MDM4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/860388?v=4","gravatar_id":"","url":"https://api.github.com/users/spathiwa","html_url":"https://github.com/spathiwa","followers_url":"https://api.github.com/users/spathiwa/followers","following_url":"https://api.github.com/users/spathiwa/following{/other_user}","gists_url":"https://api.github.com/users/spathiwa/gists{/gist_id}","starred_url":"https://api.github.com/users/spathiwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spathiwa/subscriptions","organizations_url":"https://api.github.com/users/spathiwa/orgs","repos_url":"https://api.github.com/users/spathiwa/repos","events_url":"https://api.github.com/users/spathiwa/events{/privacy}","received_events_url":"https://api.github.com/users/spathiwa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/spathiwa/VireoSDK","description":"Compact runtime for a subset of LabVIEW","fork":true,"url":"https://api.github.com/repos/spathiwa/VireoSDK","forks_url":"https://api.github.com/repos/spathiwa/VireoSDK/forks","keys_url":"https://api.github.com/repos/spathiwa/VireoSDK/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spathiwa/VireoSDK/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spathiwa/VireoSDK/teams","hooks_url":"https://api.github.com/repos/spathiwa/VireoSDK/hooks","issue_events_url":"https://api.github.com/repos/spathiwa/VireoSDK/issues/events{/number}","events_url":"https://api.github.com/repos/spathiwa/VireoSDK/events","assignees_url":"https://api.github.com/repos/spathiwa/VireoSDK/assignees{/user}","branches_url":"https://api.github.com/repos/spathiwa/VireoSDK/branches{/branch}","tags_url":"https://api.github.com/repos/spathiwa/VireoSDK/tags","blobs_url":"https://api.github.com/repos/spathiwa/VireoSDK/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spathiwa/VireoSDK/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spathiwa/VireoSDK/git/refs{/sha}","trees_url":"https://api.github.com/repos/spathiwa/VireoSDK/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spathiwa/VireoSDK/statuses/{sha}","languages_url":"https://api.github.com/repos/spathiwa/VireoSDK/languages","stargazers_url":"https://api.github.com/repos/spathiwa/VireoSDK/stargazers","contributors_url":"https://api.github.com/repos/spathiwa/VireoSDK/contributors","subscribers_url":"https://api.github.com/repos/spathiwa/VireoSDK/subscribers","subscription_url":"https://api.github.com/repos/spathiwa/VireoSDK/subscription","commits_url":"https://api.github.com/repos/spathiwa/VireoSDK/commits{/sha}","git_commits_url":"https://api.github.com/repos/spathiwa/VireoSDK/git/commits{/sha}","comments_url":"https://api.github.com/repos/spathiwa/VireoSDK/comments{/number}","issue_comment_url":"https://api.github.com/repos/spathiwa/VireoSDK/issues/comments{/number}","contents_url":"https://api.github.com/repos/spathiwa/VireoSDK/contents/{+path}","compare_url":"https://api.github.com/repos/spathiwa/VireoSDK/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spathiwa/VireoSDK/merges","archive_url":"https://api.github.com/repos/spathiwa/VireoSDK/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spathiwa/VireoSDK/downloads","issues_url":"https://api.github.com/repos/spathiwa/VireoSDK/issues{/number}","pulls_url":"https://api.github.com/repos/spathiwa/VireoSDK/pulls{/number}","milestones_url":"https://api.github.com/repos/spathiwa/VireoSDK/milestones{/number}","notifications_url":"https://api.github.com/repos/spathiwa/VireoSDK/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spathiwa/VireoSDK/labels{/name}","releases_url":"https://api.github.com/repos/spathiwa/VireoSDK/releases{/id}","deployments_url":"https://api.github.com/repos/spathiwa/VireoSDK/deployments","created_at":"2016-05-07T17:58:45Z","updated_at":"2018-07-17T21:23:50Z","pushed_at":"2018-07-18T04:49:09Z","git_url":"git://github.com/spathiwa/VireoSDK.git","ssh_url":"git@github.com:spathiwa/VireoSDK.git","clone_url":"https://github.com/spathiwa/VireoSDK.git","svn_url":"https://github.com/spathiwa/VireoSDK","homepage":"http://ni.github.io/VireoSDK/","size":18229,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ni:master","ref":"master","sha":"0d3a08eb84bd0dd412c6cd247b91d6cb70990e17","user":{"login":"ni","id":5598284,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU1OTgyODQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5598284?v=4","gravatar_id":"","url":"https://api.github.com/users/ni","html_url":"https://github.com/ni","followers_url":"https://api.github.com/users/ni/followers","following_url":"https://api.github.com/users/ni/following{/other_user}","gists_url":"https://api.github.com/users/ni/gists{/gist_id}","starred_url":"https://api.github.com/users/ni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ni/subscriptions","organizations_url":"https://api.github.com/users/ni/orgs","repos_url":"https://api.github.com/users/ni/repos","events_url":"https://api.github.com/users/ni/events{/privacy}","received_events_url":"https://api.github.com/users/ni/received_events","type":"Organization","site_admin":false},"repo":{"id":18154590,"node_id":"MDEwOlJlcG9zaXRvcnkxODE1NDU5MA==","name":"VireoSDK","full_name":"ni/VireoSDK","owner":{"login":"ni","id":5598284,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU1OTgyODQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5598284?v=4","gravatar_id":"","url":"https://api.github.com/users/ni","html_url":"https://github.com/ni","followers_url":"https://api.github.com/users/ni/followers","following_url":"https://api.github.com/users/ni/following{/other_user}","gists_url":"https://api.github.com/users/ni/gists{/gist_id}","starred_url":"https://api.github.com/users/ni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ni/subscriptions","organizations_url":"https://api.github.com/users/ni/orgs","repos_url":"https://api.github.com/users/ni/repos","events_url":"https://api.github.com/users/ni/events{/privacy}","received_events_url":"https://api.github.com/users/ni/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ni/VireoSDK","description":"Compact runtime for a subset of LabVIEW","fork":false,"url":"https://api.github.com/repos/ni/VireoSDK","forks_url":"https://api.github.com/repos/ni/VireoSDK/forks","keys_url":"https://api.github.com/repos/ni/VireoSDK/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ni/VireoSDK/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ni/VireoSDK/teams","hooks_url":"https://api.github.com/repos/ni/VireoSDK/hooks","issue_events_url":"https://api.github.com/repos/ni/VireoSDK/issues/events{/number}","events_url":"https://api.github.com/repos/ni/VireoSDK/events","assignees_url":"https://api.github.com/repos/ni/VireoSDK/assignees{/user}","branches_url":"https://api.github.com/repos/ni/VireoSDK/branches{/branch}","tags_url":"https://api.github.com/repos/ni/VireoSDK/tags","blobs_url":"https://api.github.com/repos/ni/VireoSDK/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ni/VireoSDK/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ni/VireoSDK/git/refs{/sha}","trees_url":"https://api.github.com/repos/ni/VireoSDK/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ni/VireoSDK/statuses/{sha}","languages_url":"https://api.github.com/repos/ni/VireoSDK/languages","stargazers_url":"https://api.github.com/repos/ni/VireoSDK/stargazers","contributors_url":"https://api.github.com/repos/ni/VireoSDK/contributors","subscribers_url":"https://api.github.com/repos/ni/VireoSDK/subscribers","subscription_url":"https://api.github.com/repos/ni/VireoSDK/subscription","commits_url":"https://api.github.com/repos/ni/VireoSDK/commits{/sha}","git_commits_url":"https://api.github.com/repos/ni/VireoSDK/git/commits{/sha}","comments_url":"https://api.github.com/repos/ni/VireoSDK/comments{/number}","issue_comment_url":"https://api.github.com/repos/ni/VireoSDK/issues/comments{/number}","contents_url":"https://api.github.com/repos/ni/VireoSDK/contents/{+path}","compare_url":"https://api.github.com/repos/ni/VireoSDK/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ni/VireoSDK/merges","archive_url":"https://api.github.com/repos/ni/VireoSDK/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ni/VireoSDK/downloads","issues_url":"https://api.github.com/repos/ni/VireoSDK/issues{/number}","pulls_url":"https://api.github.com/repos/ni/VireoSDK/pulls{/number}","milestones_url":"https://api.github.com/repos/ni/VireoSDK/milestones{/number}","notifications_url":"https://api.github.com/repos/ni/VireoSDK/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ni/VireoSDK/labels{/name}","releases_url":"https://api.github.com/repos/ni/VireoSDK/releases{/id}","deployments_url":"https://api.github.com/repos/ni/VireoSDK/deployments","created_at":"2014-03-26T21:30:22Z","updated_at":"2018-07-18T13:26:05Z","pushed_at":"2018-07-18T14:01:53Z","git_url":"git://github.com/ni/VireoSDK.git","ssh_url":"git@github.com:ni/VireoSDK.git","clone_url":"https://github.com/ni/VireoSDK.git","svn_url":"https://github.com/ni/VireoSDK","homepage":"http://ni.github.io/VireoSDK/","size":27627,"stargazers_count":31,"watchers_count":31,"language":"C++","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":20,"mirror_url":null,"archived":false,"open_issues_count":46,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":20,"open_issues":46,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ni/VireoSDK/pulls/482"},"html":{"href":"https://github.com/ni/VireoSDK/pull/482"},"issue":{"href":"https://api.github.com/repos/ni/VireoSDK/issues/482"},"comments":{"href":"https://api.github.com/repos/ni/VireoSDK/issues/482/comments"},"review_comments":{"href":"https://api.github.com/repos/ni/VireoSDK/pulls/482/comments"},"review_comment":{"href":"https://api.github.com/repos/ni/VireoSDK/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ni/VireoSDK/pulls/482/commits"},"statuses":{"href":"https://api.github.com/repos/ni/VireoSDK/statuses/1d72f1992126cefe116d8257c479f99233ea6273"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"spathiwa"}}