You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
`//-------------------------------------------------------------------------------------------------------
// Author:HAO Jing
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
`//-------------------------------------------------------------------------------------------------------
// Author:HAO Jing
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "ChakraCore.h"
#include "ChakraCommon.h"
#include <stdlib.h>
#include <stdio.h>
#include
#include
#include
#define FAIL_CHECK(cmd)
do
{
JsErrorCode errCode = cmd;
if (errCode != JsNoError)
{
printf("Error %d at '%s'\n",
errCode, #cmd);
return 1;
}
} while(0)
using namespace std;
JsValueRef CHAKRA_CALLBACK JSHello(JsValueRef caller,bool isConstructCall,JsValueRef* arguments,unsigned short argumentCount,void* callbackState);
JsValueRef CHAKRA_CALLBACK JSLogCB(JsValueRef caller,bool isConstructCall,JsValueRef* arguments,unsigned short argumentCount,void* callbackState);
void setCallback(JsValueRef* object,const char* propertyName,JsNativeFunction callback,void* callbackState);
//int x =1;
int main()
{
JsRuntimeHandle runtime;
JsContextRef context;
JsValueRef result;
unsigned currentSourceContext = 0;
}
JsValueRef CHAKRA_CALLBACK JSLogCB(JsValueRef caller,bool isConstructCall,JsValueRef* arguments,unsigned short argumentCount,void* callbackState)
{
cout<<argumentCount<<endl;
char* buff = nullptr;
JsValueRef strMsg;
JsConvertValueToString(arguments[1], &strMsg);
size_t length;
JsCopyString(strMsg, buff, 0, &length);
buff = new char[length+1];
JsCopyString(strMsg, buff, length+1, nullptr);
cout<<buff<<endl;
return JS_INVALID_REFERENCE;
}
JsValueRef CHAKRA_CALLBACK JSHello(JsValueRef caller,bool isConstructCall,JsValueRef* arguments,unsigned short argumentCount,void* callbackState)
{
//return JS_INVALID_REFERENCE;
//JsValueRef ret = JS_INVALID_REFERENCE;
double x,y,z;
JsNumberToDouble(arguments[1], &x);
JsNumberToDouble(arguments[2], &y);
z = x+y;
JsValueRef ret;
const char* msg = "return";
JsCreateString(msg, strlen(msg), &ret);
std::cout<<"this is a native function"<<std::endl;
return ret;
//return ret;
}
void setCallback(JsValueRef* object,const char* propertyName,JsNativeFunction callback,void* callbackState)
{
}
`
The text was updated successfully, but these errors were encountered: