Пример #1
0
void CCallStackDlg::Update()
{
	m_list.DeleteAllItems();

	LuaState* state = theApp.GetDocument()->GetState();

	LuaObject callStackTableObj = state->GetGlobals()[ "CallStack" ];
	if (callStackTableObj.IsTable())
	{
		int index = 1;
		while (true)
		{
			LuaObject callTableObj = callStackTableObj.GetByIndex(index++);
			if (callTableObj.IsNil())
				break;
			LuaObject nameObj = callTableObj.GetByIndex(1);
			LuaObject typeObj = callTableObj.GetByIndex(2);
			LuaObject lineNumberObj = callTableObj.GetByIndex(3);

			CString str;
			if (lineNumberObj.GetInteger() != -1)
				str.Format(_T(" line %d"), lineNumberObj.GetInteger());
			str = nameObj.GetString() + str + _T(" (") + typeObj.GetString() + _T(")");
			m_list.InsertItem(m_list.GetItemCount(), str);
		}
	}
}
Пример #2
0
void ScriptFunctionsRegister(struct lua_State* L)
{
	LuaState* state = lua_State_To_LuaState(L);
	LuaObject globalsObj = state->GetGlobals();
	globalsObj.Register("GetTickCount",		LS_GetTickCount);

#if defined(_MSC_VER)  &&  defined(WIN32)  &&  !defined(_XBOX)  &&  !defined(_XBOX_VER)  &&  !defined(PLATFORM_PS3)
#elif defined(__APPLE__)
	char modulePath[MAXPATHLEN + 1];
	unsigned int path_len = MAXPATHLEN;
    _NSGetExecutablePath(modulePath, &path_len);
	char* slashPtr = strrchr(modulePath, '/');
	slashPtr++;
	*slashPtr = 0;
#endif // _MSC_VER

    state->GetGlobals().Register("LuaDumpGlobals", LS_LuaDumpGlobals);
	state->GetGlobals().Register("LuaDumpObject", LS_LuaDumpObject);
	state->GetGlobals().Register("LuaDumpFile", LS_LuaDumpFile);
}
Пример #3
0
extern "C" LUAMODULE_API int luaopen_dotnet(lua_State* L)
{
	LuaState* state = LuaState::CastState(L);
	LuaObject obj = state->GetGlobals()["dotnet"];
	if (obj.IsTable())
		return 0;

	obj = state->GetGlobals().CreateTable( "dotnet" );

	char path[ _MAX_PATH ];
#ifdef _DEBUG
	const char* dllName = "ldotnet.dlld";
#else !_DEBUG
	const char* dllName = "ldotnet.dll";
#endif _DEBUG
	GetModuleFileName(GetModuleHandle(dllName), path, _MAX_PATH);
	char* slashPtr = strrchr( path, '\\' );
	slashPtr++;
	*slashPtr = 0;
#ifdef _DEBUG
	strcat(path, "Debug\\");
#endif _DEBUG
	strcat(path, "dotnetinterface.dll");

	Assembly* assembly = Assembly::LoadFrom(path);
	Type* type = assembly->GetType("LuaInterface.Lua");
	Object* parms[] = new Object*[1];
	parms[0] = __box((IntPtr)state->GetCState());
	Object* lua = Activator::CreateInstance(type, parms);

	LuaObject metaTableObj;
	metaTableObj.AssignNewTable(state);
	metaTableObj.Register("__gc", GCHandle_gc);

	LuaObject dotNetObj = state->NewUserDataBox((void*)(GCHandle::op_Explicit(GCHandle::Alloc(lua))).ToInt32());
	dotNetObj.SetMetaTable(metaTableObj);

	obj.SetObject("__dotNetUserData", dotNetObj);

	return 0;
}
Пример #4
0
int main(int argc, char** argv)
{
	LuaState* pstate = LuaState::Create(true);	

	pstate->GetGlobals().Register("TestFunc", TestFunc);	

	const char* szCmd = "TestFunc('hahhahhahh');";
	pstate->DoString(szCmd);

	LuaState::Destroy(pstate);
	return 0;
}
Пример #5
0
extern "C" LUAMODULE_API int luaopen_bit(lua_State* L)
{
	LuaState* state = LuaState::CastState(L);
	LuaObject obj = state->GetGlobals().CreateTable( "bit" );
	obj.Register("bnot", int_bnot);
	obj.Register("band", int_band);
	obj.Register("bor", int_bor);
	obj.Register("bxor", int_bxor);
	obj.Register("lshift", int_lshift);
	obj.Register("rshift", int_rshift);
	obj.Register("arshift", int_arshift);
	obj.Register("mod", int_mod);
	obj.Register("help", LS_help);
	return 0;
}
Пример #6
0
extern "C" LUAMODULE_API int luaopen_vdrive(lua_State* L)
{
	LuaState* state = LuaState::CastState(L);

	LuaObject metaTableObj = state->GetRegistry().CreateTable("VDriveFileHandleMetaTable");
	metaTableObj.Register("__gc",			VirtualFileHandle_gc);

	metaTableObj = state->GetRegistry().CreateTable("VDriveMetaTable");
	metaTableObj.Register("Create",				LS_VirtualDrive_Create);
	metaTableObj.Register("Open",				LS_VirtualDrive_Open);
	metaTableObj.Register("Close",				LS_VirtualDrive_Close);
	metaTableObj.Register("Flush",				LS_VirtualDrive_Flush);
	metaTableObj.Register("FileCreate",			LS_VirtualDrive_FileCreate);
	metaTableObj.Register("FileOpen",			LS_VirtualDrive_FileOpen);
	metaTableObj.Register("FileClose",			LS_VirtualDrive_FileClose);
	metaTableObj.Register("FileCloseAll",		LS_VirtualDrive_FileCloseAll);
	metaTableObj.Register("FileGetFileName",    LS_VirtualDrive_FileGetFileName);
	metaTableObj.Register("FileGetPosition",    LS_VirtualDrive_FileGetPosition);
	metaTableObj.Register("FileSetLength",      LS_VirtualDrive_FileSetLength);
	metaTableObj.Register("FileGetLength",      LS_VirtualDrive_FileGetLength);
	metaTableObj.Register("FileRead",           LS_VirtualDrive_FileRead);
	metaTableObj.Register("FileWrite",          LS_VirtualDrive_FileWrite);
    metaTableObj.Register("FileErase",			LS_VirtualDrive_FileErase);
	metaTableObj.Register("FileRename",			LS_VirtualDrive_FileRename);
	metaTableObj.Register("FileInsert",			LS_VirtualDrive_FileInsert);
	metaTableObj.Register("FileExtract",		LS_VirtualDrive_FileExtract);
	metaTableObj.Register("Pack",				LS_VirtualDrive_Pack);
	metaTableObj.Register("ProcessFileList",	LS_VirtualDrive_ProcessFileList);
	metaTableObj.Register("GetFileName",		LS_VirtualDrive_GetFileName);
	metaTableObj.Register("GetFileEntryCount",	LS_VirtualDrive_GetFileEntryCount);
	metaTableObj.Register("GetFileEntry",		LS_VirtualDrive_GetFileEntry);
	metaTableObj.Register("FindFileEntry",		LS_VirtualDrive_FindFileEntry);
	metaTableObj.Register("GetFileEntryIndex",	LS_VirtualDrive_GetFileEntryIndex);
	metaTableObj.Register("__gc",				VirtualDrive_gc);
	metaTableObj.SetObject("__index",			metaTableObj);

	LuaObject obj = state->GetGlobals().CreateTable( "vdrive" );
	obj.Register("VirtualDrive", LS_VirtualDrive);
	obj.Register("AdjustTime_t", LS_AdjustTime_t);
	obj.Register("help", LS_Help);
	obj.Register("crc32", LS_crc32);
	return 0;
}
Пример #7
0
extern "C" LUAMODULE_API int luaopen_iox(lua_State* L)
{
	LuaState* state = LuaState::CastState(L);
	LuaObject ioxObj = state->GetGlobals().CreateTable("iox");
	ioxObj.RegisterDirect("PathCreate", PathCreate);
	ioxObj.RegisterDirect("PathDestroy", PathDestroy);
	ioxObj.RegisterDirect("CreateDirectory", PathCreate);
	ioxObj.RegisterDirect("RemoveDirectory", PathDestroy);
	ioxObj.Register("GetCurrentDirectory", LS_GetCurrentDirectory);
	ioxObj.Register("SetCurrentDirectory", LS_SetCurrentDirectory);

	ioxObj.Register("PathAddBackslash", LS_PathAddBackslash);
	ioxObj.Register("PathAddExtension", LS_PathAddExtension);
	ioxObj.Register("PathAppend", LS_PathAppend);
    ioxObj.Register("PathCanonicalize", LS_PathCanonicalize);
	ioxObj.Register("PathCombine", LS_PathCombine);
	ioxObj.Register("PathCommonPrefix", LS_PathCommonPrefix);
	ioxObj.Register("PathFileExists", LS_PathFileExists);
	ioxObj.Register("PathFindExtension", LS_PathFindExtension);
	ioxObj.Register("PathFindFileName", LS_PathFindFileName);
	ioxObj.Register("PathFindNextComponent", LS_PathFindNextComponent);
	ioxObj.Register("PathFindOnPath", LS_PathFindOnPath);
	ioxObj.Register("PathGetArgs", LS_PathGetArgs);
	ioxObj.Register("PathIsDirectory", LS_PathIsDirectory);
	ioxObj.Register("PathIsDirectoryEmpty", LS_PathIsDirectoryEmpty);
	ioxObj.Register("PathIsFileSpec", LS_PathIsFileSpec);
	ioxObj.Register("PathIsHTMLFile", LS_PathIsHTMLFile);
	ioxObj.Register("PathIsLFNFileSpec", LS_PathIsLFNFileSpec);
	ioxObj.Register("PathIsNetworkPath", LS_PathIsNetworkPath);
	ioxObj.Register("PathIsPrefix", LS_PathIsPrefix);
	ioxObj.Register("PathIsRelative", LS_PathIsRelative);
	ioxObj.Register("PathIsRoot", LS_PathIsRoot);
	ioxObj.Register("PathIsSameRoot", LS_PathIsSameRoot);
	ioxObj.Register("PathIsSystemFolder", LS_PathIsSystemFolder);
	ioxObj.Register("PathIsUNC", LS_PathIsUNC);
	ioxObj.Register("PathIsUNCServer", LS_PathIsUNCServer);
	ioxObj.Register("PathIsUNCServerShare", LS_PathIsUNCServerShare);
	ioxObj.Register("PathIsURL", LS_PathIsURL);
	ioxObj.Register("PathMakePretty", LS_PathMakePretty);
	ioxObj.Register("PathMakeSystemFolder", LS_PathMakeSystemFolder);
	ioxObj.Register("PathMatchSpec", LS_PathMatchSpec);
	ioxObj.Register("PathQuoteSpaces", LS_PathQuoteSpaces);
	ioxObj.Register("PathRelativePathTo", LS_PathRelativePathTo);
	ioxObj.Register("PathRemoveArgs", LS_PathRemoveArgs);
	ioxObj.Register("PathRemoveBackslash", LS_PathRemoveBackslash);
	ioxObj.Register("PathRemoveBlanks", LS_PathRemoveBlanks);
	ioxObj.Register("PathRemoveExtension", LS_PathRemoveExtension);
	ioxObj.Register("PathRemoveFileSpec", LS_PathRemoveFileSpec);
	ioxObj.Register("PathRenameExtension", LS_PathRenameExtension);
	ioxObj.Register("PathSearchAndQualify", LS_PathSearchAndQualify);
	ioxObj.Register("PathSkipRoot", LS_PathSkipRoot);
	ioxObj.Register("PathStripPath", LS_PathStripPath);
	ioxObj.Register("PathStripToRoot", LS_PathStripToRoot);
	ioxObj.Register("PathUndecorate", LS_PathUndecorate);
	ioxObj.Register("PathUnExpandEnvStrings", LS_PathUnExpandEnvStrings);
	ioxObj.Register("PathUnmakeSystemFolder", LS_PathUnmakeSystemFolder);
	ioxObj.Register("PathUnquoteSpaces", LS_PathUnquoteSpaces);
	
	ioxObj.Register("PathMakeAbsolute", LS_PathMakeAbsolute);
	ioxObj.Register("PathMakeBackSlash", LS_PathMakeBackSlash);
	ioxObj.Register("PathMakeForwardSlash", LS_PathMakeForwardSlash);

	ioxObj.Register("FindFirstFile",		LS_FindFirstFile);
	ioxObj.Register("FindNextFile",			LS_FindNextFile);
	ioxObj.Register("FindClose",			LS_FindClose);
	ioxObj.Register("FindGetFileName",		LS_FindGetFileName);
	ioxObj.Register("FindIsDirectory",		LS_FindIsDirectory);
	ioxObj.Register("FindGetLastWriteTime",	LS_FindGetLastWriteTime);
	ioxObj.Register("GetFileSize",			LS_GetFileSize);
	ioxObj.Register("access",				LS_access);

	ioxObj.Register("CopyFile",				LS_CopyFile);
	ioxObj.Register("DeleteFile",			LS_DeleteFile);
	ioxObj.Register("GetWriteTime",			LS_GetFileWriteTime);
	ioxObj.Register("SetWriteTime",			LS_SetFileWriteTime);
	ioxObj.Register("MakeWritable",			LS_MakeWritable);

	ioxObj.Register("Sleep",				LS_Sleep);
	ioxObj.Register("FileTimeToTime_t",		LS_FileTimeToTime_t);

	ioxObj.Register("LoadLibrary",			LS_LoadLibrary);
	ioxObj.Register("FreeLibrary",			LS_FreeLibrary);

	return 0;
}