Skip to content

Commit 5f2117d

Browse files
committed
Enable compilation on VS
1 parent 147ff7e commit 5f2117d

File tree

6 files changed

+27
-26
lines changed

6 files changed

+27
-26
lines changed

erpc_rust/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
target
1+
target
2+

erpcgen/VisualStudio_v14/erpcgen.vcxproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ python.exe ..\bin\txt_to_c.py --output .\java_interface.cpp ..\src\templates\jav
124124
python.exe ..\bin\txt_to_c.py --output .\java_struct.cpp ..\src\templates\java_struct.template
125125
python.exe ..\bin\txt_to_c.py --output .\java_server.cpp ..\src\templates\java_server.template
126126
python.exe ..\bin\txt_to_c.py --output .\java_client.cpp ..\src\templates\java_client.template
127-
python.exe ..\bin\txt_to_c.py --output .\java_const.cpp ..\src\templates\java_const.template</Command>
127+
python.exe ..\bin\txt_to_c.py --output .\java_const.cpp ..\src\templates\java_const.template
128+
python.exe ..\bin\txt_to_c.py --output .\rust_template.cpp ..\src\templates\rust_template.template</Command>
128129
</PreBuildEvent>
129130
</ItemDefinitionGroup>
130131
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -178,7 +179,8 @@ python.exe ..\bin\txt_to_c.py --output .\java_interface.cpp ..\src\templates\jav
178179
python.exe ..\bin\txt_to_c.py --output .\java_struct.cpp ..\src\templates\java_struct.template
179180
python.exe ..\bin\txt_to_c.py --output .\java_server.cpp ..\src\templates\java_server.template
180181
python.exe ..\bin\txt_to_c.py --output .\java_client.cpp ..\src\templates\java_client.template
181-
python.exe ..\bin\txt_to_c.py --output .\java_const.cpp ..\src\templates\java_const.template</Command>
182+
python.exe ..\bin\txt_to_c.py --output .\java_const.cpp ..\src\templates\java_const.template
183+
python.exe ..\bin\txt_to_c.py --output .\rust_template.cpp ..\src\templates\rust_template.template</Command>
182184
</PreBuildEvent>
183185
<Flex>
184186
<OutputFile>$(ProjectDir)\%(Filename).flex.cpp</OutputFile>
@@ -212,6 +214,7 @@ python.exe ..\bin\txt_to_c.py --output .\java_const.cpp ..\src\templates\java_co
212214
<ClInclude Include="..\src\InterfaceDefinition.hpp" />
213215
<ClInclude Include="..\src\ParseErrors.hpp" />
214216
<ClInclude Include="..\src\PythonGenerator.hpp" />
217+
<ClInclude Include="..\src\RustGenerator.hpp" />
215218
<ClInclude Include="..\src\SymbolScanner.hpp" />
216219
<ClInclude Include="..\src\Token.hpp" />
217220
<ClInclude Include="..\src\types\AliasType.hpp" />
@@ -254,6 +257,7 @@ python.exe ..\bin\txt_to_c.py --output .\java_const.cpp ..\src\templates\java_co
254257
<ClCompile Include="..\src\InterfaceDefinition.cpp" />
255258
<ClCompile Include="..\src\ParseErrors.cpp" />
256259
<ClCompile Include="..\src\PythonGenerator.cpp" />
260+
<ClCompile Include="..\src\RustGenerator.cpp" />
257261
<ClCompile Include="..\src\SymbolScanner.cpp" />
258262
<ClCompile Include="..\src\Token.cpp" />
259263
<ClCompile Include="..\src\types\Type.cpp" />
@@ -280,6 +284,7 @@ python.exe ..\bin\txt_to_c.py --output .\java_const.cpp ..\src\templates\java_co
280284
<ClCompile Include="java_client.cpp" />
281285
<ClCompile Include="java_coders.cpp" />
282286
<ClCompile Include="java_const.cpp" />
287+
<ClCompile Include="rust_template.cpp" />
283288
<ClCompile Include="java_enum.cpp" />
284289
<ClCompile Include="java_interface.cpp" />
285290
<ClCompile Include="java_server.cpp" />

