Esempio n. 1
0
void set_id_annotation (DDS_DynamicTypeBuilder b,
			const char             *name,
			DDS_MemberId           id)
{
	DDS_DynamicTypeMember		dtm;
	DDS_ReturnCode_t	 	ret;
	unsigned			n;
	char				buf [12];
	static DDS_AnnotationDescriptor	ad = { NULL, };

	if (!b && ad.type) {
		DDS_AnnotationDescriptor__clear (&ad);
		return;
	}
	if (!ad.type) {
		ad.type = DDS_DynamicTypeBuilderFactory_get_builtin_annotation ("ID");
		fail_unless (ad.type != NULL);
	}
	n = snprintf (buf, sizeof (buf), "%u", id);
	fail_unless (n != 0);

	ret = DDS_AnnotationDescriptor_set_value (&ad, "value", buf);
	fail_unless (ret == DDS_RETCODE_OK);

	dtm = DDS_DynamicTypeMember__alloc ();
	fail_unless (dtm != NULL);

	ret = DDS_DynamicTypeBuilder_get_member_by_name (b, dtm, name);
	fail_unless (ret == DDS_RETCODE_OK);

	ret = DDS_DynamicTypeMember_apply_annotation (dtm, &ad);
	fail_unless (ret == DDS_RETCODE_OK);

	DDS_DynamicTypeMember__free (dtm);
}
Esempio n. 2
0
void set_key_annotation (DDS_DynamicTypeBuilder b,
			 const char             *name)
{
	DDS_DynamicTypeMember		dtm;
	DDS_ReturnCode_t	 	ret;
	static DDS_AnnotationDescriptor	ad = { NULL, };

	if (!b && ad.type) {
		DDS_AnnotationDescriptor__clear (&ad);
		return;
	}
	if (!ad.type) {
		ad.type = DDS_DynamicTypeBuilderFactory_get_builtin_annotation ("Key");
		fail_unless (ad.type != NULL);
	}
	dtm = DDS_DynamicTypeMember__alloc ();
	fail_unless (dtm != NULL);

	ret = DDS_DynamicTypeBuilder_get_member_by_name (b, dtm, name);
	fail_unless (ret == DDS_RETCODE_OK);

	ret = DDS_DynamicTypeMember_apply_annotation (dtm, &ad);
	fail_unless (ret == DDS_RETCODE_OK);

	DDS_DynamicTypeMember__free (dtm);
}
Esempio n. 3
0
void set_ext_annotation (DDS_DynamicTypeBuilder b,
			 const char             *ext)
{
	DDS_ReturnCode_t	 	ret;
	static DDS_AnnotationDescriptor	ad = { NULL, };

	if (!b && ad.type) {
		DDS_AnnotationDescriptor__clear (&ad);
		return;
	}
	if (!ad.type) {
		ad.type = DDS_DynamicTypeBuilderFactory_get_builtin_annotation ("Extensibility");
		fail_unless (ad.type != NULL);
	}
	ret = DDS_AnnotationDescriptor_set_value (&ad, "value", ext);
	fail_unless (ret == DDS_RETCODE_OK);

	ret = DDS_DynamicTypeBuilder_apply_annotation (b, &ad);
	fail_unless (ret == DDS_RETCODE_OK);
}
Esempio n. 4
0
void introspect_enum_type (unsigned                 indent,
		           const DDS_DynamicType    t,
		           const DDS_TypeDescriptor *dp)
{
	unsigned		i, j, n;
	DDS_ReturnCode_t	ret;
	DDS_MemberDescriptor	md;
	DDS_AnnotationDescriptor ad;
	DDS_DynamicTypeMembersById members;
	MapEntry_DDS_MemberId_DDS_DynamicTypeMember *p;

	dbg_printf ("enum %s {\r\n", dp->name);
	indent++;
	DDS_MemberDescriptor__init (&md);
	ret = DDS_DynamicType_get_all_members (t, &members);
	fail_unless (ret == DDS_RETCODE_OK);

	DDS_SEQ_FOREACH_ENTRY (members, i, p) {
		INDENT (indent, j);
		if ((n = DDS_DynamicTypeMember_get_annotation_count (p->value)) != 0) {
			DDS_AnnotationDescriptor__init (&ad);
			for (i = 0; i < n; i++) {
				ret = DDS_DynamicType_get_annotation (t, &ad, i);
				fail_unless (ret == DDS_RETCODE_OK);

				introspect_annotation (&ad, 0);
				DDS_AnnotationDescriptor__clear (&ad);
			}
		}
		ret = DDS_DynamicTypeMember_get_descriptor (p->value, &md);
		fail_unless (ret == DDS_RETCODE_OK);

		dbg_printf ("%s", md.name);
		if (i + 1 < DDS_SEQ_LENGTH (members))
			dbg_printf (",");
		dbg_printf ("\r\n");
	}