Commits

M6 KVM committed 193995b

Check to ensure that a code ref is passed.

Comments (0)

Files changed (1)

 	OPT_TYPE_VARNAME() => \&_CheckOptTypeVarname,
 	OPT_TYPE_STRING() => \&_CheckOptTypeString,
 	OPT_TYPE_BOOL() => \&_CheckOptTypeBool,
-	OPT_TYPE_CODEREF() => undef,
+	OPT_TYPE_CODEREF() => \&_CheckOptTypeCoderef,
 	OPT_TYPE_REALFILE() => \&_CheckOptTypeRealfile,
 	OPT_TYPE_REALDIR() => \&_CheckOptTypeRealdir
 );
 	return 0;
 }
 #----------------------------------------------------------------------------
+sub _CheckOptTypeCoderef
+{
+	my $ref;
+	my $good = 0;
+	my ( $self, $OptVal, $PErrMsg ) = @_;
+	die 'Internal error' if ( !$self );
+	if ( defined($OptVal) && ($ref = ref($OptVal)) ) {
+		if ( $ref eq 'CODE' ) {
+			$good++;
+		} else {
+			$$PErrMsg = sprintf(
+				'Ref to type %s (not code)',
+				$ref
+			) if ( $PErrMsg );
+		}
+	} else {
+		if ( defined($OptVal) ) {
+			$$PErrMsg = $OptVal . ' is not a reference'
+				if ( $PErrMsg );
+		} else {
+			$$PErrMsg = 'Undefined value' if ( $PErrMsg );
+		}
+	}
+	return $good;
+}
+#----------------------------------------------------------------------------
 sub _CheckOptTypeRealdir
 {
 	my $self = shift;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.