Skip to content

Commit

Permalink
Refactor CScriptEngine::parse_script_namespace function.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Dec 6, 2015
1 parent e948ea5 commit 3ed4224
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/xrScriptEngine/script_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class XRSCRIPTENGINE_API CScriptEngine
bool process_file(LPCSTR file_name);
bool process_file(LPCSTR file_name, bool reload_modules);
bool function_object(LPCSTR function_to_call, luabind::object &object, int type = LUA_TFUNCTION);
IC void parse_script_namespace(LPCSTR function_to_call, LPSTR name_space, u32 const namespace_size, LPSTR function, u32 const function_size);
IC void parse_script_namespace(const char *name, char *ns, u32 nsSize, char *func, u32 funcSize);
template<typename TResult>
IC bool functor(LPCSTR function_to_call, luabind::functor<TResult> &lua_function);
#ifdef USE_DEBUGGER
Expand Down
22 changes: 9 additions & 13 deletions src/xrScriptEngine/script_engine_inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,21 @@ CScriptProcess *CScriptEngine::script_process(const ScriptProcessor &process_id)
return nullptr;
}

IC void CScriptEngine::parse_script_namespace(LPCSTR function_to_call, LPSTR name_space,
u32 const namespace_size, LPSTR function, u32 const function_size)
IC void CScriptEngine::parse_script_namespace(const char *name, char *ns, u32 nsSize, char *func, u32 funcSize)
{
LPCSTR I = function_to_call, J = nullptr;
for (; ; J = I , ++I)
auto p = strrchr(name, '.');
if (!p)
{
I = strchr(I, '.');
if (!I)
break;
xr_strcpy(ns, nsSize, GlobalNamespace);
p = name-1;
}
xr_strcpy(name_space, namespace_size, GlobalNamespace);
if (!J)
xr_strcpy(function, function_size, function_to_call);
else
{
CopyMemory (name_space,function_to_call, u32(J - function_to_call)*sizeof(char)) ;
name_space[u32(J - function_to_call)] = 0;
xr_strcpy(function, function_size, J + 1);
VERIFY(u32(p-name+1)<=nsSize);
strncpy(ns, name, p-name);
ns[p-name] = 0;
}
xr_strcpy(func, funcSize, p+1);
}

template<typename TResult>
Expand Down

0 comments on commit 3ed4224

Please sign in to comment.