Exemplo n.º 1
0
 void inject_value(const type_descriptor& type_descriptor, const field& field, const void* source_ptr, reflectable& target)
 {
     VAR* target_ptr = ⌖
     VAR* head_ptr = static_cast<char*>(static_cast<void*>(target_ptr));
     VAR* field_ptr = static_cast<void*>(head_ptr + get_value_offset(field));
     type_descriptor.inject_value(source_ptr, field_ptr);
 }
Exemplo n.º 2
0
 void inspect_value(const type_descriptor& type_descriptor, const reflectable& source, const field& field, void* target_ptr)
 {
     VAR* source_ptr = &source;
     VAR* head_ptr = static_cast<const char*>(static_cast<const void*>(source_ptr));
     VAR* field_ptr = static_cast<const void*>(head_ptr + get_value_offset(field));
     type_descriptor.inspect_value(field_ptr, target_ptr);
 }
Exemplo n.º 3
0
complex_assert::complex_assert(MODULE *module)
{
	if (oclass==NULL)
	{
		// register to receive notice for first top down. bottom up, and second top down synchronizations
		oclass = gl_register_class(module,"complex_assert",sizeof(complex_assert),PC_AUTOLOCK|PC_OBSERVER);
		if (oclass==NULL)
			throw "unable to register class complex_assert";
		else
			oclass->trl = TRL_PROVEN;

		if (gl_publish_variable(oclass,
			// TO DO:  publish your variables here
			PT_enumeration,"status",get_status_offset(),
				PT_KEYWORD,"ASSERT_TRUE",(enumeration)ASSERT_TRUE,
				PT_KEYWORD,"ASSERT_FALSE",(enumeration)ASSERT_FALSE,
				PT_KEYWORD,"ASSERT_NONE",(enumeration)ASSERT_NONE,
			PT_enumeration, "once", get_once_offset(),
				PT_KEYWORD,"ONCE_FALSE",(enumeration)ONCE_FALSE,
				PT_KEYWORD,"ONCE_TRUE",(enumeration)ONCE_TRUE,
				PT_KEYWORD,"ONCE_DONE",(enumeration)ONCE_DONE,
			PT_enumeration, "operation", get_operation_offset(),
				PT_KEYWORD,"FULL",(enumeration)FULL,
				PT_KEYWORD,"REAL",(enumeration)REAL,
				PT_KEYWORD,"IMAGINARY",(enumeration)IMAGINARY,
				PT_KEYWORD,"MAGNITUDE",(enumeration)MAGNITUDE,
				PT_KEYWORD,"ANGLE",(enumeration)ANGLE, // If using, please specify in radians
			PT_complex, "value", get_value_offset(),
			PT_double, "within", get_within_offset(),
			PT_char1024, "target", get_target_offset(),	
			NULL)<1){
				char msg[256];
				sprintf(msg, "unable to publish properties in %s",__FILE__);
				throw msg;
		}

		defaults = this;
		status = ASSERT_TRUE;
		within = 0.0;
		value = 0.0;
		once = ONCE_FALSE;
		once_value = 0;
		operation = FULL;
	}
}
Exemplo n.º 4
0
double_assert::double_assert(MODULE *module)
{
	if (oclass==NULL)
	{
		// register to receive notice for first top down. bottom up, and second top down synchronizations
		oclass = gl_register_class(module,"double_assert",sizeof(double_assert),PC_AUTOLOCK|PC_OBSERVER);
		if (oclass==NULL)
			throw "unable to register class double_assert";
		else
			oclass->trl = TRL_PROVEN;

		if (gl_publish_variable(oclass,
			// TO DO:  publish your variables here
			PT_enumeration,"status",get_status_offset(),PT_DESCRIPTION,"Conditions for the assert checks",
				PT_KEYWORD,"ASSERT_TRUE",(enumeration)ASSERT_TRUE,
				PT_KEYWORD,"ASSERT_FALSE",(enumeration)ASSERT_FALSE,
				PT_KEYWORD,"ASSERT_NONE",(enumeration)ASSERT_NONE,
			PT_enumeration, "once", get_once_offset(),PT_DESCRIPTION,"Conditions for a single assert check",
				PT_KEYWORD,"ONCE_FALSE",(enumeration)ONCE_FALSE,
				PT_KEYWORD,"ONCE_TRUE",(enumeration)ONCE_TRUE,
				PT_KEYWORD,"ONCE_DONE",(enumeration)ONCE_DONE,
			PT_enumeration, "within_mode", get_within_mode_offset(),PT_DESCRIPTION,"Method of applying tolerance",
				PT_KEYWORD,"WITHIN_VALUE",(enumeration)IN_ABS,
				PT_KEYWORD,"WITHIN_RATIO",(enumeration)IN_RATIO,
			PT_double, "value", get_value_offset(),PT_DESCRIPTION,"Value to assert",
			PT_double, "within", get_within_offset(),PT_DESCRIPTION,"Tolerance for a successful assert",
			PT_char1024, "target", get_target_offset(),PT_DESCRIPTION,"Property to perform the assert upon",
			NULL)<1){
				char msg[256];
				sprintf(msg, "unable to publish properties in %s",__FILE__);
				throw msg;
		}

		defaults = this;
		status = ASSERT_TRUE;
		within = 0.0;
		within_mode = IN_ABS;
		value = 0.0;
		once = ONCE_FALSE;
		once_value = 0;
	}
}
Exemplo n.º 5
0
    static void read_value_internal(const std::shared_ptr<type_t>& type, const symbols_t& symbols, reflectable& reflectable)
    {
        // read sub-type values
        if (VAL* base_type_index = get_base_type_index_opt(*type).get())
        {
            VAL& base_type = get_type(*base_type_index);
            read_value_internal(base_type, symbols, reflectable);
        }

        // read current type values
        VAL& field_vector = get_field_vector(*type);
        VAR symbols_iter = std::begin(symbols);
        VAL symbols_end = std::end(symbols);
        for (VAL& field_kvp : field_vector)
        {
            if (symbols_iter != symbols_end)
            {
                VAL& field = field_kvp.second;
                VAL& field_symbol = *symbols_iter;
                VAL& field_type_index = get_type_index(*field);
                VAL& field_type_descriptor = get_type_descriptor(field_type_index);
                VAL& field_ptr = static_cast<char*>(static_cast<void*>(&reflectable)) + get_value_offset(*field);
                read_value(*field_type_descriptor, field_symbol, field_ptr);
                ++symbols_iter;
            }
        }
    }
Exemplo n.º 6
0
    void write_value_internal(const std::shared_ptr<type_t>& type, const reflectable& reflectable, symbols_t& symbols)
    {
        // write sub-type values
        if (VAL* base_type_index = get_base_type_index_opt(*type).get())
        {
            VAL& base_type = get_type(*base_type_index);
            write_value_internal(base_type, reflectable, symbols);
        }

        // write current type values
        VAL& field_vector = get_field_vector(*type);
        for (VAL& field_kvp : field_vector)
        {
            symbol field_symbol_mvb{};
            VAL& field = field_kvp.second;
            VAL& field_type_index = get_type_index(*field);
            VAL& field_type_descriptor = get_type_descriptor(field_type_index);
            VAL& field_ptr = static_cast<const char*>(static_cast<const void*>(&reflectable)) + get_value_offset(*field);
            write_value(*field_type_descriptor, field_ptr, field_symbol_mvb);
            symbols.emplace_back(std::move(field_symbol_mvb));
        }
    }