@@ -195,12 +195,21 @@ fn extend_dict_with_use(
195
195
router
196
196
}
197
197
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
+ }
204
213
}
205
214
cm_rust:: UseSource :: Child ( child_name) => {
206
215
let child_name = ChildName :: parse ( child_name) . expect ( "invalid child name" ) ;
@@ -218,11 +227,17 @@ fn extend_dict_with_use(
218
227
)
219
228
}
220
229
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
+ }
221
236
let ( receiver, sender) = Receiver :: new ( ) ;
222
237
let source_name = use_protocol. source_name . clone ( ) ;
223
238
sources_and_receivers. push ( (
224
239
CapabilitySourceFactory :: new ( move |component| CapabilitySource :: Framework {
225
- capability : InternalCapability :: Protocol ( source_name. clone ( ) ) ,
240
+ capability : InternalCapability :: Protocol ( source_name) ,
226
241
component,
227
242
} ) ,
228
243
receiver,
@@ -264,9 +279,9 @@ fn extend_dict_with_offer(
264
279
cm_rust:: OfferDecl :: Protocol ( _) | cm_rust:: OfferDecl :: Dictionary ( _) => ( ) ,
265
280
_ => return ,
266
281
}
267
- let source_name = offer. source_name ( ) ;
282
+ let source_path = offer. source_path ( ) ;
268
283
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 ( ) {
270
285
warn ! (
271
286
"duplicate sources for protocol {} in a dict, unable to populate dict entry" ,
272
287
target_name
@@ -277,51 +292,56 @@ fn extend_dict_with_offer(
277
292
let router = match offer. source ( ) {
278
293
cm_rust:: OfferSource :: Parent => {
279
294
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 ( ) )
281
296
else {
282
297
return ;
283
298
} ;
284
299
router
285
300
}
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 ( ) {
288
303
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 ( ) )
290
305
else {
291
306
return ;
292
307
} ;
293
308
router
294
- }
295
- _ => {
309
+ } else {
296
310
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 ( ) )
298
312
else {
299
313
return ;
300
314
} ;
301
315
router
302
316
}
303
- } ,
317
+ }
304
318
cm_rust:: OfferSource :: Child ( child_ref) => {
305
319
let child_name: ChildName = child_ref. clone ( ) . try_into ( ) . expect ( "invalid child ref" ) ;
306
320
let Some ( child) = children. get ( & child_name) else { return } ;
307
321
let weak_child = WeakComponentInstance :: new ( child) ;
308
322
new_forwarding_router_to_child (
309
323
component,
310
324
weak_child,
311
- SeparatedPath { basename : source_name . to_string ( ) , dirname : None } ,
325
+ source_path . to_owned ( ) ,
312
326
RoutingError :: offer_from_child_expose_not_found (
313
327
child. moniker . leaf ( ) . unwrap ( ) ,
314
328
& child. moniker . parent ( ) . unwrap ( ) ,
315
- source_name. clone ( ) ,
329
+ offer . source_name ( ) . clone ( ) ,
316
330
) ,
317
331
)
318
332
}
319
333
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 ( ) ;
321
341
new_router_for_cm_hosted_receiver (
322
342
sources_and_receivers,
323
343
CapabilitySourceFactory :: new ( move |component| CapabilitySource :: Framework {
324
- capability : InternalCapability :: Protocol ( source_name. clone ( ) ) ,
344
+ capability : InternalCapability :: Protocol ( source_name) ,
325
345
component,
326
346
} ) ,
327
347
)
@@ -363,52 +383,58 @@ fn extend_dict_with_expose(
363
383
if expose. target ( ) != & cm_rust:: ExposeTarget :: Parent {
364
384
return ;
365
385
}
366
- let source_name = expose. source_name ( ) ;
386
+ let source_path = expose. source_path ( ) ;
367
387
let target_name = expose. target_name ( ) ;
368
388
369
389
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
+ {
372
393
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 ( ) )
374
395
else {
375
396
return ;
376
397
} ;
377
398
router
378
- }
379
- _ => {
399
+ } else {
380
400
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 ( ) )
382
402
else {
383
403
return ;
384
404
} ;
385
405
router
386
406
}
387
- } ,
407
+ }
388
408
cm_rust:: ExposeSource :: Child ( child_name) => {
389
409
let child_name = ChildName :: parse ( child_name) . expect ( "invalid static child name" ) ;
390
410
if let Some ( child) = children. get ( & child_name) {
391
411
let weak_child = WeakComponentInstance :: new ( child) ;
392
412
new_forwarding_router_to_child (
393
413
component,
394
414
weak_child,
395
- SeparatedPath { basename : source_name . to_string ( ) , dirname : None } ,
415
+ source_path . to_owned ( ) ,
396
416
RoutingError :: expose_from_child_expose_not_found (
397
417
child. moniker . leaf ( ) . unwrap ( ) ,
398
418
& child. moniker . parent ( ) . unwrap ( ) ,
399
- source_name. clone ( ) ,
419
+ expose . source_name ( ) . clone ( ) ,
400
420
) ,
401
421
)
402
422
} else {
403
423
return ;
404
424
}
405
425
}
406
426
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 ( ) ;
408
434
new_router_for_cm_hosted_receiver (
409
435
sources_and_receivers,
410
436
CapabilitySourceFactory :: new ( move |component| CapabilitySource :: Framework {
411
- capability : InternalCapability :: Protocol ( source_name. clone ( ) ) ,
437
+ capability : InternalCapability :: Protocol ( source_name) ,
412
438
component,
413
439
} ) ,
414
440
)
0 commit comments