#ifndef signal_h__
#define signal_h__


#include "stdint.h"
#include "rtthread.h"
#include <rthw.h>
#include "string.h"




#define signal void
#define emit

typedef struct _slot_list{
  struct _slot_list *next;
  void *fun;
  void *mb;
  void *obj;
}slot_list;


typedef struct _signal_list{
  struct _signal_list *next;
  slot_list *head;
  void *sig_obj;
  void *signal_;
}signal_list;




typedef struct{
  const char *name;
  void *signal_;
//  slot_list *head;
}signal_def;


typedef struct{
  void *fun;
  void *src;
  int param_num;
  uint32_t param[0];
}slot_msg_def;




typedef struct{
  void *mb;
  int run;
}slot_run_def;


typedef void * sig_thread;







#define signal_export(name_) \
  const static char __sig_##name_##_name[] SECTION(".rodata.sigstr") = #name_; \
  RT_USED static signal_def _signal_##name_ SECTION("signalstruct")= \
  {\
    .name=__sig_##name_##_name,\
    .signal_=name_,\
  };



sig_thread thread_creat(int pro);
void thread_delete(sig_thread t);
signal_def *signal_find(void *signal_);
int connect(void *sig_obj,void *signal_,sig_thread t,void *slot_obj,void *slot);
int disconnect(void *sig_obj,void *signal_,sig_thread t,void *slot_obj,void *slot);
int signal_init(void);
int disconnect_sig(void *sig_obj);
int disconnect_slot(void *slot_obj);





  
  
  
int _signal_emit(void *sig_obj,void *signal_,uint32_t *param,int param_num);



#endif

