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 0B1286EC5D; Wed, 7 Apr 2021 23:46:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0B1286EC5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617828363; bh=ux83z8+Li0fr2G/u9BAzy0pHaOI+IzrfnhjmeKjJtno=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Nv2EB+yeJFFyO+neMdMuelXZB0U5KtMYvAc6eM8oSmwJQva7uJyja0ZIbWYiDadfZ Yn4eOwz3d0dof1tOpnrIqq1NWOMrP+RXxZGs+s1J97yhasQnz2UONb1SUUMGZ3mjr/ 487wEuIEckvcK0tp2p0mDaU+/eHfq9lCKBd23JBc= Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id EDCEA6EC5D for ; Wed, 7 Apr 2021 23:46:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EDCEA6EC5D Received: by mail-lf1-f44.google.com with SMTP id g8so202574lfv.12 for ; Wed, 07 Apr 2021 13:46:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=OrML2uenXiF4/xTOIAMDHrksV2KBai7hxTmt7NBfExk=; b=pHPI02lt1qhKsG5QCqcYX9f8u/hgmX46G5H6+GADFPu65KI0vY7FaI14AqGSmR3whY V0sy11PSYxi64g32sSZUvEeF8ZpG8tjS85kblHvMgOS/g4/39cde+dQ66hx6tp6X7EyE Tbiq7+FzjSJVHC6JD0KVg1if+35dSu0ceRJUMcGFEo1DSx9sZy2srWHyU0xii1b5WecF u8WZq2eDAjXAck2PDZDBD+kqRRFylCgaJRsb29JtoyK0QMcOuaimf6CN0RLfP8E4O5Ii +2opXdKInzqQBWCKhm8ljXwLZPn3fjKUvmq10MW1ThGqFzPHMyQSX7iqTDy7svMktfN4 2lpA== X-Gm-Message-State: AOAM531hViltIk/7ssGfP36AGrILkVhYcMRveLjemo62cUQPwMwzq/wZ cuHS9rEJDntPir/daDT8+yrFbqs6e4s= X-Google-Smtp-Source: ABdhPJzq5D4uiCQdWRctSvSsBbaenXaf3Zja7QhcWmuCFxF+K4N2ZrePiUNETmuWeU19KEOrIQkwog== X-Received: by 2002:a19:2d5d:: with SMTP id t29mr1397309lft.243.1617828359781; Wed, 07 Apr 2021 13:45:59 -0700 (PDT) Received: from grain.localdomain ([5.18.199.94]) by smtp.gmail.com with ESMTPSA id a7sm2595261lfo.177.2021.04.07.13.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 13:45:58 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id CFAEF560152; Wed, 7 Apr 2021 23:45:57 +0300 (MSK) Date: Wed, 7 Apr 2021 23:45:57 +0300 To: Vladislav Shpilevoy Message-ID: References: <20210402123420.885834-1-gorcunov@gmail.com> <20210402123420.885834-7-gorcunov@gmail.com> <8d3a4d20-2887-7423-777f-2af808b65495@tarantool.org> <02f89e4e-70ff-215f-7cc4-3331adbb3c94@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.5 (2021-01-21) 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: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: tml Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Wed, Apr 07, 2021 at 11:37:15PM +0300, Cyrill Gorcunov wrote: ... > > If I don't lookup for key being some nonnil value in __index > (ie those 5 lines) then module:load simply stop working. As > far as I understand the __index is called when Lua looks up > for a key in table. It sends "load" there and since it is > in metatable it executes lbox_module_load_func as it should. > What I'm missing? Look into fiber code static const struct luaL_Reg lbox_fiber_meta [] = { ... {"__serialize", lbox_fiber_serialize}, {"__tostring", lbox_fiber_tostring}, {"join", lbox_fiber_join}, {"set_joinable", lbox_fiber_set_joinable}, {"wakeup", lbox_fiber_wakeup}, {"__index", lbox_fiber_index}, {NULL, NULL} }; static int lbox_fiber_index(struct lua_State *L) { if (lua_gettop(L) < 2) return 0; if (lua_isstring(L, 2) && strcmp(lua_tostring(L, 2), "storage") == 0) return lbox_fiber_storage(L); --> /* Get value from metatable */ lua_getmetatable(L, 1); lua_pushvalue(L, 2); lua_gettable(L, -2); return 1; } So I need to do the same Cyrill