Permalink
Browse files

Merge branch 'dev' of https://github.com/fibjs/fibjs into dev

  • Loading branch information...
xicilion committed Jul 9, 2018
2 parents 70c117a + 6a252e7 commit 5d36247e31c20ce366af06bddf509986057dc188
View
@@ -22,8 +22,7 @@ class Digest : public Digest_base {
public:
// Digest_base
virtual result_t update(Buffer_base* data, obj_ptr<Digest_base>& retVal);
virtual result_t digest(Buffer_base* data, obj_ptr<Buffer_base>& retVal);
virtual result_t digest(obj_ptr<Buffer_base>& retVal);
virtual result_t digest(exlib::string codec, v8::Local<v8::Value>& retVal);
virtual result_t get_size(int32_t& retVal);
private:
View
@@ -24,8 +24,7 @@ class Digest_base : public object_base {
public:
// Digest_base
virtual result_t update(Buffer_base* data, obj_ptr<Digest_base>& retVal) = 0;
virtual result_t digest(Buffer_base* data, obj_ptr<Buffer_base>& retVal) = 0;
virtual result_t digest(obj_ptr<Buffer_base>& retVal) = 0;
virtual result_t digest(exlib::string codec, v8::Local<v8::Value>& retVal) = 0;
virtual result_t get_size(int32_t& retVal) = 0;
public:
@@ -89,22 +88,18 @@ inline void Digest_base::s_update(const v8::FunctionCallbackInfo<v8::Value>& arg
inline void Digest_base::s_digest(const v8::FunctionCallbackInfo<v8::Value>& args)
{
obj_ptr<Buffer_base> vr;
v8::Local<v8::Value> vr;
METHOD_NAME("Digest.digest");
METHOD_INSTANCE(Digest_base);
METHOD_ENTER();
METHOD_OVER(1, 1);
METHOD_OVER(1, 0);
ARG(obj_ptr<Buffer_base>, 0);
OPT_ARG(exlib::string, 0, "buffer");
hr = pInst->digest(v0, vr);
METHOD_OVER(0, 0);
hr = pInst->digest(vr);
METHOD_RETURN();
}
@@ -229,10 +229,10 @@ inline void global_base::s_setTimeout(const v8::FunctionCallbackInfo<v8::Value>&
METHOD_NAME("global.setTimeout");
METHOD_ENTER();
METHOD_OVER(-1, 2);
METHOD_OVER(-1, 1);
ARG(v8::Local<v8::Function>, 0);
ARG(double, 1);
OPT_ARG(double, 1, 1);
ARG_LIST(2);
hr = setTimeout(v0, v1, v2, vr);
@@ -88,10 +88,10 @@ inline void timers_base::s_setTimeout(const v8::FunctionCallbackInfo<v8::Value>&
METHOD_NAME("timers.setTimeout");
METHOD_ENTER();
METHOD_OVER(-1, 2);
METHOD_OVER(-1, 1);
ARG(v8::Local<v8::Function>, 0);
ARG(double, 1);
OPT_ARG(double, 1, 1);
ARG_LIST(2);
hr = setTimeout(v0, v1, v2, vr);
View
@@ -680,6 +680,8 @@ class OptArgs {
, m_base(base)
, m_argc(argc)
{
if (m_base > m_argc)
m_base = m_argc;
}
OptArgs(const OptArgs& a)
@@ -9,6 +9,7 @@
#include "ifs/hash.h"
#include "Digest.h"
#include "Buffer.h"
#include "encoding.h"
#include <string.h>
namespace fibjs {
@@ -58,13 +59,13 @@ result_t Digest::update(Buffer_base* data, obj_ptr<Digest_base>& retVal)
return 0;
}
result_t Digest::digest(obj_ptr<Buffer_base>& retVal)
result_t Digest::digest(exlib::string codec,
v8::Local<v8::Value>& retVal)
{
exlib::string strBuf;
if (m_iAlgo < 0)
return CHECK_ERROR(CALL_E_INVALID_CALL);
exlib::string strBuf;
strBuf.resize(mbedtls_md_get_size(m_ctx.md_info));
if (m_bMac)
@@ -75,22 +76,20 @@ result_t Digest::digest(obj_ptr<Buffer_base>& retVal)
m_iAlgo = -1;
mbedtls_md_hmac_reset(&m_ctx);
retVal = new Buffer(strBuf);
if ((codec == "buffer")) {
obj_ptr<Buffer_base> buf = new Buffer(strBuf);
retVal = buf->wrap();
} else {
exlib::string data;
result_t hr = commonEncode(codec, strBuf, data);
if (hr < 0)
return hr;
retVal = holder()->NewString(data);
}
return 0;
}
result_t Digest::digest(Buffer_base* data,
obj_ptr<Buffer_base>& retVal)
{
if (m_iAlgo < 0)
return CHECK_ERROR(CALL_E_INVALID_CALL);
obj_ptr<Digest_base> r;
update(data, r);
return digest(retVal);
}
result_t Digest::get_size(int32_t& retVal)
{
if (m_iAlgo < 0)
View
@@ -7,15 +7,10 @@ interface Digest : object
update(Buffer data);
/*! @brief Compute and return the digest
@param data Binary data packet which will be updated into the digest before computing
@return The binary digest
@param codec The encode format, can be "buffer", "hex", “base64”, "utf8" or any other character sets supported by the system.
@return The encode value representing the value of the digest
*/
Buffer digest(Buffer data);
/*! @brief Compute and return the digest
@return The binary digest
*/
Buffer digest();
Value digest(String codec = "buffer");
/*! @brief Query the number of bytes of the digest of the digest algorithm currently being used */
readonly Integer size;
View
@@ -84,7 +84,7 @@ module global
@param args Optional arguments to pass when the callback is called.
@return The returned timeoutID is a positive integer value which identifies the timer created by the call to setTimeout(); this value can be passed to clearTimeout() to cancel the timeout.
*/
static Timer setTimeout(Function callback, Number timeout, ...args);
static Timer setTimeout(Function callback, Number timeout = 1, ...args);
/*! @brief run a callback function immediately after the browser has completed other operations such as events and display updates.
@param callback the function you wish to call.
View
@@ -30,7 +30,7 @@ module timers
@param args Optional arguments to pass when the callback is called.
@return The returned timeoutID is a positive integer value which identifies the timer created by the call to setTimeout(); this value can be passed to clearTimeout() to cancel the timeout.
*/
static Timer setTimeout(Function callback, Number timeout, ...args);
static Timer setTimeout(Function callback, Number timeout = 1, ...args);
/*! @brief run a callback function immediately after the browser has completed other operations such as events and display updates.
@param callback the function you wish to call.
View
@@ -8,15 +8,10 @@ interface Digest : object
Digest update(Buffer data);
/*! @brief 计算并返回摘要
@param data 二进制数据块,此数据块将在计算前更新进摘要
@return 返回摘要的二进制数据
@param codec 指定编码格式,允许值为:"buffer", "hex", "base64", "utf8", 或者系统支持的字符集
@return 返回指定编码的摘要表示
*/
Buffer digest(Buffer data);
/*! @brief 计算并返回摘要
@return 返回摘要的二进制数据
*/
Buffer digest();
Value digest(String codec = "buffer");
/*! @brief 查询当前信息摘要算法的摘要字节数 */
readonly Integer size;
View
@@ -103,7 +103,7 @@ module global
@param args 额外的参数,传入到指定的 callback 内,可选。
@return 返回定时器对象
*/
static Timer setTimeout(Function callback, Number timeout, ...args);
static Timer setTimeout(Function callback, Number timeout = 1, ...args);
/*! @brief 清除指定的定时器
@param t 指定要清除的定时器
View
@@ -7,7 +7,7 @@ module timers
@param args 额外的参数,传入到指定的 callback 内,可选。
@return 返回定时器对象
*/
static Timer setTimeout(Function callback, Number timeout, ...args);
static Timer setTimeout(Function callback, Number timeout = 1, ...args);
/*! @brief 清除指定的定时器
@param t 指定要清除的定时器
Oops, something went wrong.

0 comments on commit 5d36247

Please sign in to comment.