在 iPhone 上执行序言代码

发布于 2024-09-27 02:44:36 字数 598 浏览 2 评论 0原文

我目前需要在我正在制作的应用程序中执行序言代码。我知道苹果可能永远不会允许这样的东西出现在 App Store 中,但这也不是意图。这更像是一个私人项目,永远不会进入 App Store。

目的

在这种情况下,序言用于描述对象(例如电话)及其属性。该对象将使用 prolog 脚本中指定的坐标通过 OpenGL 进行绘制。使用 prolog 的原因是我需要能够查询程序有关该对象具有的一些功能,而 prolog 大大简化了这一点。底线:我“需要”从我的应用程序查询序言脚本。

可能的解决方案

  • 嵌入用 C 编写的现有实现。我不确定这是否可行。
  • 在另一台机器上执行prolog代码,并使用网络查询prolog。
  • 似乎可以在应用程序内运行某种 Ruby VM(据我所知,shinycocos 使用此),这可以用于运行 Ruby Prolog 实现之一吗?
  • 寻找 Prolog 的替代方案。这需要给我一些与 prolog 相同的可能性。

可悲的是,谷歌几乎没有给我任何结果,所以我有一种感觉,我可能在这个项目上很孤独。如果有人有任何经验或线索,我将非常感激。

I currently have the need to execute prolog code in an application I am making. I am aware that Apple probably never would allow something like this in the App Store, but that is not the intention either. This is more a private project that will never reach the App Store.

Purpose

In this case prolog is used to describe an object (like for example a telephone) and its properties. The object will be drawn with OpenGL using coordinates specified in the prolog script. The reason for using prolog is that I need the ability to query the program about some of the features this object has, and prolog eases this a lot. Bottom line: I "need" to query a prolog script from my app.

Possible solutions

  • Embed an already existing implementation written in C. I am unsure if this will even work.
  • Execute the prolog code on another machine and use the network to query prolog.
  • It seems that it is possible to run some sort Ruby VM inside the app (shinycocos uses this as far as I understand), could this be used to run one of the Ruby Prolog implementations?
  • Find some alternative to Prolog. This needs to give me some of the same possibilities I get with prolog.

Sadly, google gives me close to no results at all, so I have a feeling that I might be quite alone on this project. If anyone have any experience or clue at all, I would be very thankful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

述情 2024-10-04 02:44:36

尽管情况不同,但在调用 prolog 代码时也遇到过类似的困难,我建议您查看castor c++ 库。这允许您用本机 C++ 编写逻辑范例代码,而根本不需要扩展该语言。由于 Castor 是一个仅包含头文件的库,因此在 C++ 可用的任何地方都可以轻松编译。
Castor 网站:http://www.mpprogramming.com/cpp/default.aspx

Having faced similar difficulties calling prolog code, albeit in a different situation, I'd recommend checking out the castor c++ library. This allows you to write logic paradigm code in native c++ without needing to extend the language at all. As castor is a header only library it is easy to compile wherever c++ is available.
Castor website: http://www.mpprogramming.com/cpp/default.aspx

帝王念 2024-10-04 02:44:36

半年过去了,我想就此提供一些见解。我最终用 Java 编写了一个带有 prolog 接口的服务器,通过 TCP 接受 prolog 调用。它的工作方式几乎与 SWI-prolog(以及其他)提供的实时 prolog 解释器完全相同,并且大多数情况下工作得很好。但是,它远非最佳解决方案,因为您无法从 prolog 内部调用函数。你失去了双向沟通的可能性。

如果我重新开始,我肯定会更加努力地编译 iOS 的纯 C 实现之一。我快速尝试了一下,但由于缺乏经验,我什至无法消除遇到的所有错误。鉴于您无法在未修改的 iOS 版本上将 prolog 作为后台进程运行,因此必须进行一些重大重写。因此,人们可能只需要从头开始编写一个新的实现(可能受到一些更轻量级的实现的启发)即可获得完美的解决方案。

Half a year later, I would just like to provide some insight on this. I ended up writing a server with an interface to prolog in Java, accepting prolog calls through TCP. It works almost exactly like the live prolog interpreter SWI-prolog (among others) provides, and mostly works quite well. However, it is far from an optimal solution, as you can't call functions from inside prolog. You lose the possibility of having two-way communication.

If I were to start all over again, I would certainly have tried harder to compile one of the pure C implementations for iOS. I gave it a quick go, but my lack of experience stopped me from even removing all of the errors I got. Judging by the fact that you cannot have prolog running as a background process on a unmodified version of iOS as well, some major rewriting would have to be done. Because of this, one might just have to write a new implementation (perhaps inspired by some of the more lightweight ones out there) from scratch to get the perfect solution.

送你一个梦 2024-10-04 02:44:36

您可以下载SWI-Prolog的源代码并使用iOS平台的XCODE进行编译。我从来没有这样做过,但这在技术上肯定是可行的。

一旦你这样做了,就有很多关于如何从C/C++运行 prolog 代码的示例,因此,你将能够从 Objective-C 运行 prolog。

You can download SWI-Prolog's source code and compile it with XCODE for iOS platform. I've never done that, but it's certainly technically possible.

Once you do that, there are a lot of examples on how to run prolog code from C/C++, hence, you will be able to run prolog from Objective-C.

衣神在巴黎 2024-10-04 02:44:36

仅供参考,如果您使用 JPL,您可以非常轻松地在 Java 和 SWI-Prolog 之间进行双向调用:

http://www.swi-prolog.org/packages/jpl/

它也是完全可重入的,因此您可以从 java 实例化 prolog 代码,而 java 代码又实例化 java 代码等...

我这样做了几年前,当我需要将基于 Prolog 的推理引擎连接到大量 Java 代码时,我参与了许多商业项目。

它确实使用 JNI(Java 本机接口),因此您需要小心如何编译和链接到本机 api。不过,如果您针对每个平台适当地编译它,则可以使其跨平台工作。我让它可以在 OS-X、Windows、Linux 和 Windows 上运行。索拉里斯。

FYI, you can quite easily bi-directionally make calls between Java and SWI-Prolog if you use JPL:

http://www.swi-prolog.org/packages/jpl/

It is also fully re-entrant, so you can instantiate prolog code from java, which in turn instantiates java code etc...

I did this for a number of commercial projects a few years ago when I was required to connect a Prolog based Reasoning Engine to a lot of Java code.

It does use JNI (the Java Native Interface), so you need to be careful about how you compile and link to the native api. Though if you compile it appropriately for each platform you can make it work cross platform. I had it working on OS-X, Windows, Linux & Solaris.

倾城泪 2024-10-04 02:44:36

我不知道这是否已经尝试过,但有可能将 NodeJS 组合用于移动应用程序和应用程序。 TauProlog:

在此处输入图像描述

在此处输入图像描述

I do not know if this has been tried but there is the possibility to use the combination of NodeJS for Mobile Apps & TauProlog:

enter image description here

and

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文