浏览代码

Added String.FromChars( chars:Int[] ).

Mark Sibly 8 年之前
父节点
当前提交
b2976c674a
共有 3 个文件被更改,包括 17 次插入4 次删除
  1. 3 0
      modules/monkey/native/bbstring.cpp
  2. 2 0
      modules/monkey/native/bbstring.h
  3. 12 4
      modules/monkey/types.monkey2

+ 3 - 0
modules/monkey/native/bbstring.cpp

@@ -249,3 +249,6 @@ bbString bbString::join( bbArray<bbString> bits )const{
 	return rep;
 	return rep;
 }
 }
 
 
+bbString bbString::fromChars( bbArray<int> chrs ){ 
+	return Rep::create( chrs.data(),chrs.length() ); 
+}

+ 2 - 0
modules/monkey/native/bbstring.h

@@ -466,6 +466,8 @@ class bbString{
 	
 	
 	static bbString fromChar( int chr );
 	static bbString fromChar( int chr );
 	
 	
+	static bbString fromChars( bbArray<int> chrs );
+	
 	static bbString fromCString( const void *data ){ return bbString( data ); }
 	static bbString fromCString( const void *data ){ return bbString( data ); }
 	
 	
 	static bbString fromCString( const void *data,int size ){ return bbString( data,size ); }
 	static bbString fromCString( const void *data,int size ){ return bbString( data,size ); }

+ 12 - 4
modules/monkey/types.monkey2

@@ -344,17 +344,25 @@ Struct @String ="bbString"
 
 
 	#rem monkeydoc Creates a string containing a single character.
 	#rem monkeydoc Creates a string containing a single character.
 	
 	
-	@param chr The character.
+	@param char The character.
 	
 	
 	#end
 	#end
-	Function FromChar:String( chr:Int )="bbString::fromChar"
+	Function FromChar:String( char:Int )="bbString::fromChar"
+	
+
+	#rem monkeydoc Creates a string containing characters in an array.
+	
+	@param chars The array.
+	
+	#end
+	Function FromChars:String( chars:Int[] )="bbString::fromChars"
 	
 	
 	
 	
 	#rem monkeydoc Creates a string from a CString.
 	#rem monkeydoc Creates a string from a CString.
 	
 	
 	If `bufSize` is specified, the CString may contain null characters which will be included in the string.
 	If `bufSize` is specified, the CString may contain null characters which will be included in the string.
 	
 	
-	If `bufsize` is not specified, the CString must be correctly null terminated or Bad Things Will Happen.
+	If `bufSize` is not specified, the CString must be correctly null terminated or Bad Things Will Happen.
 	
 	
 	@param buf The memory buffer containing the CString.
 	@param buf The memory buffer containing the CString.
 	
 	
@@ -370,7 +378,7 @@ Struct @String ="bbString"
 	
 	
 	If `bufSize` is specified, the WString may contain null characters which will be included in the string.
 	If `bufSize` is specified, the WString may contain null characters which will be included in the string.
 	
 	
-	If `bufsize` is not specified, the WString must be correctly null terminated or Bad Things Will Happen.
+	If `bufSize` is not specified, the WString must be correctly null terminated or Bad Things Will Happen.
 	
 	
 	@param buf The memory buffer containing the WString.
 	@param buf The memory buffer containing the WString.