how to call simple addition function in c file from javascript through native client

83 views Asked by At
I have installed **naclsdk** with stable pepper35 version.

i found getting started tutorial for c++ but i cant find any simple tutorial for c.As i new to chrome-native client it will be helpful if any one tells how to call simple c function from javascript through chrome browser because i need to call already existing c algorithm functions from javascript and i need to update graph using that returned value.i tried some examples but i cant understand.. i need to call in javascript like var ans = pexe_instance.Addition(5,6)

1

There are 1 answers

0
binji On BEST ANSWER

The Native Client SDK has a few examples that are written in C. Take a look at:

Passing messages back and forth between Native Client and JavaScript is easiest with ppapi_simple. The life.c example shows how to handle messages in the ProcessEvent function:

void ProcessEvent(PSEvent* event) {
  switch(event->type) {
    case PSE_INSTANCE_HANDLEMESSAGE: {
      struct PP_Var var = event->as_var;
      ...
      break;
    }

    default:
      break;
  }
}