@@ -4163,12 +4163,6 @@ static void AppendArray(
41634163 builders . CppMethodDefinitions . Append ( subject ) ;
41644164 builders . CppMethodDefinitions . Append (
41654165 "InternalLength = 0;\n " ) ;
4166- AppendIndent (
4167- extraIndent ,
4168- builders . CppMethodDefinitions ) ;
4169- builders . CppMethodDefinitions . Append ( subject ) ;
4170- builders . CppMethodDefinitions . Append (
4171- "InternalRank = 0;\n " ) ;
41724166 if ( rank > 1 )
41734167 {
41744168 for ( int i = 0 ; i < rank ; ++ i )
@@ -4194,14 +4188,6 @@ static void AppendArray(
41944188 builders . CppMethodDefinitions . Append ( subject ) ;
41954189 builders . CppMethodDefinitions . Append (
41964190 "InternalLength;\n " ) ;
4197- AppendIndent (
4198- extraIndent ,
4199- builders . CppMethodDefinitions ) ;
4200- builders . CppMethodDefinitions . Append (
4201- "InternalRank = " ) ;
4202- builders . CppMethodDefinitions . Append ( subject ) ;
4203- builders . CppMethodDefinitions . Append (
4204- "InternalRank;\n " ) ;
42054191 if ( rank > 1 )
42064192 {
42074193 for ( int i = 0 ; i < rank ; ++ i )
@@ -4232,11 +4218,6 @@ static void AppendArray(
42324218 builders . CppTypeDefinitions ) ;
42334219 builders . CppTypeDefinitions . Append (
42344220 "int32_t InternalLength;\n " ) ;
4235- AppendIndent (
4236- indent + 1 ,
4237- builders . CppTypeDefinitions ) ;
4238- builders . CppTypeDefinitions . Append (
4239- "int32_t InternalRank;\n " ) ;
42404221 if ( rank > 1 )
42414222 {
42424223 AppendIndent (
@@ -4258,11 +4239,9 @@ static void AppendArray(
42584239 builders ) ;
42594240
42604241 // Base GetLength
4261- AppendArrayCppCallBaseGetIntFunction (
4242+ AppendArrayCppGetLengthFunction (
42624243 indent ,
42634244 cppArrayTypeName ,
4264- "GetLength" ,
4265- "InternalLength" ,
42664245 cppTypeParams ,
42674246 builders ) ;
42684247
@@ -4279,12 +4258,11 @@ static void AppendArray(
42794258 builders ) ;
42804259 }
42814260
4282- AppendArrayCppCallBaseGetIntFunction (
4261+ AppendArrayCppGetRankFunction (
42834262 indent ,
42844263 cppArrayTypeName ,
4285- "GetRank" ,
4286- "InternalRank" ,
42874264 cppTypeParams ,
4265+ rank ,
42884266 builders ) ;
42894267
42904268 AppendArrayGetItem (
@@ -5069,11 +5047,9 @@ static void AppendArrayConstructor(
50695047 builders . CppMethodDefinitions . Append ( "\n " ) ;
50705048 }
50715049
5072- static void AppendArrayCppCallBaseGetIntFunction (
5050+ static void AppendArrayCppGetLengthFunction (
50735051 int indent ,
50745052 string cppArrayTypeName ,
5075- string baseFunctionName ,
5076- string memberVariableName ,
50775053 Type [ ] cppTypeParams ,
50785054 StringBuilders builders )
50795055 {
@@ -5084,7 +5060,7 @@ static void AppendArrayCppCallBaseGetIntFunction(
50845060 indent + 1 ,
50855061 builders . CppTypeDefinitions ) ;
50865062 AppendCppMethodDeclaration (
5087- baseFunctionName ,
5063+ "GetLength" ,
50885064 false ,
50895065 false ,
50905066 false ,
@@ -5097,7 +5073,7 @@ static void AppendArrayCppCallBaseGetIntFunction(
50975073 AppendCppMethodDefinitionBegin (
50985074 cppArrayTypeName ,
50995075 typeof ( int ) ,
5100- baseFunctionName ,
5076+ "GetLength" ,
51015077 cppTypeParams ,
51025078 null ,
51035079 parameters ,
@@ -5110,9 +5086,8 @@ static void AppendArrayCppCallBaseGetIntFunction(
51105086 AppendIndent (
51115087 indent + 1 ,
51125088 builders . CppMethodDefinitions ) ;
5113- builders . CppMethodDefinitions . Append ( "int32_t returnVal = " ) ;
5114- builders . CppMethodDefinitions . Append ( memberVariableName ) ;
5115- builders . CppMethodDefinitions . Append ( ";\n " ) ;
5089+ builders . CppMethodDefinitions . Append (
5090+ "int32_t returnVal = InternalLength;\n " ) ;
51165091 AppendIndent (
51175092 indent + 1 ,
51185093 builders . CppMethodDefinitions ) ;
@@ -5124,14 +5099,13 @@ static void AppendArrayCppCallBaseGetIntFunction(
51245099 AppendIndent (
51255100 indent + 2 ,
51265101 builders . CppMethodDefinitions ) ;
5127- builders . CppMethodDefinitions . Append ( "returnVal = Array::" ) ;
5128- builders . CppMethodDefinitions . Append ( baseFunctionName ) ;
5129- builders . CppMethodDefinitions . Append ( "();\n " ) ;
5102+ builders . CppMethodDefinitions . Append (
5103+ "returnVal = Array::GetLength();\n " ) ;
51305104 AppendIndent (
51315105 indent + 2 ,
51325106 builders . CppMethodDefinitions ) ;
5133- builders . CppMethodDefinitions . Append ( memberVariableName ) ;
5134- builders . CppMethodDefinitions . Append ( " = returnVal;\n ") ;
5107+ builders . CppMethodDefinitions . Append (
5108+ "InternalLength = returnVal;\n ") ;
51355109 AppendIndent (
51365110 indent + 1 ,
51375111 builders . CppMethodDefinitions ) ;
@@ -5150,6 +5124,59 @@ static void AppendArrayCppCallBaseGetIntFunction(
51505124 builders . CppMethodDefinitions . Append ( '\n ' ) ;
51515125 }
51525126
5127+ static void AppendArrayCppGetRankFunction (
5128+ int indent ,
5129+ string cppArrayTypeName ,
5130+ Type [ ] cppTypeParams ,
5131+ int rank ,
5132+ StringBuilders builders )
5133+ {
5134+ ParameterInfo [ ] parameters = new ParameterInfo [ 0 ] ;
5135+
5136+ // C++ method declaration
5137+ AppendIndent (
5138+ indent + 1 ,
5139+ builders . CppTypeDefinitions ) ;
5140+ AppendCppMethodDeclaration (
5141+ "GetRank" ,
5142+ false ,
5143+ false ,
5144+ false ,
5145+ typeof ( int ) ,
5146+ null ,
5147+ parameters ,
5148+ builders . CppTypeDefinitions ) ;
5149+
5150+ // C++ method definition
5151+ AppendCppMethodDefinitionBegin (
5152+ cppArrayTypeName ,
5153+ typeof ( int ) ,
5154+ "GetRank" ,
5155+ cppTypeParams ,
5156+ null ,
5157+ parameters ,
5158+ indent ,
5159+ builders . CppMethodDefinitions ) ;
5160+ AppendIndent (
5161+ indent ,
5162+ builders . CppMethodDefinitions ) ;
5163+ builders . CppMethodDefinitions . Append ( "{\n " ) ;
5164+ AppendIndent (
5165+ indent + 1 ,
5166+ builders . CppMethodDefinitions ) ;
5167+ builders . CppMethodDefinitions . Append ( "return " ) ;
5168+ builders . CppMethodDefinitions . Append ( rank ) ;
5169+ builders . CppMethodDefinitions . Append ( ";\n " ) ;
5170+ AppendIndent (
5171+ indent ,
5172+ builders . CppMethodDefinitions ) ;
5173+ builders . CppMethodDefinitions . Append ( "}\n " ) ;
5174+ AppendIndent (
5175+ indent ,
5176+ builders . CppMethodDefinitions ) ;
5177+ builders . CppMethodDefinitions . Append ( '\n ' ) ;
5178+ }
5179+
51535180 static void AppendArrayMultidimensionalGetLength (
51545181 Type elementType ,
51555182 Type arrayType ,
0 commit comments