Changeset 18252 for ext

Show
Ignore:
Timestamp:
10/01/07 06:02:24 (16 months ago)
Author:
Darren_Duncan
Message:

ext/Muldis-DB/ : the Muldis DB API now has users specify the AST language of interaction

Location:
ext/Muldis-DB
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • ext/Muldis-DB/Changes

    r18105 r18252  
    22--------------------------------------------------------------------------- 
    33 
    4 2007-09-22   Darren Duncan <perl@DarrenDuncan.net> 
    5  
    6     * Muldis DB version 0.4.0 for Perl 5 is released on CPAN as 
    7     Muldis-DB-0.4.0.tar.gz.  Muldis DB version 0.4.0 for Perl 6 is not 
     42007-10-xx   Darren Duncan <perl@DarrenDuncan.net> 
     5 
     6    * Muldis DB version 0.5.0 for Perl 5 is released on CPAN as 
     7    Muldis-DB-0.5.0.tar.gz.  Muldis DB version 0.5.0 for Perl 6 is not 
    88    released at this time, if ever, since it is currently released only as 
    99    part of the Perl6-Pugs project (in its ext/Muldis-DB/ subdirectory), 
    1010    which sets its own less frequent release schedule.  The rest of this 
    1111    Changes entry refers only to the Perl 5 version. 
     12 
     13    * New file versions are: DB.pm and Interface.pm and Validator.pm and 
     14    Example.pm 0.5.0.  The other pre-existing versioned files are 
     15    unchanged. 
     16 
     17    * (Interface.pm, Example.pm, Validator.pm)  Added a new attribute to 
     18    the DBMS role (and Example's doing class), "expected AST language", 
     19    with which Muldis DB users explicitly declare what Muldis DB (or 
     20    alternative) language version they expect to use for further 
     21    interaction with that DBMS.  The new_dbms constructor function gains a 
     22    parameter ('exp_ast_lang') for setting its default value, and the DBMS 
     23    role gains 2 methods for fetching/updating that attribute.  Note that, 
     24    unlike the engine_name and dbms_config parameters, exp_ast_lang is 
     25    generally not suited to read from a config file, as it is meant to 
     26    correspond to program code rather than a user's runtime setting.  The 
     27    &main of Validator.pm was updated to provide a hard-coded argument for 
     28    exp_ast_lang, which will be maintained in future releases at the latest 
     29    official Muldis D version number known to work at the time. 
     30 
     312007-09-22   Darren Duncan <perl@DarrenDuncan.net> 
     32 
     33    * Muldis DB version 0.4.0 for Perl 5 is released on CPAN as 
     34    Muldis-DB-0.4.0.tar.gz.  Muldis DB version 0.4.0 for Perl 6 is not 
     35    released at all.  The rest of this Changes entry refers only to the 
     36    Perl 5 version. 
    1237 
    1338    * This release is a snapshot to show a particular mid-way point in a 
  • ext/Muldis-DB/lib/Muldis/DB/Engine/Example.pm

    r18105 r18252  
    1313 
    1414sub new_dbms of Muldis::DB::Engine::Example::Public::DBMS 
    15         (Any :$dbms_config!) { 
     15        (Array :$exp_ast_lang!, Any :$dbms_config!) { 
    1616    return ::Muldis::DB::Engine::Example::Public::DBMS.new( 
    17         :dbms_config($dbms_config) ); 
     17        :exp_ast_lang($exp_ast_lang), :dbms_config($dbms_config) ); 
    1818} 
    1919 
     
    3636    # For the moment, the Example Engine doesn't actually have anything 
    3737    # that can be configured in this way, so input $dbms_config is ignored. 
     38    has Any $!exp_ast_lang; 
    3839    has Any $!dbms_config; 
    3940 
     
    5152########################################################################### 
    5253 
    53 submethod BUILD (Any :$dbms_config!) { 
    54  
    55     $!dbms_config = $dbms_config; 
     54submethod BUILD (Array :$exp_ast_lang!, Any :$dbms_config!) { 
     55 
     56    # TODO: input checks. 
     57    $!exp_ast_lang = [$exp_ast_lang.values]; 
     58    $!dbms_config  = $dbms_config; 
    5659 
    5760    $!assoc_vars          = {}; 
     
    6770    # TODO: check for active trans and rollback ... or member VM does it. 
    6871    # Likewise with closing open files or whatever. 
     72    return; 
     73} 
     74 
     75########################################################################### 
     76 
     77method fetch_exp_ast_lang of Array () { 
     78    return [$!exp_ast_lang.values]; 
     79} 
     80 
     81method store_exp_ast_lang (Array :$lang!) { 
     82    # TODO: input checks. 
     83    $!exp_ast_lang = [$lang.values]; 
    6984    return; 
    7085} 
     
    210225#    return $!var.as_phmd(); # TODO; or some such 
    211226} 
    212  
    213 ########################################################################### 
    214227 
    215228method store_ast (Array :$ast!) { 
  • ext/Muldis-DB/lib/Muldis/DB/Interface.pm

    r18105 r18252  
    1010 
    1111sub new_dbms of Muldis::DB::Interface::DBMS 
    12         (Str :$engine_name!, Any :$dbms_config!) { 
     12        (Str :$engine_name!, Array :$exp_ast_lang!, Any :$dbms_config!) { 
    1313 
    1414    die q{new_dbms(): Bad :$engine_name arg; it is not an object of a} 
     
    3737    my $dbms = undef; 
    3838    try { 
    39         $dbms = &::($engine_name)::new_dbms( :dbms_config($dbms_config) ); 
     39        $dbms = &::($engine_name)::new_dbms( 
     40            :exp_ast_lang($exp_ast_lang), :dbms_config($dbms_config) ); 
    4041    }; 
    4142    if (my $err = $!) { 
     
    6061role Muldis::DB::Interface::DBMS { 
    6162 
     63    method fetch_exp_ast_lang { 
     64        die q{not implemented by subclass } ~ self.WHAT; 
     65    } 
     66 
     67    method store_exp_ast_lang { 
     68        die q{not implemented by subclass } ~ self.WHAT; 
     69    } 
     70 
    6271    method new_var { 
    6372        die q{not implemented by subclass } ~ self.WHAT; 
     
    242251    my $dbms = Muldis::DB::Interface::new_dbms( 
    243252        :engine_name('Muldis::DB::Engine::Example'), 
     253        :exp_ast_lang([ 'MuldisD', 'cpan:DUNCAND', '0.8.1' ]), 
    244254        :dbms_config({}), 
    245255    ); 
     
    345355=over 
    346356 
    347 =item C<new_dbms of Muldis::DB::Interface::DBMS (Str :$engine_name!, Any 
    348 :$dbms_config!)> 
     357=item C<new_dbms of Muldis::DB::Interface::DBMS (Str :$engine_name!, Array 
     358:$exp_ast_lang!, Any :$dbms_config!)> 
    349359 
    350360This constructor function creates and returns a C<DBMS> object that is 
     
    358368role.  This function will start by testing if the root package is already 
    359369loaded (it may be declared by some already-loaded file of another name), 
    360 and only if not, will it do a Perl 'require' of the C<$engine_name>. 
     370and only if not, will it do a Perl 'require' of the C<$engine_name>.  The 
     371new C<DBMS> object's "expected AST language" attribute is initialized from 
     372the C<$exp_ast_lang> argument, which is a 3-element Array as described for 
     373the argument of the C<DBMS> method C<store_exp_ast_lang> (if applicable, 
     374the C<$dbms_config> argument is interpreted in light of C<$exp_ast_lang>). 
    361375 
    362376=back 
     
    374388 
    375389=over 
     390 
     391=item C<fetch_exp_ast_lang of Array ()> 
     392 
     393This method returns, as a 3-element (ordered) Array, the long name of the 
     394Muldis D (or alternative) language version that its invocant C<DBMS> object 
     395and its associated/child objects expect their AST/code/value input to 
     396conform to, and that their AST/code/value output will conform to.  The 3 
     397elements of the array (each a Str) are, in order, the language spec base 
     398name (typically C<MuldisD>), the language spec authority (typically 
     399C<cpan:DUNCAND> when the base name is C<MuldisD>), and the language spec 
     400version number (looks like C<1.2.3> for C<MuldisD> plus C<cpan:DUNCAND>). 
     401 
     402=item C<store_exp_ast_lang (Array :$lang!)> 
     403 
     404This method assigns a new expected language long name to its invocant 
     405C<DBMS>, which is supplied in the C<$lang> argument; the argument is 
     406expected to be a 3-element Array as described for C<fetch_exp_ast_lang>. 
     407This method dies if the specified language/version isn't one that the 
     408invocant's Engine knows how to or desires to handle. 
    376409 
    377410=item C<new_var of Muldis::DB::Interface::Var (Str :$decl_type!)> 
  • ext/Muldis-DB/lib/Muldis/DB/Validator.pm

    r18105 r18252  
    2020    # Instantiate a Muldis DB DBMS / virtual machine. 
    2121    my Muldis::DB::Interface::DBMS $dbms = Muldis::DB::Interface::new_dbms( 
    22         :engine_name($engine_name), :dbms_config($dbms_config) ); 
     22        :engine_name($engine_name), 
     23        :exp_ast_lang([ 'MuldisD', 'cpan:DUNCAND', '0.8.1' ]), 
     24        :dbms_config($dbms_config), 
     25    ); 
    2326    does_ok( $dbms, 'Muldis::DB::Interface::DBMS' ); 
    2427