DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
// Copyright (c) 2004 Daniel Wallin // 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. #include
#include
#include
#include
#include
namespace luabind { namespace detail { namespace { void add_operator_to_metatable(lua_State* L, int op_index) { lua_pushstring(L, get_operator_name(op_index)); lua_pushstring(L, get_operator_name(op_index)); lua_pushboolean(L, op_index == op_unm); lua_pushcclosure(L, &class_rep::operator_dispatcher, 2); lua_settable(L, -3); } int create_cpp_class_metatable(lua_State* L) { lua_newtable(L); // mark the table with our (hopefully) unique tag // that says that the user data that has this // metatable is a class_rep lua_pushstring(L, "__luabind_classrep"); lua_pushboolean(L, 1); lua_rawset(L, -3); lua_pushstring(L, "__gc"); lua_pushcclosure( L , &garbage_collector_s< detail::class_rep >::apply , 0); lua_rawset(L, -3); lua_pushstring(L, "__call"); lua_pushcclosure(L, &class_rep::constructor_dispatcher, 0); lua_rawset(L, -3); lua_pushstring(L, "__index"); lua_pushcclosure(L, &class_rep::static_class_gettable, 0); lua_rawset(L, -3); lua_pushstring(L, "__newindex"); lua_pushcclosure(L, &class_rep::lua_settable_dispatcher, 0); lua_rawset(L, -3); return detail::ref(L); } int create_cpp_instance_metatable(lua_State* L) { lua_newtable(L); // just indicate that this really is a class and not just // any user data lua_pushstring(L, "__luabind_class"); lua_pushboolean(L, 1); lua_rawset(L, -3); // __index and __newindex will simply be references to the // class_rep which in turn has it's own metamethods for __index // and __newindex lua_pushstring(L, "__index"); lua_pushcclosure(L, &class_rep::gettable_dispatcher, 0); lua_rawset(L, -3); lua_pushstring(L, "__newindex"); lua_pushcclosure(L, &class_rep::settable_dispatcher, 0); lua_rawset(L, -3); lua_pushstring(L, "__gc"); lua_pushcclosure(L, detail::object_rep::garbage_collector, 0); lua_rawset(L, -3); lua_pushstring(L, "__gettable"); lua_pushcclosure(L, &class_rep::static_class_gettable, 0); lua_rawset(L, -3); for (int i = 0; i < number_of_operators; ++i) add_operator_to_metatable(L, i); // store a reference to the instance-metatable in our class_rep assert((lua_type(L, -1) == LUA_TTABLE) && "internal error, please report"); return detail::ref(L); } int create_lua_class_metatable(lua_State* L) { lua_newtable(L); lua_pushstring(L, "__luabind_classrep"); lua_pushboolean(L, 1); lua_rawset(L, -3); lua_pushstring(L, "__gc"); lua_pushcclosure( L , &detail::garbage_collector_s< detail::class_rep >::apply , 0); lua_rawset(L, -3); lua_pushstring(L, "__newindex"); lua_pushcclosure(L, &class_rep::lua_settable_dispatcher, 0); lua_rawset(L, -3); lua_pushstring(L, "__call"); lua_pushcclosure(L, &class_rep::construct_lua_class_callback, 0); lua_rawset(L, -3); lua_pushstring(L, "__index"); lua_pushcclosure(L, &class_rep::static_class_gettable, 0); lua_rawset(L, -3); return detail::ref(L); } int create_lua_instance_metatable(lua_State* L) { lua_newtable(L); // just indicate that this really is a class and not just // any user data lua_pushstring(L, "__luabind_class"); lua_pushboolean(L, 1); lua_rawset(L, -3); lua_pushstring(L, "__index"); lua_pushcclosure(L, &class_rep::lua_class_gettable, 0); lua_rawset(L, -3); lua_pushstring(L, "__newindex"); lua_pushcclosure(L, &class_rep::lua_class_settable, 0); lua_rawset(L, -3); lua_pushstring(L, "__gc"); lua_pushcclosure(L, detail::object_rep::garbage_collector, 0); lua_rawset(L, -3); for (int i = 0; i < number_of_operators; ++i) add_operator_to_metatable(L, i); // store a reference to the instance-metatable in our class_rep return detail::ref(L); } int create_lua_function_metatable(lua_State* L) { lua_newtable(L); lua_pushstring(L, "__gc"); lua_pushcclosure( L , detail::garbage_collector_s< detail::free_functions::function_rep >::apply , 0); lua_rawset(L, -3); return detail::ref(L); } } // namespace unnamed class class_rep; class_registry::class_registry(lua_State* L) : m_cpp_instance_metatable(create_cpp_instance_metatable(L)) , m_cpp_class_metatable(create_cpp_class_metatable(L)) , m_lua_instance_metatable(create_lua_instance_metatable(L)) , m_lua_class_metatable(create_lua_class_metatable(L)) , m_lua_function_metatable(create_lua_function_metatable(L)) { } class_registry* class_registry::get_registry(lua_State* L) { #ifdef LUABIND_NOT_THREADSAFE // if we don't have to be thread safe, we can keep a // chache of the class_registry pointer without the // need of a mutex static lua_State* cache_key = 0; static class_registry* registry_cache = 0; if (cache_key == L) return registry_cache; #endif lua_pushstring(L, "__luabind_classes"); lua_gettable(L, LUA_REGISTRYINDEX); class_registry* p = static_cast
(lua_touserdata(L, -1)); lua_pop(L, 1); #ifdef LUABIND_NOT_THREADSAFE cache_key = L; registry_cache = p; #endif return p; } void class_registry::add_class(LUABIND_TYPE_INFO info, class_rep* crep) { // class is already registered assert((m_classes.find(info) == m_classes.end()) && "you are trying to register a class twice"); m_classes[info] = crep; } class_rep* class_registry::find_class(LUABIND_TYPE_INFO info) const { std::map
::const_iterator i( m_classes.find(info)); if (i == m_classes.end()) return 0; // the type is not registered return i->second; } }} // namespace luabind::detail
class_registry.cpp
Page URL
File URL
Prev
3/21
Next
Download
( 8 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.