-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for tagged choices and new tag syntax
- Loading branch information
Showing
12 changed files
with
168 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,48 @@ | ||
#include "choice.h" | ||
|
||
#include "output.h" | ||
#include "string_utils.h" | ||
#include "string_table.h" | ||
#include "string_utils.h" | ||
|
||
namespace ink | ||
{ | ||
namespace runtime | ||
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 ) | ||
{ | ||
choice& choice::setup(internal::basic_stream& in, internal::string_table& strings, internal::list_table& lists, int index, uint32_t path, thread_t thread) | ||
char* text = nullptr; | ||
// if we only have one item in our output stream | ||
if ( in.queued() == 2 ) | ||
{ | ||
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 | ||
// If it's a string, just grab it. Otherwise, use allocation | ||
const internal::value& data = in.peek(); | ||
switch ( data.type() ) | ||
{ | ||
// Non-string. Must allocate | ||
text = in.get_alloc(strings, lists); | ||
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 ); | ||
} | ||
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; | ||
return *this; | ||
} | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.