@@ -195,12 +195,21 @@ fn extend_dict_with_use(
195195 router
196196 }
197197 cm_rust:: UseSource :: Self_ => {
198- let Some ( router) =
199- program_output_dict. get_routable :: < Router > ( source_path. iter_segments ( ) )
200- else {
201- return ;
202- } ;
203- router
198+ if source_path. dirname . is_some ( ) {
199+ let Some ( router) =
200+ program_output_dict. get_routable :: < Dict > ( source_path. iter_segments ( ) )
201+ else {
202+ return ;
203+ } ;
204+ router
205+ } else {
206+ let Some ( router) =
207+ program_output_dict. get_routable :: < Router > ( source_path. iter_segments ( ) )
208+ else {
209+ return ;
210+ } ;
211+ router
212+ }
204213 }
205214 cm_rust:: UseSource :: Child ( child_name) => {
206215 let child_name = ChildName :: parse ( child_name) . expect ( "invalid child name" ) ;
@@ -218,11 +227,17 @@ fn extend_dict_with_use(
218227 )
219228 }
220229 cm_rust:: UseSource :: Framework => {
230+ if source_path. dirname . is_some ( ) {
231+ warn ! (
232+ "routing from framework with dictionary path is not supported: {source_path}"
233+ ) ;
234+ return ;
235+ }
221236 let ( receiver, sender) = Receiver :: new ( ) ;
222237 let source_name = use_protocol. source_name . clone ( ) ;
223238 sources_and_receivers. push ( (
224239 CapabilitySourceFactory :: new ( move |component| CapabilitySource :: Framework {
225- capability : InternalCapability :: Protocol ( source_name. clone ( ) ) ,
240+ capability : InternalCapability :: Protocol ( source_name) ,
226241 component,
227242 } ) ,
228243 receiver,
@@ -264,9 +279,9 @@ fn extend_dict_with_offer(
264279 cm_rust:: OfferDecl :: Protocol ( _) | cm_rust:: OfferDecl :: Dictionary ( _) => ( ) ,
265280 _ => return ,
266281 }
267- let source_name = offer. source_name ( ) ;
282+ let source_path = offer. source_path ( ) ;
268283 let target_name = offer. target_name ( ) ;
269- if target_dict. get_routable :: < Router > ( iter :: once ( target_name . as_str ( ) ) ) . is_some ( ) {
284+ if target_dict. get_routable :: < Router > ( source_path . iter_segments ( ) ) . is_some ( ) {
270285 warn ! (
271286 "duplicate sources for protocol {} in a dict, unable to populate dict entry" ,
272287 target_name
@@ -277,51 +292,56 @@ fn extend_dict_with_offer(
277292 let router = match offer. source ( ) {
278293 cm_rust:: OfferSource :: Parent => {
279294 let Some ( router) =
280- component_input_dict. get_routable :: < Router > ( iter :: once ( source_name . as_str ( ) ) )
295+ component_input_dict. get_routable :: < Router > ( source_path . iter_segments ( ) )
281296 else {
282297 return ;
283298 } ;
284299 router
285300 }
286- cm_rust:: OfferSource :: Self_ => match offer {
287- cm_rust:: OfferDecl :: Dictionary ( _) => {
301+ cm_rust:: OfferSource :: Self_ => {
302+ if matches ! ( offer , cm_rust:: OfferDecl :: Dictionary ( _) ) || source_path . dirname . is_some ( ) {
288303 let Some ( router) =
289- program_output_dict. get_routable :: < Dict > ( iter :: once ( source_name . as_str ( ) ) )
304+ program_output_dict. get_routable :: < Dict > ( source_path . iter_segments ( ) )
290305 else {
291306 return ;
292307 } ;
293308 router
294- }
295- _ => {
309+ } else {
296310 let Some ( router) =
297- program_output_dict. get_routable :: < Router > ( iter :: once ( source_name . as_str ( ) ) )
311+ program_output_dict. get_routable :: < Router > ( source_path . iter_segments ( ) )
298312 else {
299313 return ;
300314 } ;
301315 router
302316 }
303- } ,
317+ }
304318 cm_rust:: OfferSource :: Child ( child_ref) => {
305319 let child_name: ChildName = child_ref. clone ( ) . try_into ( ) . expect ( "invalid child ref" ) ;
306320 let Some ( child) = children. get ( & child_name) else { return } ;
307321 let weak_child = WeakComponentInstance :: new ( child) ;
308322 new_forwarding_router_to_child (
309323 component,
310324 weak_child,
311- SeparatedPath { basename : source_name . to_string ( ) , dirname : None } ,
325+ source_path . to_owned ( ) ,
312326 RoutingError :: offer_from_child_expose_not_found (
313327 child. moniker . leaf ( ) . unwrap ( ) ,
314328 & child. moniker . parent ( ) . unwrap ( ) ,
315- source_name. clone ( ) ,
329+ offer . source_name ( ) . clone ( ) ,
316330 ) ,
317331 )
318332 }
319333 cm_rust:: OfferSource :: Framework => {
320- let source_name = source_name. clone ( ) ;
334+ if source_path. dirname . is_some ( ) {
335+ warn ! (
336+ "routing from framework with dictionary path is not supported: {source_path}"
337+ ) ;
338+ return ;
339+ }
340+ let source_name = offer. source_name ( ) . clone ( ) ;
321341 new_router_for_cm_hosted_receiver (
322342 sources_and_receivers,
323343 CapabilitySourceFactory :: new ( move |component| CapabilitySource :: Framework {
324- capability : InternalCapability :: Protocol ( source_name. clone ( ) ) ,
344+ capability : InternalCapability :: Protocol ( source_name) ,
325345 component,
326346 } ) ,
327347 )
@@ -363,52 +383,58 @@ fn extend_dict_with_expose(
363383 if expose. target ( ) != & cm_rust:: ExposeTarget :: Parent {
364384 return ;
365385 }
366- let source_name = expose. source_name ( ) ;
386+ let source_path = expose. source_path ( ) ;
367387 let target_name = expose. target_name ( ) ;
368388
369389 let router = match expose. source ( ) {
370- cm_rust:: ExposeSource :: Self_ => match expose {
371- cm_rust:: ExposeDecl :: Dictionary ( _) => {
390+ cm_rust:: ExposeSource :: Self_ => {
391+ if matches ! ( expose, cm_rust:: ExposeDecl :: Dictionary ( _) ) || source_path. dirname . is_some ( )
392+ {
372393 let Some ( router) =
373- program_output_dict. get_routable :: < Dict > ( iter :: once ( source_name . as_str ( ) ) )
394+ program_output_dict. get_routable :: < Dict > ( source_path . iter_segments ( ) )
374395 else {
375396 return ;
376397 } ;
377398 router
378- }
379- _ => {
399+ } else {
380400 let Some ( router) =
381- program_output_dict. get_routable :: < Router > ( iter :: once ( source_name . as_str ( ) ) )
401+ program_output_dict. get_routable :: < Router > ( source_path . iter_segments ( ) )
382402 else {
383403 return ;
384404 } ;
385405 router
386406 }
387- } ,
407+ }
388408 cm_rust:: ExposeSource :: Child ( child_name) => {
389409 let child_name = ChildName :: parse ( child_name) . expect ( "invalid static child name" ) ;
390410 if let Some ( child) = children. get ( & child_name) {
391411 let weak_child = WeakComponentInstance :: new ( child) ;
392412 new_forwarding_router_to_child (
393413 component,
394414 weak_child,
395- SeparatedPath { basename : source_name . to_string ( ) , dirname : None } ,
415+ source_path . to_owned ( ) ,
396416 RoutingError :: expose_from_child_expose_not_found (
397417 child. moniker . leaf ( ) . unwrap ( ) ,
398418 & child. moniker . parent ( ) . unwrap ( ) ,
399- source_name. clone ( ) ,
419+ expose . source_name ( ) . clone ( ) ,
400420 ) ,
401421 )
402422 } else {
403423 return ;
404424 }
405425 }
406426 cm_rust:: ExposeSource :: Framework => {
407- let source_name = source_name. clone ( ) ;
427+ if source_path. dirname . is_some ( ) {
428+ warn ! (
429+ "routing from framework with dictionary path is not supported: {source_path}"
430+ ) ;
431+ return ;
432+ }
433+ let source_name = expose. source_name ( ) . clone ( ) ;
408434 new_router_for_cm_hosted_receiver (
409435 sources_and_receivers,
410436 CapabilitySourceFactory :: new ( move |component| CapabilitySource :: Framework {
411- capability : InternalCapability :: Protocol ( source_name. clone ( ) ) ,
437+ capability : InternalCapability :: Protocol ( source_name) ,
412438 component,
413439 } ) ,
414440 )
0 commit comments