Sha256: 1b228ee4994b379d201ae9a1db819b3cfe01767144f20712e9a12b5d09733d27

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

/* Copyright (c) 2024 Julian Benda
 *
 * This file is part of inkCPP which is released under MIT license.
 * See file LICENSE.txt or go to
 * https://github.com/JBenda/inkcpp for full license details.
 */
#include "choice.h"

#include "output.h"
#include "string_table.h"
#include "string_utils.h"

namespace ink {
namespace runtime {
	choice& choice::setup( internal::basic_stream& in, internal::string_table& strings, internal::list_table& lists, int index, uint32_t path, thread_t thread, const char* const* tags )
	{
		char* text = nullptr;
		// if we only have one item in our output stream
		if ( in.queued() == 2 )
		{
			// If it's a string, just grab it. Otherwise, use allocation
			const internal::value& data = in.peek();
			switch ( data.type() )
			{
			case internal::value_type::string:
				text = strings.duplicate( data.get<internal::value_type::string>() );
				in.discard( 2 );
				break;
			default:
				text = in.get_alloc( strings, lists );
			}
		}
		else
		{
			// Non-string. Must allocate
			text = in.get_alloc( strings, lists );
		}
		char* end = text;
		while ( *end )
		{
			++end;
		}
		end   = ink::runtime::internal::clean_string<true, true>( text, end );
		*end  = 0;
		_text = text;
		// Index/path
		_index  = index;
		_path   = path;
		_thread = thread;
		_tags   = tags;
		return *this;
	}
}
}   // namespace ink::runtime

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
inkcpp_rb-0.1.3 ext/inkcpp_rb/inkcpp/inkcpp/choice.cpp
inkcpp_rb-0.1.2 ext/inkcpp_rb/inkcpp/inkcpp/choice.cpp
inkcpp_rb-0.1.1 ext/inkcpp_rb/inkcpp/inkcpp/choice.cpp
inkcpp_rb-0.1.0 ext/inkcpp_rb/inkcpp/inkcpp/choice.cpp