{"id":141,"date":"2011-03-02T15:45:17","date_gmt":"2011-03-02T23:45:17","guid":{"rendered":"http:\/\/blog.mozilla.org\/sfink\/?p=141"},"modified":"2021-06-13T14:08:58","modified_gmt":"2021-06-13T21:08:58","slug":"updating-uuids","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/sfink\/2011\/03\/02\/updating-uuids\/","title":{"rendered":"Updating UUIDs (the wrong way)"},"content":{"rendered":"<p>When you change an IDL interface, you have to update its uuid. Simple enough, just grab a new uuid and stick it in the .idl file. Easy enough, right?<\/p>\n<p>I&#8217;ve been working on JSD (the JavaScript debugger interface) recently, and its IDL file contains 18 different interfaces. So say I add a method to jsdIScript. What interfaces do I need to update? From empirical observations (as in, when I forget to do one I get yelled at by a reviewer), you have to update the uuid on the interface containing any added methods, any interfaces that use that interface within their definitions, and any interface that&#8230; inherits? extends? that interface. Recursively.<\/p>\n<p><strong>Update: <\/strong>No you don&#8217;t, says #developers, though currently the conversation is not finished and it seems like it may come down to something of a judgement call (something like &#8220;if you modify the vtable, update the uuid. If you change an interface used in a method in such a way that it might break a user, update the uuid.&#8221;) I&#8217;ve updated <a title=\"UUID auto-updater script\" href=\"http:\/\/people.mozilla.com\/~sfink\/uploads\/update-uuids\">my script<\/a> to use the more common rule (inheritance only), though if you want the stricter behavior you can get it with &#8211;mode=params.<\/p>\n<p>Leaving the rest of this post here for now:<\/p>\n<hr \/>\n<p>Solution 1: Manually go through and trace the dependencies, updating uuids as you go.<\/p>\n<p>Bleckth. Maybe someone else can manage to do that properly, but I&#8217;m an airhead, and I&#8217;d never get that exactly right.<\/p>\n<p>Solution 2: Nuke &#8217;em all and let God sort &#8217;em out. (As in, update every single uuid in the file.)<\/p>\n<p>Easy, but inelegant and I sometimes wonder if knowing whether an interface changed might actually <em>matter<\/em> to someone. Besides, this could result in me getting yelled at by a reviewer, and that&#8217;s what I depend on for figuring out the rules (see &#8220;empirical observations&#8221;, above.)<\/p>\n<p>Solution 3: automate solution 1.<\/p>\n<p>&#8230;so <a href=\"http:\/\/people.mozilla.com\/~sfink\/uploads\/update-uuids\">I did<\/a>.<\/p>\n<p>Give it a .idl file to chew on and one or more interfaces that you <em>know<\/em> you&#8217;ve changed, and it&#8217;ll chase through the dependencies for you. Assuming I got the rules right. It spits out a new file with brand-new uuids on all affected interfaces, and even spews to stderr the set of interfaces it&#8217;s updating and why:<\/p>\n<pre>% update-uuids jsdIDebuggerService.idl jsdIContext &gt;\/dev\/null\r\nuuids to update:\r\n jsdIContext because it was given on command line\r\n   3e5c934d-6863-4d81-96f5-76a3b962fc2b -&gt; 24ad10b2-8b4f-49f6-9236-f0ecaed0e19a\r\n jsdIStackFrame because its body contains jsdIContext\r\n   7c95422c-7579-4a6f-8ef7-e5b391552ee5 -&gt; 4c8c5902-77e8-4a9d-99f8-0ae6f0c58eec\r\n jsdIContextEnumerator because its body contains jsdIContext\r\n   57d18286-550c-4ca9-ac33-56f12ebba91e -&gt; d102ff63-59ea-4ed7-86d5-490c9e9b6b5a\r\n jsdICallHook because its body contains jsdIStackFrame\r\n   3eff1314-7ae3-4cf8-833b-c33c24a55633 -&gt; 150610f5-89cd-4f76-b960-06447471eb00\r\n jsdIExecutionHook because its body contains jsdIStackFrame\r\n   3a722496-9d78-4f0a-a797-293d9e8cb8d2 -&gt; cd3bfe98-c8a3-4c98-91d1-c7e2e79c396c\r\n jsdIDebuggerService because its body contains jsdIContextEnumerator\r\n   aa232c7f-855f-4488-a92c-6f89adc668cc -&gt; 75ab47da-2400-4efe-bb5e-745dceba4e06<\/pre>\n<p>(Sorry, no examples of inheritance-triggered changes there.)<\/p>\n<p>It&#8217;s a quickie parse-with-regexes Perl hack.<\/p>\n<p>One major flaw &#8212; it only considers a single .idl file. If some other .idl file depends on an interface modified within your file, then this won&#8217;t tell you it needs to be updated. I&#8217;m pretty sure that no other IDLs depend on the JSD IDL, so I don&#8217;t care yet. If this would be useful to you and that&#8217;s a necessary feature, let me know and I&#8217;ll throw it in. It&#8217;s easy enough to implement as long as you provide the list of IDL files to consider.<\/p>\n<p>The other major flaw is that this doesn&#8217;t update the uuids in header files, once again because JSD didn&#8217;t need it. That would be some more work, and I don&#8217;t even know if I have the rules right so I&#8217;m not going to bother unless someone asks me to and tells me this is the right thing in the first place.<\/p>\n<p>If nobody comments here within a week or so telling me I&#8217;m completely wrong about how this stuff works, I&#8217;ll add a link to this script on <a href=\"https:\/\/developer.mozilla.org\/en\/Generating_GUIDs\">MDC<\/a>. Maybe. If I remember. (And it turns out, someone did tell me I&#8217;m completely wrong. Yay!)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you change an IDL interface, you have to update its uuid. Simple enough, just grab a new uuid and stick it in the .idl file. Easy enough, right? I&#8217;ve been working on JSD (the JavaScript debugger interface) recently, and its IDL file contains 18 different interfaces. So say I add a method to jsdIScript. [&hellip;]<\/p>\n","protected":false},"author":206,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4143,666,4144],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/posts\/141"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/users\/206"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/sfink\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}