Skip to content

Commit

Permalink
增加process.version
Browse files Browse the repository at this point in the history
  • Loading branch information
ngot committed Dec 29, 2016
1 parent 667fe97 commit 4d2a6f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion fibjs/include/ifs/process.h
Expand Up @@ -27,6 +27,7 @@ class process_base : public object_base
// process_base
static result_t get_argv(v8::Local<v8::Array>& retVal);
static result_t get_execArgv(v8::Local<v8::Array>& retVal);
static result_t get_version(exlib::string& retVal);
static result_t get_execPath(exlib::string& retVal);
static result_t get_env(v8::Local<v8::Object>& retVal);
static result_t get_arch(exlib::string& retVal);
Expand Down Expand Up @@ -56,6 +57,7 @@ class process_base : public object_base
public:
static void s_get_argv(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value> &args);
static void s_get_execArgv(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value> &args);
static void s_get_version(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value> &args);
static void s_get_execPath(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value> &args);
static void s_get_env(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value> &args);
static void s_get_arch(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value> &args);
Expand Down Expand Up @@ -92,6 +94,7 @@ namespace fibjs
{
{"argv", s_get_argv, block_set, true},
{"execArgv", s_get_execArgv, block_set, true},
{"version", s_get_version, block_set, true},
{"execPath", s_get_execPath, block_set, true},
{"env", s_get_env, block_set, true},
{"arch", s_get_arch, block_set, true},
Expand All @@ -101,7 +104,7 @@ namespace fibjs
static ClassData s_cd =
{
"process", s__new, NULL,
7, s_method, 0, NULL, 6, s_property, NULL, NULL,
7, s_method, 0, NULL, 7, s_property, NULL, NULL,
NULL
};

Expand Down Expand Up @@ -131,6 +134,17 @@ namespace fibjs
METHOD_RETURN();
}

inline void process_base::s_get_version(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value> &args)
{
exlib::string vr;

PROPERTY_ENTER();

hr = get_version(vr);

METHOD_RETURN();
}

inline void process_base::s_get_execPath(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value> &args)
{
exlib::string vr;
Expand Down
3 changes: 3 additions & 0 deletions fibjs/include/ifs/process.idl
Expand Up @@ -13,6 +13,9 @@ module process
/*! @brief 返回当前进程的特殊命令行参数,这些参数被 fibjs 用于设置运行环境 */
static readonly Array execArgv;

/*! @brief 返回fibjs版本字符串 */
static readonly String version;

/*! @brief 查询当前运行执行文件完整路径 */
static readonly String execPath;

Expand Down
9 changes: 9 additions & 0 deletions fibjs/src/process/process.cpp
Expand Up @@ -6,6 +6,7 @@
*/

#include "object.h"
#include "ifs/util.h"
#include "ifs/process.h"
#include "ifs/os.h"
#include "ifs/global.h"
Expand Down Expand Up @@ -96,6 +97,14 @@ result_t process_base::get_execArgv(v8::Local<v8::Array>& retVal)
return 0;
}

extern char s_version[];

result_t process_base::get_version(exlib::string &retVal)
{
retVal = s_version;
return 0;
}

result_t process_base::get_execPath(exlib::string &retVal)
{
return os_base::get_execPath(retVal);
Expand Down

0 comments on commit 4d2a6f1

Please sign in to comment.