Return-Path: X-Original-To: apmail-lucy-dev-archive@www.apache.org Delivered-To: apmail-lucy-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D87D59F0A for ; Thu, 12 Apr 2012 04:11:24 +0000 (UTC) Received: (qmail 55214 invoked by uid 500); 12 Apr 2012 04:11:24 -0000 Delivered-To: apmail-lucy-dev-archive@lucy.apache.org Received: (qmail 55105 invoked by uid 500); 12 Apr 2012 04:11:23 -0000 Mailing-List: contact dev-help@lucy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucy.apache.org Delivered-To: mailing list dev@lucy.apache.org Received: (qmail 55058 invoked by uid 99); 12 Apr 2012 04:11:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 04:11:22 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.213.179] (HELO mail-yx0-f179.google.com) (209.85.213.179) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 04:11:14 +0000 Received: by yenl1 with SMTP id l1so867000yen.10 for ; Wed, 11 Apr 2012 21:10:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:x-gm-message-state; bh=7Ods0uo6KoU6M/crpXO3o5CYRo4naPt/22w8JqPKL3k=; b=SuxXojbiiKpP08rtSaiMdzqI/JPxMifa0qhq/NHS9AmssdNl1nTX12jUx14dE7CtJe MvF7or8IdkJ49wY2vQuuKM6UJXPCfZiCN89sC88S+neLDGIYdNpOUURv32OEyjpWiJ0L fIXXG6jujTIOYb9hvU7pNKyNpbZLkRk05/Kbuv0vEMLrt5P5Ibh7hzXkGqZa/yxMXyMo hEmMBvgxrri7pPnz+Oy1ZuHRqEKzchsra4FTwXi4lLTm2vYynzL9K+QiIuxYSk89mRIf xweZbjMLWbMngL+qHtmTkW10mRPUQmdDDrj9Hij8uLTKUy6WzYRAkQbcGmQEnWgdtLdZ /ecw== MIME-Version: 1.0 Received: by 10.50.202.35 with SMTP id kf3mr1169594igc.10.1334203851982; Wed, 11 Apr 2012 21:10:51 -0700 (PDT) Received: by 10.142.115.3 with HTTP; Wed, 11 Apr 2012 21:10:51 -0700 (PDT) X-Originating-IP: [99.46.94.139] In-Reply-To: <4F85C209.6030800@aevum.de> References: <4F6F6F2A.1030904@aevum.de> <4F848357.5050704@aevum.de> <4F85C209.6030800@aevum.de> Date: Wed, 11 Apr 2012 21:10:51 -0700 Message-ID: From: Marvin Humphrey To: dev@lucy.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQldxn3NGleuG3azHh22UtFkLgvVDEd/bADgTxKfcJ77Msd6Tp2z5VGJY5W6x7vXiUfzJr92 Subject: Re: [lucy-dev] Hiding struct defs On Wed, Apr 11, 2012 at 10:40 AM, Nick Wellnhofer wrote: > On 11/04/2012 19:09, Marvin Humphrey wrote: >>> I also tried to malloc the VTables dynamically, but this broke >>> RAWPOSTING_BLANK where a VTable is used to initialize a global struct. >> >> I've just committed a change that kills off RAWPOSTING_BLANK. >> >> I suspect that the ZombieCharBuf EMPTY is also going to get in your way; >> I'll look into deep-sixing that one later today. >> >> There may be others; we'll just address them one-by-one until we can malloc >> dynamically. > > > OK. Several of these are now gone. A couple known instances remain. >From core/Lucy/Object/Hash.c: static HashTombStone TOMBSTONE = { HASHTOMBSTONE, {1} }; >From core/Lucy/Object/Num.c: static ViewCharBuf true_string = { VIEWCHARBUF, {1}, "true", 4, 0 }; static ViewCharBuf false_string = { VIEWCHARBUF, {1}, "false", 5, 0 }; static BoolNum true_obj = { BOOLNUM, {1}, true, &true_string }; static BoolNum false_obj = { BOOLNUM, {1}, false, &false_string }; What I would really like to do with those is initialize them during the per-class bootstrapping you've been coding up. To achieve this, I imagine that we could store a bootstrapping routine as a global function in the per-class autogenerated .h files, enabled with a pound-define. Something like this... In autogen/Lucy/Object/Hash.h: #ifdef LUCY_HASH_WANT_BOOT void lucy_Hash_bootstrap(void) { // ... LUCY_HASH = cfish_VTable_bootstrap(LUCY_HASH, LUCY_OBJ, "Lucy::Object::Hash", obj_alloc_size, x, size, callbacks, methods); #ifdef LUCY_HASH_AUX_BOOT LUCY_HASH_AUX_BOOT(); #endif return LUCY_HASH; } #endif // LUCY_HASH_WANT_BOOT In core/Lucy/Object/Hash.c: #define LUCY_HASH_WANT_BOOT #define LUCY_HASHTOMBSTONE_WANT_BOOT #define LUCY_HASHTOMBSTONE_AUX_BOOT S_tombstone_aux_boot #include "Lucy/Object/Hash.h" static void S_tombstone_aux_boot(void) { TOMBSTONE.vtable = HASHTOMBSTONE; TOMBSTONE.ref.count = 1; } That's kind of messy, but do you see where I'm going with this? Each class gets an optional bootstrapping routine that it can hook into to do whatever it wants. The punchline is that I believe we will ultimately be able to hide all of our method implementations by making them static. If we can pull that off, it will help us in two ways: 1. It will cut down significantly on the number of exported symbols the dynamic linker has to deal with. 2. It will make it impossible for a user to make the mistake of invoking the implementing function instead of the method through accidental miscapitalization (as multiple Lucy PMC members have done when starting out.) Marvin Humphrey