« Return to Thread: %include directive.

Re: %include directive.

by wsfulton :: Rate this Message:

Reply to Author | View in Thread

I don't know the OCAML module and what files it generates, but in the
code below, you don't have any %template directive for wrapping
std::list. Please read the C++ chapter in the documentation on template
wrapping. %module should also be at the top of the interface file, but
it shouldn't matter given that you only have a %include of a templated
library above it. As you've commented out most of your code, you will
only get wrappers for tokenizer and spitter, it isn't clear if you were
expecting more.

William

Guillaume Yziquel wrote:

> Hello.
>
> I've made a swig freeling.i file that worked. As I was going to use more
> and more std::lists, I tried to modularise it by adding %include
> <std_list.i> and commenting out the code wrapping lists.
>
> Now, I get std_list.ml and std_list.mli as well as std_lib_wrap.cxx, but
> not anymore the files wrapping freeling.i...
>
> What am I doing wrong?
>
> All the best,
>
> Guillaume Yziquel
>
>
>> yziquel@seldon:~/svn/main/libmorfo-ocaml$ cat freeling.i
>> %include <std_list.i>
>>
>> %module swig_Freeling
>> %{
>>
>> #include "freeling.h"
>>
>> using namespace std;
>>
>> string string_of_chars (char * c)
>> {
>>   string s (c);
>>   return s;
>> }
>>
>> /*word last_word_of_word_list (list<word> & l)
>> {
>>   word head = l.front ();
>>   return head;
>> }
>>
>> void pop_last_word_list (list<word> & l)
>> {
>>   l.pop_front ();
>> }
>>
>> bool is_empty_word_list (list<word> & l)
>> {
>>   bool b = l.empty ();
>>   return b;
>> }
>>
>> list<word> new_word_list ()
>> {
>>   list<word> l;
>>   return l;
>> }
>>
>> void push_last_word_list (list<word> & l, word& w)
>> {
>>   l.push_back (w);
>> }*/
>>
>> %}
>>
>> // C++ functions used to glue code with OCaml.
>>
>> string string_of_chars (char *);
>>
>> /*word last_word_of_word_list (list<word> &);
>> void pop_last_word_list (list<word> &);
>> bool is_empty_word_list (list<word> &);
>> list<word> new_word_list ();
>> void push_last_word_list (list<word> &, word &);*/
>>
>> // Freeling declarations.
>>
>> class tokenizer {
>>    public:
>>        /// Constructor
>>        tokenizer(const string &);
>>
>>        /// tokenize string with default options
>>        list<word> tokenize(const string &);
>>        /// tokenize string with default options, tracking offset in given int param.
>>        list<word> tokenize(const string &, unsigned long &);
>> };
>>
>> class splitter {
>>    public:
>>       /// Constructor
>>       splitter(const std::string &);
>>
>>       /// split sentences with default options
>>       std::list<sentence> split(const std::list<word> &, bool);
>> };
>>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Swig-user mailing list
> Swig-user@...
> https://lists.sourceforge.net/lists/listinfo/swig-user
>


------------------------------------------------------------------------------
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: %include directive.