Skip to content

Instantly share code, notes, and snippets.

@mrryanjohnston
Last active September 9, 2020 17:11
Show Gist options
  • Save mrryanjohnston/07d7b9da6b06e8ef2695ad381d156055 to your computer and use it in GitHub Desktop.
Save mrryanjohnston/07d7b9da6b06e8ef2695ad381d156055 to your computer and use it in GitHub Desktop.
CLIPS via Ruby using FFI
module Clips
extend FFI::Library
ffi_lib 'clips/libclips.so'
attach_function :create_environment, :CreateEnvironment, [], :pointer
attach_function :reroute_stdin, :RerouteStdin, [:pointer, :int, :pointer], :pointer
attach_function :command_loop, :CommandLoop, [:pointer], :void
end
the_env = Clips.create_environment
Clips.reroute_stdin(the_env, 0, FFI::MemoryPointer.new(:pointer))
Clips.command_loop(the_env)
#include "clips.h"
int main(
int argc,
char *argv[])
{
void *theEnv;
theEnv = CreateEnvironment();
RerouteStdin(theEnv,argc,argv);
CommandLoop(theEnv);
return(-1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment