mbeddr / mbeddr.core

The mbeddr core. An extensible C
Eclipse Public License 2.0
223 stars 77 forks source link

can't refer to required c/s interface's member function as a function pointer #378

Open aykutkilic opened 12 years ago

aykutkilic commented 12 years ago

In case I have a required c/s interface:

exported c/s interface jack_listener { 
  int32 on_set_buffer_size(jack_nframes_t nframes, void* p_param) 
}

I would like to be able to refer to it as a function pointer for callback functions case like below:

exported component jack_wrapper extends nothing { 
  requires jack_listener listener 
  jack_client_t* p_client 

  void init() ⬅ on init { 
    jack_set_buffer_size_callback(p_client, :listener.on_set_buffer_size, null); 
  } runnable 
}

where: int32 jack_set_buffer_size_callback(jack_client_t* client, JackBufferSizeCallback bufsize_callback, void* arg); and: typedef (jack_nframes_t, void*)⇒(int) as JackBufferSizeCallback;

markusvoelter commented 12 years ago

Take a look at this test in ext.components: test.ex.ext.components.interfaceTypes

Does this do what you need?

markusvoelter commented 12 years ago

By the way: I don't know if this helps, but it is also possible to rewire required ports at runtime. Maybe this is an alternative to using "pointers"?

aykutkilic commented 12 years ago

The one in test passes interface as a parameter, What I need is passing the pointer to the function of the interface. This reduces the amount of code to write.

Out of the scope of this issue but, also it is not possible to refer to a runnable with the : operator.

I've pushed the not working version to aynth git repo.