BenitoJedai / nativeclient-sdk

Automatically exported from code.google.com/p/nativeclient-sdk
0 stars 1 forks source link

Step 5 of tutorial has incorrect code snippet. #114

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
http://code.google.com/chrome/nativeclient/docs/tutorial.html#messageHandler

virtual void HandleMessage(const pp::Var& var_message) {  
   if (!var_message.is_string()) {
      return;
    }
    std::string message = var_message.AsString();
    pp::Var var_reply;
    if (message == kHelloString)
      var_reply = pp::Var(kReplyString);
    PostMessage(var_reply);
  }
};

It's hard to see in this copy above, but the indentation is incorrect.
1 - The first 'If' is 4 spaces in instead of 2
2 - Inconsistent use if {} for single line statement in the first IF vs second 
IF.  Why not just 'return;' instead?  The usual convention wrt {} is use it if 
it's on multiple lines, otherwise use same line as if.
3 - Either their is a missing { on the second if, or here is an extra } before 
the final };  Again it's hard to tell the original intention because of the 4 
space on the original if.

Original issue reported on code.google.com by noelal...@google.com on 11 Aug 2011 at 6:56

GoogleCodeExporter commented 8 years ago

Original comment by dsprin...@chromium.org on 15 Aug 2011 at 5:10

GoogleCodeExporter commented 8 years ago

Original comment by dsprin...@chromium.org on 23 Aug 2011 at 9:49