Skip to content

Commit

Permalink
Add set_package_preload().
Browse files Browse the repository at this point in the history
Conflicts:
	src/CMakeLists.txt
  • Loading branch information
rpavlik authored and Oberon00 committed Jun 29, 2013
1 parent 61e8e8f commit 3502e9c
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
54 changes: 54 additions & 0 deletions luabind/set_package_preload.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/** @file
@brief Header
@date 2012
@author
Ryan Pavlik
<[email protected]> and <[email protected]>
http://academic.cleardefinition.com/
Iowa State University Virtual Reality Applications Center
Human-Computer Interaction Graduate Program
*/

// Copyright Iowa State University 2012.
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.

#pragma once
#ifndef INCLUDED_set_package_preload_hpp_GUID_563c882e_86f7_4ea7_8603_4594ea41737e
#define INCLUDED_set_package_preload_hpp_GUID_563c882e_86f7_4ea7_8603_4594ea41737e

// Internal Includes
#include <luabind/config.hpp>
#include <luabind/lua_state_fwd.hpp>

// Library/third-party includes
// - none

// Standard includes
// - none


namespace luabind {

LUABIND_API void set_package_preload(lua_State * L, const char * modulename, int (*loader) (lua_State *));
}
#endif // INCLUDED_set_package_preload_hpp_GUID_563c882e_86f7_4ea7_8603_4594ea41737e
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(luabind_SRCS
open.cpp
pcall.cpp
scope.cpp
set_package_preload.cpp
stack_content_by_name.cpp
weak_ref.cpp
wrapper_base.cpp)
Expand Down Expand Up @@ -54,6 +55,7 @@ set(luabind_HDRS
../luabind/raw_policy.hpp
../luabind/return_reference_to_policy.hpp
../luabind/scope.hpp
../luabind/set_package_preload.hpp
../luabind/shared_ptr_converter.hpp
../luabind/tag_function.hpp
../luabind/typeid.hpp
Expand Down
55 changes: 55 additions & 0 deletions src/set_package_preload.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
@file
@brief Implementation
@date 2012
@author
Ryan Pavlik
<[email protected]> and <[email protected]>
http://academic.cleardefinition.com/
Iowa State University Virtual Reality Applications Center
Human-Computer Interaction Graduate Program
*/

// Copyright Iowa State University 2012.
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.

// Internal Includes
#include <luabind/set_package_preload.hpp>
#include <luabind/object.hpp>

// Library/third-party includes
// - none

// Standard includes
// - none


namespace luabind {
LUABIND_API void set_package_preload(lua_State * L, const char * modulename, int (*loader) (lua_State *)) {
rawget(rawget(globals(L), "package"), "preload").push(L);
lua_pushcclosure(L, loader, 0);
lua_setfield(L, -2, modulename);
lua_pop(L, 1);
}

} // namespace luabind

0 comments on commit 3502e9c

Please sign in to comment.