erpcgen/src/RustGenerator.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ std::string RustGenerator::generateClientRequestSerialization(
808808
<< " let request_data = request_codec.as_bytes().to_vec();\n";
809809
requestCode << " \n";
810810
requestCode << " let "
811-
<< (fn->isOneway() ? "_response_data" : "response_data")
811+
<< (fn->isOneway() ? "_" : "response_data")
812812
<< " = self.client\n";
813813
requestCode << " .perform_request(\n";
814814
requestCode << " " << interfaceServiceId << ".as_u8(),\n";
@@ -1569,16 +1569,10 @@ void RustGenerator::determineReturnTypes(
15691569
clientReturnType = rustReturnType;
15701570
} else {
15711571
// Function has no return value or out parameters
1572-
if (fn->isOneway()) {
1573-
// Oneway methods return void (no Result wrapper)
1574-
rustReturnType = "";
1575-
clientReturnType =
1576-
" -> Result<(), Box<dyn std::error::Error + Send + Sync>>";
1577-
} else {
1578-
rustReturnType =
1579-
" -> Result<(), Box<dyn std::error::Error + Send + Sync>>";
1580-
clientReturnType = rustReturnType;
1581-
}
1572+
// Always use Result type for consistency and better error handling
1573+
rustReturnType =
1574+
" -> Result<(), Box<dyn std::error::Error + Send + Sync>>";
1575+
clientReturnType = rustReturnType;
15821576
}
15831577
}
15841578

@@ -1640,12 +1634,10 @@ RustGenerator::generateOnewayServerHandler(Function *fn,
16401634
codecParamName);
16411635

16421636
// Generate method call with parameters
1643-
serverHandlerCode << " self.service."
1637+
serverHandlerCode << " let _ = self.service."
16441638
<< toSnakeCase(fn->getName()) << "(";
16451639
serverHandlerCode << generateMethodCallParameters(fn, lengthParams);
16461640
serverHandlerCode << ").await;\n";
1647-
serverHandlerCode
1648-
<< " // Oneway methods don't send responses\n";
16491641
serverHandlerCode << " Ok(())";
16501642

16511643
return serverHandlerCode.str();

examples/temp_alarm_rust/src/client_impl.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ pub async fn run_client() -> Result<(), Box<dyn std::error::Error>> {
8383
.map_err(|e| format!("read_results error: {}", e))?;
8484
println!("✅ Multiple sensor results sent via TempAsyncClient");
8585

86-
// Continue using TempAsyncClient for more method calls
87-
let mut temp_async_client = TempAsyncClient::new(&mut shared_client_manager);
88-
8986
// Fire another alarm notification
9087
temp_async_client
9188
.alarm_fired(2, 45.5)

examples/temp_alarm_rust/src/server_impl.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,15 @@ impl TempAsync for TempAsyncServiceImpl {
180180
Ok(())
181181
}
182182

183-
async fn read_results(&self, results: Vec<SensorReadResult>) {
183+
async fn read_results(
184+
&self,
185+
results: Vec<SensorReadResult>,
186+
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
184187
println!("📊 Received {} sensor readings:", results.len());
185188
for result in results {
186189
println!(" 🌡️ Sensor {}: {}°C", result.address, result.temp);
187190
}
191+
Ok(())
188192
}
189193
}
190194

examples/temp_alarm_rust/src/temp_alarm.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
//
11-
// Generated by erpcgen 1.14.0 on Thu Aug 7 13:19:44 2025.
11+
// Generated by erpcgen 1.14.0 on Thu Aug 7 14:41:40 2025.
1212
//
1313
// AUTOGENERATED - DO NOT EDIT
1414
//
@@ -1437,7 +1437,10 @@ pub mod temp_async_server {
14371437
temp: f32,
14381438
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>;
14391439
/// <function(2) read_results-><member (return):(void)> [<struct (fn) [0:<member results:(list)>, 1:<member count:uint32>]>]>
1440-
async fn read_results(&self, results: Vec<SensorReadResult>);
1440+
async fn read_results(
1441+
&self,
1442+
results: Vec<SensorReadResult>,
1443+
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>;
14411444
}
14421445

14431446
/// Server wrapper for TempAsync service
@@ -1549,8 +1552,7 @@ pub mod temp_async_server {
15491552
Ok(list)
15501553
})()?;
15511554

1552-
self.service.read_results(results).await;
1553-
// Oneway methods don't send responses
1555+
let _ = self.service.read_results(results).await;
15541556
Ok(())
15551557
}
15561558
}
@@ -1652,7 +1654,7 @@ pub mod temp_async_server {
16521654

16531655
let request_data = request_codec.as_bytes().to_vec();
16541656

1655-
let _response_data = self
1657+
let _ = self
16561658
.client
16571659
.perform_request(
16581660
ServiceId::TempAsync.as_u8(),

0 commit comments

Comments
 (0)