DPI-C export of a task defined inside a SystemVerilog class

In reply to dnguyen82us:
You cannot import/export class methods. Same problem exists between C and C++.

module top;
   class packet;
      static packet list[int];
      int id;
      function new (int my_id);
	 id = my_id;
	 if (list.exists(id))
           $error("id %0d already exists",id);
	 else
           list[id] = this;  
      endfunction : new
      task send (int data);
	 #1ns;
	 $display ("%t id: %0d data = %h", $time,id,data);
      endtask : send
   endclass : packet
   
   task send_wrapper(int id, int data);
      if (packet::list.exists(id))
	packet::list[id].send(data);
      else        
	$error("id %0d does not exist",id);
   endtask
   
   packet h;
   initial begin
      for(int i=1;i<=10;i++) h = new(i);
      call_into_c;
      $display("all done at %t", $time);
   end
   
   import "DPI-C" context task call_into_c();
   export "DPI-C" send = task send_wrapper; 
endmodule : top

C code:

#include "svdpi.h"
int send(int id, int data);
int call_into_c() {
  for(int i=2;i<=11;i++)
    if (send(i,i*i)) return 1;
  return 0;
}