summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2003-05-13 14:05:57 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2003-05-13 14:05:57 +0000
commit2adbc058c8b49418809c3ea05713905c268629c4 (patch)
treed748b3a0c1d3a52f9f5c2d8d15166e5d761cfd2f
parente1fde9042d0c8be9e37d7db9db769a2ec844a2a9 (diff)
downloadMPC-2adbc058c8b49418809c3ea05713905c268629c4.tar.gz
ChangeLogTag: Tue May 13 09:04:18 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r--modules/Creator.pm36
-rw-r--r--modules/ProjectCreator.pm48
-rw-r--r--modules/WorkspaceCreator.pm43
3 files changed, 94 insertions, 33 deletions
diff --git a/modules/Creator.pm b/modules/Creator.pm
index 7af3fbdd..8f891cea 100644
--- a/modules/Creator.pm
+++ b/modules/Creator.pm
@@ -534,6 +534,42 @@ sub process_assignment_sub {
}
+sub fill_type_name {
+ my($self) = shift;
+ my($name) = shift;
+ my($def) = shift;
+
+ if ($name =~ /\*/) {
+ my($pre) = $def . '_';
+ my($mid) = '_' . $def . '_';
+ my($post) = '_' . $def;
+
+ ## Replace the beginning and end first then the middle
+ $name =~ s/^\*/$pre/;
+ $name =~ s/\*$/$post/;
+ $name =~ s/\*/$mid/g;
+
+ ## If any one word is capitalized then capitalize each word
+ if ($name =~ /[A-Z][0-9a-z_]+/) {
+ ## Do the first word
+ if ($name =~ /^([a-z])([^_]+)/) {
+ my($first) = uc($1);
+ my($rest) = $2;
+ $name =~ s/^[a-z][^_]+/$first$rest/;
+ }
+ ## Do subsequent words
+ while($name =~ /(_[a-z])([^_]+)/) {
+ my($first) = uc($1);
+ my($rest) = $2;
+ $name =~ s/_[a-z][^_]+/$first$rest/;
+ }
+ }
+ }
+
+ return $name;
+}
+
+
sub save_state {
my($self) = shift;
my(%state) = ();
diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm
index 94b89523..ad3d4262 100644
--- a/modules/ProjectCreator.pm
+++ b/modules/ProjectCreator.pm
@@ -317,6 +317,11 @@ sub parse_line {
$name =~ s/^\(\s*//;
$name =~ s/\s*\)$//;
$name = $self->transform_file_name($name);
+
+ ## Replace any *'s with the default name
+ my($def) = $self->get_default_project_name();
+ $name = $self->fill_type_name($name, $def);
+
$self->process_assignment('project_name', $name);
}
}
@@ -1477,29 +1482,36 @@ sub add_corresponding_component_files {
}
+sub get_default_project_name {
+ my($self) = shift;
+ my($name) = $self->get_current_input();
+
+ if ($name eq '') {
+ $name = $self->transform_file_name($self->base_directory());
+ }
+ else {
+ ## Since files on UNIX can have back slashes, we transform them
+ ## into underscores.
+ $name =~ s/\\/_/g;
+
+ ## Convert then name to a usable name
+ $name = $self->transform_file_name($name);
+
+ ## Take off the extension
+ $name =~ s/\.[^\.]+$//;
+ }
+
+ return $name;
+}
+
+
sub generate_defaults {
my($self) = shift;
## Generate default project name
if (!defined $self->get_assignment('project_name')) {
- my($current) = $self->get_current_input();
- if ($current eq '') {
- my($base) = $self->base_directory();
- $base = $self->transform_file_name($base);
- $self->process_assignment('project_name', $base);
- }
- else {
- ## Since files on UNIX can have back slashes, we transform them
- ## into underscores.
- $current =~ s/\\/_/g;
-
- ## Convert then name to a usable name
- $current = $self->transform_file_name($current);
-
- ## Take off the extension
- $current =~ s/\.[^\.]+$//;
- $self->process_assignment('project_name', $current);
- }
+ $self->process_assignment('project_name',
+ $self->get_default_project_name());
}
## Generate the default pch file names (if needed)
diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm
index 1ca72a4e..332d93c6 100644
--- a/modules/WorkspaceCreator.pm
+++ b/modules/WorkspaceCreator.pm
@@ -166,14 +166,19 @@ sub parse_line {
## Set up some initial values
if (defined $name) {
- $name =~ s/^\(\s*//;
- $name =~ s/\s*\)$//;
if ($name =~ /[\/\\]/) {
$status = 0;
$errorString = 'ERROR: Workspaces can not have a slash ' .
'or a back slash in the name';
}
else {
+ $name =~ s/^\(\s*//;
+ $name =~ s/\s*\)$//;
+
+ ## Replace any *'s with the default name
+ my($def) = $self->get_default_workspace_name();
+ $name = $self->fill_type_name($name, $def);
+
$self->{'workspace_name'} = $name;
}
}
@@ -417,24 +422,32 @@ sub generate_default_components {
}
+sub get_default_workspace_name {
+ my($self) = shift;
+ my($name) = $self->get_current_input();
+
+ if ($name eq '') {
+ $name = $self->base_directory();
+ }
+ else {
+ ## Since files on UNIX can have back slashes, we transform them
+ ## into underscores.
+ $name =~ s/\\/_/g;
+
+ ## Take off the extension
+ $name =~ s/\.[^\.]+$//;
+ }
+
+ return $name;
+}
+
+
sub generate_defaults {
my($self) = shift;
## Generate default workspace name
if (!defined $self->{'workspace_name'}) {
- my($current) = $self->get_current_input();
- if ($current eq '') {
- $self->{'workspace_name'} = $self->base_directory();
- }
- else {
- ## Since files on UNIX can have back slashes, we transform them
- ## into underscores.
- $current =~ s/\\/_/g;
-
- ## Take off the extension
- $current =~ s/\.[^\.]+$//;
- $self->{'workspace_name'} = $current;
- }
+ $self->{'workspace_name'} = $self->get_default_workspace_name();
}
my(@files) = $self->generate_default_file_list();