格式化代码
This commit is contained in:
parent
0d68a31aee
commit
5d771cc4a3
@ -7,12 +7,15 @@
|
||||
#include "scripting/js-bindings/event/EventDispatcher.h"
|
||||
#include "scripting/js-bindings/manual/jsb_conversions.hpp"
|
||||
#include "platform/CCApplication.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#include "AppDelegate.h"
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
||||
cocos2d::Application *cocos_android_app_init(int width, int height);
|
||||
|
||||
#endif
|
||||
using namespace cocos2d;
|
||||
NS_CC_BEGIN
|
||||
@ -31,6 +34,7 @@ NS_CC_BEGIN
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool addToArgArray(se::ValueArray *args, const char *valChar) {
|
||||
std::string strVal(valChar);
|
||||
se::Value tmpVal;
|
||||
@ -63,7 +67,7 @@ NS_CC_BEGIN
|
||||
JcWallet::_instance = nullptr;
|
||||
}
|
||||
|
||||
char* JcWallet::initWallet(const char *passwordChar) {
|
||||
char *JcWallet::initWallet(const char *passwordChar) {
|
||||
static std::string result;
|
||||
se::ValueArray args;
|
||||
addToArgArray(&args, passwordChar);
|
||||
@ -72,13 +76,13 @@ NS_CC_BEGIN
|
||||
if (ok && !value.isNullOrUndefined()) {
|
||||
result = value.toString();
|
||||
WalletEvent::Emit("wallet_inited", "{1}");
|
||||
}else {
|
||||
} else {
|
||||
result = "";
|
||||
}
|
||||
return const_cast<char*>(result.c_str());
|
||||
return const_cast<char *>(result.c_str());
|
||||
}
|
||||
|
||||
char* JcWallet::signLogin(const char *nonceChar, const char *tipChar) {
|
||||
char *JcWallet::signLogin(const char *nonceChar, const char *tipChar) {
|
||||
se::ValueArray args;
|
||||
addToArgArray(&args, nonceChar);
|
||||
addToArgArray(&args, tipChar);
|
||||
@ -88,21 +92,21 @@ NS_CC_BEGIN
|
||||
static std::string result;
|
||||
if (ok && !value.isNullOrUndefined()) {
|
||||
result = value.toString();
|
||||
}else {
|
||||
} else {
|
||||
result = "";
|
||||
}
|
||||
return const_cast<char*>(result.c_str());
|
||||
return const_cast<char *>(result.c_str());
|
||||
}
|
||||
|
||||
char* JcWallet::createAccount() {
|
||||
char *JcWallet::createAccount() {
|
||||
// return JcWallet::getInstance()->runJsMethod("createAccount", "");
|
||||
}
|
||||
|
||||
char* JcWallet::importAccount(const char *privateKey){
|
||||
char *JcWallet::importAccount(const char *privateKey) {
|
||||
// return JcWallet::getInstance()->runJsMethod("importAccount", privateKey);
|
||||
}
|
||||
|
||||
char* JcWallet::runJsMethod(const char *methodName, int paramCount, char **paramList) {
|
||||
char *JcWallet::runJsMethod(const char *methodName, int paramCount, char **paramList) {
|
||||
const char *arg;
|
||||
se::ValueArray args;
|
||||
cocos2d::log("call method %s", methodName);
|
||||
@ -116,28 +120,28 @@ NS_CC_BEGIN
|
||||
static std::string result;
|
||||
if (ok && !value.isNullOrUndefined()) {
|
||||
result = value.toString();
|
||||
}else {
|
||||
} else {
|
||||
result = "";
|
||||
}
|
||||
return const_cast<char*>(result.c_str());
|
||||
return const_cast<char *>(result.c_str());
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
char* initWallet(const char *passwordChar) {
|
||||
char *initWallet(const char *passwordChar) {
|
||||
JcWallet::getInstance()->initEnv();
|
||||
return JcWallet::getInstance()->initWallet(passwordChar);
|
||||
}
|
||||
char* signLogin(const char *nonceChar, const char *tipChar) {
|
||||
char *signLogin(const char *nonceChar, const char *tipChar) {
|
||||
return JcWallet::getInstance()->signLogin(nonceChar, tipChar);
|
||||
}
|
||||
char* createAccount() {
|
||||
char *createAccount() {
|
||||
return JcWallet::getInstance()->createAccount();
|
||||
}
|
||||
char* importAccount(const char *privateKey) {
|
||||
char *importAccount(const char *privateKey) {
|
||||
return JcWallet::getInstance()->importAccount(privateKey);
|
||||
}
|
||||
char* runWalletMethod(const char *methodName, int paramCount, char **paramList) {
|
||||
char *runWalletMethod(const char *methodName, int paramCount, char **paramList) {
|
||||
JcWallet::getInstance()->initEnv();
|
||||
return JcWallet::getInstance()->runJsMethod(methodName, paramCount, paramList);
|
||||
}
|
||||
|
@ -2,22 +2,34 @@
|
||||
#include "stdarg.h"
|
||||
#include "scripting/js-bindings/manual/jsb_conversions.hpp"
|
||||
#include "base/ccMacros.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
bool addToArgArray(se::ValueArray *args, const char *val);
|
||||
|
||||
bool runGlobalMethod(const char *name, se::ValueArray args, se::Value *value);
|
||||
|
||||
class CC_DLL JcWallet {
|
||||
public:
|
||||
void initEnv();
|
||||
|
||||
JcWallet();
|
||||
|
||||
virtual ~JcWallet();
|
||||
static JcWallet* getInstance() { return _instance; }
|
||||
char* initWallet(const char *passwordChar);
|
||||
char* signLogin(const char *nonceChar, const char *tipChar);
|
||||
char* createAccount();
|
||||
char* importAccount(const char *privateKey);
|
||||
char* runJsMethod(const char *methodName, int paramCount, char **paramList);
|
||||
|
||||
static JcWallet *getInstance() { return _instance; }
|
||||
|
||||
char *initWallet(const char *passwordChar);
|
||||
|
||||
char *signLogin(const char *nonceChar, const char *tipChar);
|
||||
|
||||
char *createAccount();
|
||||
|
||||
char *importAccount(const char *privateKey);
|
||||
|
||||
char *runJsMethod(const char *methodName, int paramCount, char **paramList);
|
||||
|
||||
private:
|
||||
static JcWallet* _instance;
|
||||
static JcWallet *_instance;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
Loading…
x
Reference in New Issue
Block a user