From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 09A2E6EC5D; Wed, 7 Apr 2021 23:28:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 09A2E6EC5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617827293; bh=c/spTfG7rRaz+Phtx0GFAv3jmzI7WmKraH4EHrEcch8=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=koLlzD7LUhYrYa8spesvCwGIDBUxiCSQ4Y6FnHFhf+UNq03ThKMTOndguyXHSaB3E mZ3IKufJ3BlB7qodZ9hUjJBlzdqIIMcHSRVG8nmXcXNvU0zdhchcNo+xd5MJiBaGCy vG6fRv8hlNNqXErgcDc2lXB4Mc/nLVGqMGkeC99A= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 726426EC5D for ; Wed, 7 Apr 2021 23:28:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 726426EC5D Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lUEmY-0002zY-95; Wed, 07 Apr 2021 23:28:10 +0300 To: Cyrill Gorcunov References: <20210402123420.885834-1-gorcunov@gmail.com> <20210402123420.885834-7-gorcunov@gmail.com> <8d3a4d20-2887-7423-777f-2af808b65495@tarantool.org> Message-ID: <02f89e4e-70ff-215f-7cc4-3331adbb3c94@tarantool.org> Date: Wed, 7 Apr 2021 22:28:09 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD912A3E3D5D4B49FC1FEA0A53B931EDD909DE4D58F47F062C400894C459B0CD1B970E92FD7D50119B861A9C4114E932D9C5785AA4462FB9458D1FFACA8F48D2A96 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B264C8851FD8E810EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AA32F0A5ADCF96E68638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B289D6DF4199A6F264D0CE018C00935140F04B652EEC242312D2E47CDBA5A96583C09775C1D3CA48CF17B107DEF921CE79117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE767883B903EA3BAEA9FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA71A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B156CCFE7AF13BCA4B5C8C57E37DE458BEDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978312AD2F7AEC48577FFE78E5B5B57A3F822 X-C1DE0DAB: 0D63561A33F958A52E859892244A42537DE6828AFA675B7261BEE37B89349652D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3450C5E6D685282BA16487D1D330E1B03F2F7B3A7A477C9858293C62D782BFDE2C4C9B9BDD348D92921D7E09C32AA3244C2D5336050C71517E7A07D8B8FE1C89A405AB220A9D022EBC927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioju+jaMfvANXrrIMzshk8l1w== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822327C6779034FD1B81F807D5D51BBB7783841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v20 6/7] box: implement box.lib module X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Cc: tml Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On 07.04.2021 22:22, Cyrill Gorcunov wrote: > On Wed, Apr 07, 2021 at 07:59:35PM +0300, Cyrill Gorcunov wrote: >>>> +/** Handle __index request for a module object. */ >>>> +static int >>>> +lbox_module_index(struct lua_State *L) >>>> +{ >>>> + lua_getmetatable(L, 1); >>>> + lua_pushvalue(L, 2); >>>> + lua_rawget(L, -2); >>>> + if (!lua_isnil(L, -1)) >>>> + return 1; >>> >>> 6. What is happening here in these 5 lines? >> >> Actually this snippet comes from popen code where >> we have wrappers on lua level and test for metamethods. >> While it doesn't hurt it makes no much sense in current >> code, thanks! Will drop. > > Heh, in real we need these to handle metamethods such as > "module:load". I added a comment into the code. For methods you need to use the metatype. It is defined as luaL_register_type(), where you can add methods, not just __index. The latter is more for, well, indexing. Getting an attribute, for example. See an example in lua/popen.c. Methods should not end up in __index.