<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On 2007-09-12, at 18:34, Chris Lattner wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">On Sep 11, 2007, at 10:01 PM, Gordon Henriksen wrote:</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div> <blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">I've attached the header, where I've mapped a portion of Module and most of Type and its subclasses. This is working, and I've built ocaml bindings on top of it.[1]</span></div></blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Oooh, look at the long doubles ;-)</div></blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; ">Oh, <i>that's</i> what this comment means:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; text-indent: -48px; "><font style="font: 10.0px Andale Mono"><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 12px;">ÊÊ ÊPackedStructTyID,</span></font></font><font color="#236e25" style="font: 10.0px Andale Mono; color: #236e25"><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 12px;">///< 10: Packed Structure. </span></font><span class="Apple-style-span" style="text-decoration: underline;"><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 12px;">This is for bitcode only</span></font></span></font></div> <div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; ">Maybe we can hide that better? ocaml mappings really (really really) like sequential enums with no dead values.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; ">Oh well. I'll remap the values.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><blockquote type="cite"> <blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">My naming conventions are similar to the Carbon interfaces in OS X. (Should I prefer a Unixy flavor instead?) Naming prefix is LLVM, which may be a bit long. (Would LL be better?)</span></div></blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">LLVM seems fine to me, and the naming convention seems ok (using <span class="Apple-converted-space"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">lowercase + underscores makes the name longer).Ê I do find things like this slightly strange:</span></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">/* Same as Module::addTypeName. */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">int AddTypeNameToModule(LLVMModuleRef M, const char *Name, <span class="Apple-converted-space">Ê</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">LLVMTypeRef Ty);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I'd expect it to be named something like "LLVMModuleAddTypeName" or <span class="Apple-converted-space"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">something, using NamespaceClassMethod uniformly.</span></span></div></blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; ">I tried that at first; I do like to do Òmethod completion for CÓ in XCode by typing something likeÊ<font class="Apple-style-span" face="Courier">LLVMModule</font>Ê<i>esc</i>. Unfortunately, the names got bizarre and unreadable. I can go back to that, but it wasn't Ôdoing itÕ for me.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br class="webkit-block-placeholder"></div><blockquote type="cite"> <blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Pointers are opaque, obviously. I find myself copying enums, which <span class="Apple-converted-space"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">is mildly scary.</span></span></div> </blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Copying the enums does seems scary.Ê<span class="Apple-converted-space"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Is LLVMTypeKind that useful?</span></span></div></blockquote><div><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; ">Uhm. Just a little bit important? :) I'll need to do the same thing with instructions kinds, too.</div><br><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-converted-space"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Is there any way around this?</span></span></div></blockquote><br><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-style-span" style="-webkit-text-stroke-width: -1;">Well, we could move the enums into the C interfaces and include the C interfaces from the C++ code. That moves the values to the global namespace, though; neitherÊ<font class="Apple-style-span" face="Courier">Type::FooTyID</font>ÊnorÊ<font class="Apple-style-span" face="Courier">llvm::Type::FooTyID</font>Êwould be valid. The types themselves can be typedef'd back where they belong.</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><blockquote type="cite"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I'm using C strings instead of const char*, size_t tuples. This <span class="Apple-converted-space"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">avoids having to write things like "tmp", strlen("tmp") in C, and is well-supported for language bindings. Nevertheless, most languages other than C have binary-safe string types, so I'm certainly willing to have my mind changed if we want to prefer correctness over inconvenience to the C programmer. (Providing overloads is silly, though.)</span></span></div> </blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I think this makes sense.<span class="Apple-converted-space">Ê </span>In order to support arbitrary strings, you <span class="Apple-converted-space"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">could have a:</span></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">void LLVMValueSetName(LLVMValueRef, const char *, unsigned len);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">... function that works with arbitrary strings.</div></blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; ">That's true for this case, but I'm not sure there's always a backdoor like that available.ÊFor some things it doesn't matter, of course; valid filenames can't containÊ<font class="Apple-style-span" face="Courier">'\0'</font> on anything notable except Mac OS ­ X, for one.ÊI guess it's a case-by-case decision. While I'm sure someone, somewhere, would appreciate consistency, that person is not me.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br class="webkit-block-placeholder"></div><blockquote type="cite"> <blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I'm putting the headers in include/llvm-c. I created a new library <span class="Apple-converted-space"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">called Interop to house the C bindingsÑbut it might make more sense to implement the C bindings in each library instead. They're just glue which the linker will trivially DCE, so that approach may have merit.</span></span></div> </blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Nice!<span class="Apple-converted-space">Ê </span>You'll make a lot of friends with this :)</div></blockquote><div><br class="webkit-block-placeholder"></div><div>:) Of course, you realize they won't be happy until they don't have to link using g++É</div><div><br class="webkit-block-placeholder"></div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">adding the bindings <span class="Apple-converted-space"><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">to the libraries in question make sense.</span></span></div></blockquote><br></div><div>I'll do that.</div><div><br class="webkit-block-placeholder"></div><div>Ñ Gordon</div><div> </div><br></body></html>