Building to shared libraries for use in other projects

I’ve managed to built the apps from the GitHub repo and having pretty good success to this point, mostly. I’ve got wrappers for Python and .NET (for use in an experimental Unity 3D project), and it really works great. I’ve read the “Calling Inform From C” section in the manual, and have implemented most of the functions.

BUT, and this is driving me nuts, I can’t seem to find the right combo to get the actual LOCATION/ROOM of an instance/person, for example, “i7_I_Somebody”, using either “i7_read_prop_value” or even combinations of “i7_read_variable”. I can get values of defined properties of i7_I_Somebody, just not their location, and I’m not sure what I’m missing. (I know it must be simple.)

Any one have an idea ?


1 Like

Welcome to the forum!

That’s accomplished by the location of phrase which you can see in the Standard Rules is defined with inline I6 as LocationOf. It looks like this isn’t in the documentation, and I haven’t tried it personally, but looking at compiled C output, it seems like the names of I6 functions from Kits get transformed by prepending I7_fn_ (but now the first parameter is a pointer to an i7process_t) so it would be I7_fn_LocationOf.

OK, if you use inform7 -format=C/symbols-header you get an inform7_symbols.h file that lets you see what symbols are available. And if you include that in your C program, it will be the case that you have access to Inform 7 phrases with the names transformed per Calling Inform from C except for things defined as inline I6, like location of, where you have no choice but to look up the inline I6 and do as I described above. The docs do tell you that phrases defined with inline I6 won’t work, but doesn’t tell you what to do about it. This was probably deliberate: the I6 layer has always been defined to be subject to change without notice.

Zed, thanks ! I SAW that function down there in the file, but was leery of straying initially from the docs :). I’ll give it a try tomorrow and let you know. If it works, now I know what to do with all of those other functions listed around it !.

FYI, I’m definitely using -format=C/no-main/symbols-header. And I use a special Python script to parse out inform7_symbols.h to get constants/enums for C# and Python.

1 Like

Please let us know how it goes! This is new territory.

I haven’t done much with the C integration, but is there any reason not to define an I7 phrase that just wraps “the location of X”, so you can call that from C?

1 Like

No, there’s no reason why that painfully obvious in hindsight thing I completely didn’t think of wouldn’t work. :laughing:

“location of (O - object)” is an I7 phrase, so it’s not obvious why the name-mangling described in “Calling Inform from C” won’t work directly.

(But I haven’t tried any of this.)

I don’t see a reason why it wouldn’t be possible to make the compiler do it, but today “Calling Inform from C” also says:

Phrases defined inline cannot be called, because they are not functions.

I7_F_location_of doesn’t get defined in inform7_symbols.h.

Hm. Well, they’re functions at some level of abstraction, but I guess not at the level that the C generator needs.

(“Inline” is a confusing way of saying “I7 phrase with an I6 definition”. I mean, confusing if you don’t already know the answer to this question.)

Wrapping it with a pure I7 phrase will work, then.

I definitely will. My plan is to get a simple example workflow up on GitHub in the next couple of weeks.

I do go back to the early days of IF (yes, I’m THAT old.) I used to play around with TADS, and it is extremely powerful, but as a developer, it was TOO LITTLE like C++ and TOO MUCH like C++, if that makes any sense, and I eventually got frustrated. A few months ago, I started digging into Inform and fell in love with the natural language aspect of it.

I have an autistic teenager and so while he’s a whiz at Xbox/Switch etc, reading comprehension is usually a challenge for kids like him, and I wanted to create something that bridged those 2 worlds. And when I saw Graham’s big announcement, and read “It enables entirely new developments, from peephole optimisation and other compilery recreations to the ability to have Inform compile its natural-language source down to C code: this in turn can then be compiled by clang or gcc to a stand-alone executable, or to code which can be linked into Unity projects, iOS apps or similar. It thus becomes possible, and we hope even convenient, for choice-based games for console, mobile or desktop to use Inform, if they wish, purely for world-modelling, conversation, or dynamic text generation.”, the light bulb went off.

So I’m deep-diving Inform7 from the official docs, this forum, the Handbook from Jim Aikin, and even the 2011 Inform for Programmers from Ron Newcomb. I’m not an expert in I6 at all, but I have a feeling I’m going to need to be. :slight_smile:

Anyway, that’s my story and I’m sticking to it. :slight_smile:


Just to add, so far, wrapping the basic functions in “Calling Inform from C” seems to be going well, and Instance IDs, Enumerations, Kind IDs, Action IDs, and Property IDs, and for the most part, Variable IDs, it’s where I get to the Function IDs that I’m starting to struggle a bit, but I just started that part.

1 Like

Dang it, still getting the hang of the formatting rules here, so something like this ? Will have to rearrange by workflow a bit, but I think this should work.

#define. i7_F_decide_which_object_is_room_of_X i7_xfn_call_U2360
i7word_t i7_xfn_call_U2360(i7process_t *proc, i7word_t p0);

1 Like