Commit f9f47a855808bb555d600feae53efe4228d727b9

  • avatar
  • Duke Leto <jonathan @le…o.net>
  • Tue Nov 03 08:11:12 CET 2009
Attempt to convert over to nqp-rx-friendly POD. Something is still wrong, though
  
11# Copyright (C) 2009, Parrot Foundation.
22# $Id$
33
4=begin
5
46=head1 NAME
57
68wget.pir - HTTP client
1717
1818This is a very thin wrapper around Plumage::Downloader::save_url_to_file
1919
20=cut
20=end
2121
2222.sub 'main' :main
2323 .param pmc argv
  
22
33Glue.pir - Rakudo "glue" builtins (functions/globals) converted for NQP
44
5=begin
56
67=head1 SYNOPSIS
78
6262 our $OSVER;
6363
6464
65=cut
65=end
6666
6767.namespace []
6868
7070.include 'sysinfo.pasm'
7171.include 'iglobals.pasm'
7272
73=begin
7374
7475=head1 DESCRIPTION
7576
8484the status code of the spawned process, which is equal the the result
8585of the waitpid system call, right bitshifted by 8.
8686
87=cut
87=end
8888
8989.sub 'run'
9090 .param pmc command_and_args :slurpy
9999 .return (status)
100100.end
101101
102=begin
102103
103104=item $success := do_run($command, $and, $args, ...)
104105
107107arguments as a new process; return 1 if the process exited successfully, or
1081080 if not.
109109
110=cut
110=end
111111
112112.sub 'do_run'
113113 .param pmc command_and_args :slurpy
125125 .return (0)
126126.end
127127
128=begin
128129
129130=item $output := qx($command, $and, $args, ...)
130131
134134
135135B<WARNING>: Parrot currently implements this B<INSECURELY>!
136136
137=cut
137=end
138138
139139.sub 'qx'
140140 .param pmc command_and_args :slurpy
159159 die $S0
160160.end
161161
162=begin
162163
163164=item die($message)
164165
165166Kill program, reporting error C<$message>.
166167
167=cut
168=end
168169
169170.sub 'die'
170171 .param string message
173173 die message
174174.end
175175
176=begin
176177
177178=item $ret := try(&code, @args [, &handler])
178179
186186 catch($ex) { $ret := &handler ?? &handler($ex, &code, @args) !! 0 }
187187 return $ret;
188188
189=cut
189=end
190190
191191.sub 'try'
192192 .param pmc code
211211 .return (0)
212212.end
213213
214=begin
214215
215216=item @keys := keys(%hash)
216217
217218Return an array containing the keys of the C<%hash>.
218219
219=cut
220=end
220221
221222.sub 'keys'
222223 .param pmc hash
238238 .return(key_list)
239239.end
240240
241=begin
241242
242243=item $found := exists(%hash, $key)
243244
244245Determine if C<$key> exists in C<%hash>, returning a true value if so, and a
245246false value if not.
246247
247=cut
248=end
248249
249250.sub 'exists'
250251 .param pmc hash
256256 .return($I0)
257257.end
258258
259=begin
259260
260261=item $does_role := does($object, $role)
261262
262263Determine if C<$object> does the C<$role>, returning a true value if so, and a
263264false value if not.
264265
265=cut
266=end
266267
267268.sub 'does'
268269 .param pmc object
274274 .return($I0)
275275.end
276276
277=begin
277278
278279=item $contents := slurp($filename)
279280
280281Read the C<$contents> of a file as a single string.
281282
282=cut
283=end
283284
284285.sub 'slurp'
285286 .param string filename
292292 .return(contents)
293293.end
294294
295=begin
295296
296297=item spew($filename, $contents)
297298
298299Write the string C<$contents> to a file.
299300
300=cut
301=end
301302
302303.sub 'spew'
303304 .param string filename
309309 close $P0
310310.end
311311
312=begin
312313
313314=item append($filename, $contents)
314315
315316Append the string C<$contents> to a file.
316317
317=cut
318=end
318319
319320.sub 'append'
320321 .param string filename
326326 close $P0
327327.end
328328
329=begin
329330
330331=item $regex_object := rx($regex_source)
331332
334334Perl 6 Regex) into a C<$regex_object>, suitable for using in C<match()> and
335335C<subst()>.
336336
337=cut
337=end
338338
339339.sub 'rx'
340340 .param string source
346346 .return(object)
347347.end
348348
349=begin
350
349351=item @matches := all_matches($regex, $text)
350352
351353Find all matches (C<:g> style, not C<:exhaustive>) for C<$regex> in the
352354C<$text>. The C<$regex> must be a regex object returned by C<rx()>.
353355
354=cut
356=end
355357
356358.sub 'all_matches'
357359 .param pmc regex
378378 .return(matches)
379379.end
380380
381=begin
381382
382383=item $edited := subst($original, $regex, $replacement)
383384
390390with each match object in turn, and must return the proper replacement string
391391for that match.
392392
393=cut
393=end
394394
395395.sub 'subst'
396396 .param string original
438438 .return(edited)
439439.end
440440
441=begin
442
441443=item chdir($path)
442444
443445Change the current working directory to the specified C<$path>.
444446
445=cut
447=end
446448
447449.sub 'chdir'
448450 .param string path
454454 os.'chdir'(path)
455455.end
456456
457=begin
458
457459=item $path := cwd()
458460
459461Return the current working directory.
460462
461=cut
463=end
462464
463465.sub 'cwd'
464466 .local pmc os
472472 .return(path)
473473.end
474474
475=begin
476
475477=item mkdir($path [, $mode])
476478
477479Create a directory specified by C<$path> with mode C<$mode>. C<$mode> is
478480optional and defaults to octal C<777> (full permissions) if absent. C<$mode>
479481is modified by the user's current C<umask> as usual.
480482
481=cut
483=end
482484
483485.sub 'mkdir'
484486 .param string path
496496 os.'mkdir'(path, mode)
497497.end
498498
499=begin
500
499501=item unlink($path)
500502
501503Unlink (delete) a file or empty directory named C<$path> in the filesystem.
502504
503=cut
505=end
504506
505507.sub 'unlink'
506508 .param string path
512512 os.'rm'(path)
513513.end
514514
515=begin
516
515517=item @info := stat($path)
516518
517519Returns a 13-item list of information about the given C<$path>, as in Perl 5.
518520(See C<perldoc -f stat> for more details.)
519521
520=cut
522=end
521523
522524.sub 'stat'
523525 .param string path
531531 .return (stat_list)
532532.end
533533
534=begin
535
534536=item $found := path_exists($path);
535537
536538Return a true value if the C<$path> exists on the filesystem, or a false
537539value if not.
538540
539=cut
541=end
540542
541543.sub 'path_exists'
542544 .param string path
554554 .return (0)
555555.end
556556
557=begin
558
557559=item @names := readdir($directory)
558560
559561List the names of all entries in the C<$directory>.
560562
561=cut
563=end
562564
563565.sub 'readdir'
564566 .param string dir
572572 .return (names)
573573.end
574574
575=begin
576
575577=item $path := fscat(@path_parts [, $filename])
576578
577579Join C<@path_parts> and C<$filename> strings together with the appropriate
581581trailing slash (though slashes inside the C<@path_parts> will not be removed,
582582so don't do that).
583583
584=cut
584=end
585585
586586.sub 'fscat'
587587 .param pmc parts
604604 .return (joined)
605605.end
606606
607=begin
608
607609=item $joined := join($delimiter, @strings)
608610
609611Join C<@strings> together with the specified C<$delimiter>.
610612
611=cut
613=end
612614
613615.sub 'join'
614616 .param string delim
622622 .return (joined)
623623.end
624624
625=begin
626
625627=item @pieces := split($delimiter, $original)
626628
627629Split the C<$original> string with the specified C<$delimiter>, which is not
628630included in the resulting C<@pieces>.
629631
630=cut
632=end
631633
632634.sub 'split'
633635 .param string delim
641641 .return (pieces)
642642.end
643643
644=begin
644645
645646=item @array := as_array($list, $of, $items, ...)
646647
647648Slurp the list of arguments into an array and return it.
648649
649=cut
650=end
650651
651652.sub 'as_array'
652653 .param pmc items :slurpy
655655 .return (items)
656656.end
657657
658=begin
658659
659660=item $result := call_flattened(&code, $mixed, @args, $list, ...)
660661
669669
670670 call_flattened(&code, as_array(@protected), @will_flatten)
671671
672=cut
672=end
673673
674674.sub 'call_flattened'
675675 .param pmc code
698698 .tailcall code(flattened :flat)
699699.end
700700
701=begin
702
701703=back
702704
703705
733733
734734=back
735735
736=cut
736=end
737737
738738.sub 'onload' :anon :load :init
739739 load_bytecode 'config.pbc'
  
22
33Metadata.nqp - Metadata-handling functions for Plumage
44
5=begin
56
67=head1 SYNOPSIS
78
1717
1818=head1 DESCRIPTION
1919
20=cut
20=end
2121
2222our %CONF;
2323our %ACTION;
2424
25=begin
26
2527=head2 Functions
2628
2729=over 4
3434whether they are currently installed or not. Each name is suitable for passing
3535to C<get_project_metadata()> to obtain more details.
3636
37=cut
37=end
3838
3939sub get_project_list () {
4040 my @files := readdir(replace_config_strings(%CONF<plumage_metadata_dir>));
5151 return @projects;
5252}
5353
54=begin
5455
5556=item %info := get_project_metadata($project, $ignore_missing)
5657
5959such project is known, and also outputs an error message unless
6060C<$ignore_missing> is true.
6161
62=cut
62=end
6363
6464sub get_project_metadata ($project, $ignore_missing) {
6565 my $meta_dir := replace_config_strings(%CONF<plumage_metadata_dir>);
8282 return 0;
8383}
8484
85=begin
8586
8687=item $is_valid := metadata_valid(%info)
8788
9191if not. Also outputs error messages and hints to the user for any problems
9292found.
9393
94=cut
94=end
9595
9696sub metadata_valid (%info) {
9797 return metadata_spec_known(%info)
158158 return 1;
159159}
160160
161=begin
161162
162163=back
163164
164=cut
165=end
  
11# Copyright (C) 2009, Parrot Foundation.
22# $Id$
33
4=begin
5
46=head1 NAME
57
68Plumage::Downloader - Fetch the contents of a url in various ways
1515
1616Downloads files.
1717
18=cut
18=end
1919
2020.namespace ['Plumage';'Downloader']
2121
  
22
33Util.nqp - Utility functions for NQP and Plumage
44
5=begin
56
67=head1 SYNOPSIS
78
2626
2727=head1 DESCRIPTION
2828
29=cut
29=end
3030
3131
3232# NQP bug XXXX: Fakecutables broken because 'nqp' language is not loaded.
4747our %CONF;
4848our $OS;
4949
50=begin
5051
5152=head2 Basic Functions
5253
6464application of C<&code> to an item in the C<@originals> produces exactly
6565one entry in the C<@mapped> output.
6666
67=cut
67=end
6868
6969sub map (&code, @originals) {
7070 my @mapped;
7676 return @mapped;
7777}
7878
79=begin
7980
8081=head2 General Utilities
8182
9292setting their corresponding value to 1, thus allowing cheap set membership
9393checks.
9494
95=cut
95=end
9696
9797sub set_from_array (@array) {
9898 my %set;
105105}
106106
107107
108=begin
109
108110=back
109111
110112
132132 # Not found, try a different $program or fail
133133 }
134134
135=cut
135=end
136136
137137sub find_program ($program) {
138138 my $path_sep := $OS eq 'MSWin32' ?? ';' !! ':';
155155 return '';
156156}
157157
158=begin
158159
159160=item mkpath($directory_path)
160161
161162Basically an iterative C<mkdir()>, C<mkpath()> works its way down from the
162163top making directories as needed until an entire path has been created.
163164
164=cut
165=end
165166
166167sub mkpath ($path) {
167168 my @path := split('/', $path);
177177 }
178178}
179179
180=begin
180181
181182=item $writable := test_dir_writable($directory_path)
182183
192192checking for errors on every real operation can avoid security holes due to
193193race conditions between test and action.
194194
195=cut
195=end
196196
197197sub test_dir_writable($dir) {
198198 my $test_file := fscat(as_array($dir), 'WrItAbLe.UtL');
214214}
215215
216216
217=begin
218
217219=head2 Plumage Specific Functions
218220
219221While the previous functions are likely usable by a great variety of NQP
248248caused by bad config settings, nor is it protected from nefarious inputs
249249producing unintended expansions.
250250
251=cut
251=end
252252
253253sub replace_config_strings ($original) {
254254 my $new := $original;
273273 return $config;
274274}
275275
276=begin
276277
277278=back
278279
279=cut
280=end