text:
// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_OBJECTS_CONTEXTS_H_
#define V8_OBJECTS_CONTEXTS_H_

#include "src/objects/fixed-array.h"
#include "src/objects/function-kind.h"
#include "src/objects/ordered-hash-table.h"
#include "src/objects/osr-optimized-code-cache.h"
#include "torque-generated/field-offsets.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"

namespace v8 {
namespace internal {

class JSGlobalObject;
class JSGlobalProxy;
class MicrotaskQueue;
class NativeContext;
class RegExpMatchInfo;

enum ContextLookupFlags {
  FOLLOW_CONTEXT_CHAIN = 1 << 0,
  FOLLOW_PROTOTYPE_CHAIN = 1 << 1,

  DONT_FOLLOW_CHAINS = 0,
  FOLLOW_CHAINS = FOLLOW_CONTEXT_CHAIN | FOLLOW_PROTOTYPE_CHAIN,
};

// Heap-allocated activation contexts.
//
// Contexts are implemented as FixedArray-like objects having a fixed
// header with a set of common fields.
//
// Note: Context must have no virtual functions and Context objects
// must always be allocated via Heap::AllocateContext() or
// Factory::NewContext.

#define NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V)                     \
  V(GENERATOR_NEXT_INTERNAL, JSFunction, generator_next_internal) \
  V(ASYNC_MODULE_EVALUATE_INTERNAL, JSFunction,                   \
    async_module_evaluate_internal)                               \
  V(OBJECT_CREATE, JSFunction, object_create)                     \
  V(REFLECT_APPLY_INDEX, JSFunction, reflect_apply)               \
  V(REFLECT_CONSTRUCT_INDEX, JSFunction, reflect_construct)       \
  V(MATH_FLOOR_INDEX, JSFunction, math_floor)                     \
  V(MATH_POW_INDEX, JSFunction, math_pow)                         \
  V(PROMISE_INTERNAL_CONSTRUCTOR_INDEX, JSFunction,               \
    promise_internal_constructor)                                 \
  V(PROMISE_THEN_INDEX, JSFunction, promise_then)

#define NATIVE_CONTEXT_FIELDS(V)                                               \
  V(GLOBAL_PROXY_INDEX, JSGlobalProxy, global_proxy_object)                    \
  /* TODO(ishell): Actually we store exactly EmbedderDataArray here but */     \
  /* it's already UBSan-fiendly and doesn't require a star... So declare */    \
  /* it as a HeapObject for now. */                                            \
  V(EMBEDDER_DATA_INDEX, HeapObject, embedder_data)                            \
  V(CONTINUATION_PRESERVED_EMBEDDER_DATA_INDEX, HeapObject,                    \
    continuation_preserved_embedder_data)                                      \
  NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V)                                        \
  /* Below is alpha-sorted */                                                  \
  V(ACCESSOR_PROPERTY_DESCRIPTOR_MAP_INDEX, Map,                               \
    accessor_property_descriptor_map)                                          \
  V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings)    \
  V(ARRAY_BUFFER_FUN_INDEX, JSFunction, array_buffer_fun)                      \
  V(ARRAY_BUFFER_MAP_INDEX, Map, array_buffer_map)                             \
  V(ARRAY_BUFFER_NOINIT_FUN_INDEX, JSFunction, array_buffer_noinit_fun)        \
  V(ARRAY_FUNCTION_INDEX, JSFunction, array_function)                          \
  V(ARRAY_JOIN_STACK_INDEX, HeapObject, array_join_stack)                      \
  V(ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX, Map, async_from_sync_iterator_map)     \
  V(ASYNC_FUNCTION_FUNCTION_INDEX, JSFunction, async_function_constructor)     \
  V(ASYNC_FUNCTION_OBJECT_MAP_INDEX, Map, async_function_object_map)           \
  V(ASYNC_GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction,                       \
    async_generator_function_function)                                         \
  V(ATOMICS_OBJECT, JSObject, atomics_object)                                  \
  V(BIGINT_FUNCTION_INDEX, JSFunction, bigint_function)                        \
  V(BIGINT64_ARRAY_FUN_INDEX, JSFunction, bigint64_array_fun)                  \
  V(BIGUINT64_ARRAY_FUN_INDEX, JSFunction, biguint64_array_fun)                \
  V(BOOLEAN_FUNCTION_INDEX, JSFunction, boolean_function)                      \
  V(BOUND_FUNCTION_WITH_CONSTRUCTOR_MAP_INDEX, Map,                            \
    bound_function_with_constructor_map)                                       \
  V(BOUND_FUNCTION_WITHOUT_CONSTRUCTOR_MAP_INDEX, Map,                         \
    bound_function_without_constructor_map)                                    \
  V(CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, JSFunction,                            \
    call_as_constructor_delegate)                                              \
  V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate)    \
  V(CALL_ASYNC_MODULE_FULFILLED, JSFunction, call_async_module_fulfilled)      \
  V(CALL_ASYNC_MODULE_REJECTED, JSFunction, call_async_module_rejected)        \
  V(CALLSITE_FUNCTION_INDEX, JSFunction, callsite_function)                    \
  V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function)  \
  V(DATA_PROPERTY_DESCRIPTOR_MAP_INDEX, Map, data_property_descriptor_map)     \
  V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun)                            \
  V(DATE_FUNCTION_INDEX, JSFunction, date_function)                            \
  V(DEBUG_CONTEXT_ID_INDEX, Object, debug_context_id)                          \
  V(EMPTY_FUNCTION_INDEX, JSFunction, empty_function)                          \
  V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object,                     \
    error_message_for_code_gen_from_strings)                                   \
  V(ERRORS_THROWN_INDEX, Smi, errors_thrown)                                   \
  V(EXTRAS_BINDING_OBJECT_INDEX, JSObject, extras_binding_object)              \
  V(FAST_ALIASED_ARGUMENTS_MAP_INDEX, Map, fast_aliased_arguments_map)         \
  V(FAST_TEMPLATE_INSTANTIATIONS_CACHE_INDEX, FixedArray,                      \
    fast_template_instantiations_cache)                                        \
  V(FLOAT32_ARRAY_FUN_INDEX, JSFunction, float32_array_fun)                    \
  V(FLOAT64_ARRAY_FUN_INDEX, JSFunction, float64_array_fun)                    \
  V(FUNCTION_FUNCTION_INDEX, JSFunction, function_function)                    \
  V(GENERATOR_FUNCTION_FUNCTION_INDEX, JSFunction,                             \
    generator_function_function)                                               \
  V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map, generator_object_prototype_map) \
  V(ASYNC_GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map,                           \
    async_generator_object_prototype_map)                                      \
  V(INITIAL_ARRAY_ITERATOR_MAP_INDEX, Map, initial_array_iterator_map)         \
  V(INITIAL_ARRAY_ITERATOR_PROTOTYPE_INDEX, JSObject,                          \
    initial_array_iterator_prototype)                                          \
  V(INITIAL_ARRAY_PROTOTYPE_INDEX, JSObject, initial_array_prototype)          \
  V(INITIAL_ERROR_PROTOTYPE_INDEX, JSObject, initial_error_prototype)          \
  V(INITIAL_GENERATOR_PROTOTYPE_INDEX, JSObject, initial_generator_prototype)  \
  V(INITIAL_ASYNC_ITERATOR_PROTOTYPE_INDEX, JSObject,                          \
    initial_async_iterator_prototype)                                          \
  V(INITIAL_ASYNC_GENERATOR_PROTOTYPE_INDEX, JSObject,                         \
    initial_async_generator_prototype)                                         \
  V(INITIAL_ITERATOR_PROTOTYPE_INDEX, JSObject, initial_iterator_prototype)    \
  V(INITIAL_MAP_ITERATOR_PROTOTYPE_INDEX, JSObject,                            \
    initial_map_iterator_prototype)                                            \
  V(INITIAL_MAP_PROTOTYPE_MAP_INDEX, Map, initial_map_prototype_map)           \
  V(INITIAL_OBJECT_PROTOTYPE_INDEX, JSObject, initial_object_prototype)        \
  V(INITIAL_SET_ITERATOR_PROTOTYPE_INDEX, JSObject,                            \
    initial_set_iterator_prototype)                                            \
  V(INITIAL_SET_PROTOTYPE_INDEX, JSObject, initial_set_prototype)              \
  V(INITIAL_SET_PROTOTYPE_MAP_INDEX, Map, initial_set_prototype_map)           \
  V(INITIAL_STRING_ITERATOR_MAP_INDEX, Map, initial_string_iterator_map)       \
  V(INITIAL_STRING_ITERATOR_PROTOTYPE_INDEX, JSObject,                         \
    initial_string_iterator_prototype)                                         \
  V(INITIAL_STRING_PROTOTYPE_INDEX, JSObject, initial_string_prototype)        \
  V(INITIAL_WEAKMAP_PROTOTYPE_MAP_INDEX, Map, initial_weakmap_prototype_map)   \
  V(INITIAL_WEAKSET_PROTOTYPE_MAP_INDEX, Map, initial_weakset_prototype_map)   \
  V(INT16_ARRAY_FUN_INDEX, JSFunction, int16_array_fun)                        \
  V(INT32_ARRAY_FUN_INDEX, JSFunction, int32_array_fun)                        \
  V(INT8_ARRAY_FUN_INDEX, JSFunction, int8_array_fun)                          \
  V(INTL_COLLATOR_FUNCTION_INDEX, JSFunction, intl_collator_function)          \
  V(INTL_DATE_TIME_FORMAT_FUNCTION_INDEX, JSFunction,                          \
    intl_date_time_format_function)                                            \
  V(INTL_DISPLAY_NAMES_FUNCTION_INDEX, JSFunction,                             \
    intl_display_names_function)                                               \
  V(INTL_NUMBER_FORMAT_FUNCTION_INDEX, JSFunction,                             \
    intl_number_format_function)                                               \
  V(INTL_LOCALE_FUNCTION_INDEX, JSFunction, intl_locale_function)              \
  V(INTL_LIST_FORMAT_FUNCTION_INDEX, JSFunction, intl_list_format_function)    \
  V(INTL_PLURAL_RULES_FUNCTION_INDEX, JSFunction, intl_plural_rules_function)  \
  V(INTL_RELATIVE_TIME_FORMAT_FUNCTION_INDEX, JSFunction,                      \
    intl_relative_time_format_function)                                        \
  V(INTL_SEGMENTER_FUNCTION_INDEX, JSFunction, intl_segmenter_function)        \
  V(INTL_SEGMENTS_MAP_INDEX, Map, intl_segments_map)                           \
  V(INTL_SEGMENT_ITERATOR_MAP_INDEX, Map, intl_segment_iterator_map)           \
  V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map)                       \
  V(JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX, Map,                               \
    js_array_packed_smi_elements_map)                                          \
  V(JS_ARRAY_HOLEY_SMI_ELEMENTS_MAP_INDEX, Map,                                \
    js_array_holey_smi_elements_map)                                           \
  V(JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX, Map, js_array_packed_elements_map)     \
  V(JS_ARRAY_HOLEY_ELEMENTS_MAP_INDEX, Map, js_array_holey_elements_map)       \
  V(JS_ARRAY_PACKED_DOUBLE_ELEMENTS_MAP_INDEX, Map,                            \
    js_array_packed_double_elements_map)                                       \
  V(JS_ARRAY_HOLEY_DOUBLE_ELEMENTS_MAP_INDEX, Map,                             \
    js_array_holey_double_elements_map)                                        \
  V(JS_MAP_FUN_INDEX, JSFunction, js_map_fun)                                  \
  V(JS_MAP_MAP_INDEX, Map, js_map_map)                                         \
  V(JS_MODULE_NAMESPACE_MAP, Map, js_module_namespace_map)                     \
  V(JS_SET_FUN_INDEX, JSFunction, js_set_fun)                                  \
  V(JS_SET_MAP_INDEX, Map, js_set_map)                                         \
  V(JS_WEAK_MAP_FUN_INDEX, JSFunction, js_weak_map_fun)                        \
  V(JS_WEAK_SET_FUN_INDEX, JSFunction, js_weak_set_fun)                        \
  V(JS_WEAK_REF_FUNCTION_INDEX, JSFunction, js_weak_ref_fun)                   \
  V(JS_FINALIZATION_REGISTRY_FUNCTION_INDEX, JSFunction,                       \
    js_finalization_registry_fun)                                              \
  /* Context maps */                                                           \
  V(NATIVE_CONTEXT_MAP_INDEX, Map, native_context_map)                         \
  V(FUNCTION_CONTEXT_MAP_INDEX, Map, function_context_map)                     \
  V(MODULE_CONTEXT_MAP_INDEX, Map, module_context_map)                         \
  V(EVAL_CONTEXT_MAP_INDEX, Map, eval_context_map)                             \
  V(SCRIPT_CONTEXT_MAP_INDEX, Map, script_context_map)                         \
  V(AWAIT_CONTEXT_MAP_INDEX, Map, await_context_map)                           \
  V(BLOCK_CONTEXT_MAP_INDEX, Map, block_context_map)                           \
  V(CATCH_CONTEXT_MAP_INDEX, Map, catch_context_map)                           \
  V(WITH_CONTEXT_MAP_INDEX, Map, with_context_map)                             \
  V(DEBUG_EVALUATE_CONTEXT_MAP_INDEX, Map, debug_evaluate_context_map)         \
  V(MAP_CACHE_INDEX, Object, map_cache)                                        \
  V(MAP_KEY_ITERATOR_MAP_INDEX, Map, map_key_iterator_map)                     \
  V(MAP_KEY_VALUE_ITERATOR_MAP_INDEX, Map, map_key_value_iterator_map)         \
  V(MAP_VALUE_ITERATOR_MAP_INDEX, Map, map_value_iterator_map)                 \
  V(MATH_RANDOM_INDEX_INDEX, Smi, math_random_index)                           \
  V(MATH_RANDOM_STATE_INDEX, ByteArray, math_random_state)                     \
  V(MATH_RANDOM_CACHE_INDEX, FixedDoubleArray, math_random_cache)              \
  V(MESSAGE_LISTENERS_INDEX, TemplateList, message_listeners)                  \
  V(NORMALIZED_MAP_CACHE_INDEX, Object, normalized_map_cache)                  \
  V(NUMBER_FUNCTION_INDEX, JSFunction, number_function)                        \
  V(OBJECT_FUNCTION_INDEX, JSFunction, object_function)                        \
  V(OBJECT_FUNCTION_PROTOTYPE_MAP_INDEX, Map, object_function_prototype_map)   \
  V(PROXY_CALLABLE_MAP_INDEX, Map, proxy_callable_map)                         \
  V(PROXY_CONSTRUCTOR_MAP_INDEX, Map, proxy_constructor_map)                   \
  V(PROXY_FUNCTION_INDEX, JSFunction, proxy_function)                          \
  V(PROXY_MAP_INDEX, Map, proxy_map)                                           \
  V(PROXY_REVOCABLE_RESULT_MAP_INDEX, Map, proxy_revocable_result_map)         \
  V(PROMISE_PROTOTYPE_INDEX, JSObject, promise_prototype)                      \
  V(RECORDER_CONTEXT_ID, Object, recorder_context_id)                          \
  V(REGEXP_EXEC_FUNCTION_INDEX, JSFunction, regexp_exec_function)              \
  V(REGEXP_FUNCTION_INDEX, JSFunction, regexp_function)                        \
  V(REGEXP_LAST_MATCH_INFO_INDEX, RegExpMatchInfo, regexp_last_match_info)     \
  V(REGEXP_MATCH_ALL_FUNCTION_INDEX, JSFunction, regexp_match_all_function)    \
  V(REGEXP_MATCH_FUNCTION_INDEX, JSFunction, regexp_match_function)            \
  V(REGEXP_PROTOTYPE_INDEX, JSObject, regexp_prototype)                        \
  V(REGEXP_PROTOTYPE_MAP_INDEX, Map, regexp_prototype_map)                     \
  V(REGEXP_REPLACE_FUNCTION_INDEX, JSFunction, regexp_replace_function)        \
  V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map)                           \
  V(REGEXP_RESULT_INDICES_MAP_INDEX, Map, regexp_result_indices_map)           \
  V(REGEXP_SEARCH_FUNCTION_INDEX, JSFunction, regexp_search_function)          \
  V(REGEXP_SPLIT_FUNCTION_INDEX, JSFunction, regexp_split_function)            \
  V(INITIAL_REGEXP_STRING_ITERATOR_PROTOTYPE_MAP_INDEX, Map,                   \
    initial_regexp_string_iterator_prototype_map)                              \
  V(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table)      \
  V(SCRIPT_EXECUTION_CALLBACK_INDEX, Object, script_execution_callback)        \
  V(SECURITY_TOKEN_INDEX, Object, security_token)                              \
  V(SERIALIZED_OBJECTS, FixedArray, serialized_objects)                        \
  V(SET_VALUE_ITERATOR_MAP_INDEX, Map, set_value_iterator_map)                 \
  V(SET_KEY_VALUE_ITERATOR_MAP_INDEX, Map, set_key_value_iterator_map)         \
  V(SHARED_ARRAY_BUFFER_FUN_INDEX, JSFunction, shared_array_buffer_fun)        \
  V(SLOPPY_ARGUMENTS_MAP_INDEX, Map, sloppy_arguments_map)                     \
  V(SLOW_ALIASED_ARGUMENTS_MAP_INDEX, Map, slow_aliased_arguments_map)         \
  V(STRICT_ARGUMENTS_MAP_INDEX, Map, strict_arguments_map)                     \
  V(SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP, Map,                                  \
    slow_object_with_null_prototype_map)                                       \
  V(SLOW_OBJECT_WITH_OBJECT_PROTOTYPE_MAP, Map,                                \
    slow_object_with_object_prototype_map)                                     \
  V(SLOW_TEMPLATE_INSTANTIATIONS_CACHE_INDEX, SimpleNumberDictionary,          \
    slow_template_instantiations_cache)                                        \
  V(ATOMICS_WAITASYNC_PROMISES, OrderedHashSet, atomics_waitasync_promises)    \
  /* Fast Path Protectors */                                                   \
  V(REGEXP_SPECIES_PROTECTOR_INDEX, PropertyCell, regexp_species_protector)    \
  /* All *_FUNCTION_MAP_INDEX definitions used by Context::FunctionMapIndex */ \
  /* must remain together. */                                                  \
  V(SLOPPY_FUNCTION_MAP_INDEX, Map, sloppy_function_map)                       \
  V(SLOPPY_FUNCTION_WITH_NAME_MAP_INDEX, Map, sloppy_function_with_name_map)   \
  V(SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map,                          \
    sloppy_function_without_prototype_map)                                     \
  V(SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map,                    \
    sloppy_function_with_readonly_prototype_map)                               \
  V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map)                       \
  V(STRICT_FUNCTION_WITH_NAME_MAP_INDEX, Map, strict_function_with_name_map)   \
  V(STRICT_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map,                    \
    strict_function_with_readonly_prototype_map)                               \
  V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map,                          \
    strict_function_without_prototype_map)                                     \
  V(METHOD_WITH_NAME_MAP_INDEX, Map, method_with_name_map)                     \
  V(METHOD_WITH_HOME_OBJECT_MAP_INDEX, Map, method_with_home_object_map)       \
  V(METHOD_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map,                           \
    method_with_name_and_home_object_map)                                      \
  V(ASYNC_FUNCTION_MAP_INDEX, Map, async_function_map)                         \
  V(ASYNC_FUNCTION_WITH_NAME_MAP_INDEX, Map, async_function_with_name_map)     \
  V(ASYNC_FUNCTION_WITH_HOME_OBJECT_MAP_INDEX, Map,                            \
    async_function_with_home_object_map)                                       \
  V(ASYNC_FUNCTION_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map,                   \
    async_function_with_name_and_home_object_map)                              \
  V(GENERATOR_FUNCTION_MAP_INDEX, Map, generator_function_map)                 \
  V(GENERATOR_FUNCTION_WITH_NAME_MAP_INDEX, Map,                               \
    generator_function_with_name_map)                                          \
  V(GENERATOR_FUNCTION_WITH_HOME_OBJECT_MAP_INDEX, Map,                        \
    generator_function_with_home_object_map)                                   \
  V(GENERATOR_FUNCTION_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map,               \
    generator_function_with_name_and_home_object_map)                          \
  V(ASYNC_GENERATOR_FUNCTION_MAP_INDEX, Map, async_generator_function_map)     \
  V(ASYNC_GENERATOR_FUNCTION_WITH_NAME_MAP_INDEX, Map,                         \
    async_generator_function_with_name_map)                                    \
  V(ASYNC_GENERATOR_FUNCTION_WITH_HOME_OBJECT_MAP_INDEX, Map,                  \
    async_generator_function_with_home_object_map)                             \
  V(ASYNC_GENERATOR_FUNCTION_WITH_NAME_AND_HOME_OBJECT_MAP_INDEX, Map,         \
    async_generator_function_with_name_and_home_object_map)                    \
  V(CLASS_FUNCTION_MAP_INDEX, Map, class_function_map)                         \
  V(STRING_FUNCTION_INDEX, JSFunction, string_function)                        \
  V(STRING_FUNCTION_PROTOTYPE_MAP_INDEX, Map, string_function_prototype_map)   \
  V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function)                        \
  V(WASM_EXPORTED_FUNCTION_MAP_INDEX, Map, wasm_exported_function_map)         \
  V(WASM_EXCEPTION_CONSTRUCTOR_INDEX, JSFunction, wasm_exception_constructor)  \
  V(WASM_GLOBAL_CONSTRUCTOR_INDEX, JSFunction, wasm_global_constructor)        \
  V(WASM_INSTANCE_CONSTRUCTOR_INDEX, JSFunction, wasm_instance_constructor)    \
  V(WASM_MEMORY_CONSTRUCTOR_INDEX, JSFunction, wasm_memory_constructor)        \
  V(WASM_MODULE_CONSTRUCTOR_INDEX, JSFunction, wasm_module_constructor)        \
  V(WASM_TABLE_CONSTRUCTOR_INDEX, JSFunction, wasm_table_constructor)          \
  V(TEMPLATE_WEAKMAP_INDEX, HeapObject, template_weakmap)                      \
  V(TYPED_ARRAY_FUN_INDEX, JSFunction, typed_array_function)                   \
  V(TYPED_ARRAY_PROTOTYPE_INDEX, JSObject, typed_array_prototype)              \
  V(UINT16_ARRAY_FUN_INDEX, JSFunction, uint16_array_fun)                      \
  V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun)                      \
  V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun)                        \
  V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun)        \
  V(ARRAY_ENTRIES_ITERATOR_INDEX, JSFunction, array_entries_iterator)          \
  V(ARRAY_FOR_EACH_ITERATOR_INDEX, JSFunction, array_for_each_iterator)        \
  V(ARRAY_KEYS_ITERATOR_INDEX, JSFunction, array_keys_iterator)                \
  V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator)            \
  V(ERROR_FUNCTION_INDEX, JSFunction, error_function)                          \
  V(ERROR_TO_STRING, JSFunction, error_to_string)                              \
  V(EVAL_ERROR_FUNCTION_INDEX, JSFunction, eval_error_function)                \
  V(AGGREGATE_ERROR_FUNCTION_INDEX, JSFunction, aggregate_error_function)      \
  V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun)                        \
  V(GLOBAL_PROXY_FUNCTION_INDEX, JSFunction, global_proxy_function)            \
  V(MAP_DELETE_INDEX, JSFunction, map_delete)                                  \
  V(MAP_GET_INDEX, JSFunction, map_get)                                        \
  V(MAP_HAS_INDEX, JSFunction, map_has)                                        \
  V(MAP_SET_INDEX, JSFunction, map_set)                                        \
  V(FINALIZATION_REGISTRY_CLEANUP_SOME, JSFunction,                            \
    finalization_registry_cleanup_some)                                        \
  V(FUNCTION_HAS_INSTANCE_INDEX, JSFunction, function_has_instance)            \
  V(FUNCTION_TO_STRING_INDEX, JSFunction, function_to_string)                  \
  V(OBJECT_TO_STRING, JSFunction, object_to_string)                            \
  V(OBJECT_VALUE_OF_FUNCTION_INDEX, JSFunction, object_value_of_function)      \
  V(PROMISE_ALL_INDEX, JSFunction, promise_all)                                \
  V(PROMISE_ANY_INDEX, JSFunction, promise_any)                                \
  V(PROMISE_CATCH_INDEX, JSFunction, promise_catch)                            \
  V(PROMISE_FUNCTION_INDEX, JSFunction, promise_function)                      \
  V(RANGE_ERROR_FUNCTION_INDEX, JSFunction, range_error_function)              \
  V(REFERENCE_ERROR_FUNCTION_INDEX, JSFunction, reference_error_function)      \
  V(SET_ADD_INDEX, JSFunction, set_add)                                        \
  V(SET_DELETE_INDEX, JSFunction, set_delete)                                  \
  V(SET_HAS_INDEX, JSFunction, set_has)                                        \
  V(SYNTAX_ERROR_FUNCTION_INDEX, JSFunction, syntax_error_function)            \
  V(TYPE_ERROR_FUNCTION_INDEX, JSFunction, type_error_function)                \
  V(URI_ERROR_FUNCTION_INDEX, JSFunction, uri_error_function)                  \
  V(WASM_COMPILE_ERROR_FUNCTION_INDEX, JSFunction,                             \
    wasm_compile_error_function)                                               \
  V(WASM_LINK_ERROR_FUNCTION_INDEX, JSFunction, wasm_link_error_function)      \
  V(WASM_RUNTIME_ERROR_FUNCTION_INDEX, JSFunction,                             \
    wasm_runtime_error_function)                                               \
  V(WEAKMAP_SET_INDEX, JSFunction, weakmap_set)                                \
  V(WEAKMAP_GET_INDEX, JSFunction, weakmap_get)                                \
  V(WEAKSET_ADD_INDEX, JSFunction, weakset_add)                                \
  V(RETAINED_MAPS, WeakArrayList, retained_maps)                               \
  V(OSR_CODE_CACHE_INDEX, WeakFixedArray, osr_code_cache)

// A table of all script contexts. Every loaded top-level script with top-level
// lexical declarations contributes its ScriptContext into this table.
//
// The table is a fixed array, its first slot is the current used count and
// the subsequent slots 1..used contain ScriptContexts.
class ScriptContextTable : public FixedArray {
 public:
  DECL_CAST(ScriptContextTable)

  struct LookupResult {
    int context_index;
    int slot_index;
    VariableMode mode;
    InitializationFlag init_flag;
    MaybeAssignedFlag maybe_assigned_flag;
  };

  inline int synchronized_used() const;
  inline void synchronized_set_used(int used);

  static inline Handle<Context> GetContext(Isolate* isolate,
                                           Handle<ScriptContextTable> table,
                                           int i);
  inline Context get_context(int i) const;

  // Lookup a variable `name` in a ScriptContextTable.
  // If it returns true, the variable is found and `result` contains
  // valid information about its location.
  // If it returns false, `result` is untouched.
  V8_WARN_UNUSED_RESULT
  V8_EXPORT_PRIVATE static bool Lookup(Isolate* isolate,
                                       ScriptContextTable table, String name,
                                       LookupResult* result);

  V8_WARN_UNUSED_RESULT
  V8_EXPORT_PRIVATE static Handle<ScriptContextTable> Extend(
      Handle<ScriptContextTable> table, Handle<Context> script_context);

  static const int kUsedSlotIndex = 0;
  static const int kFirstContextSlotIndex = 1;
  static const int kMinLength = kFirstContextSlotIndex;

  OBJECT_CONSTRUCTORS(ScriptContextTable, FixedArray);
};

// JSFunctions are pairs (context, function code), sometimes also called
// closures. A Context object is used to represent function contexts and
// dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak).
//
// At runtime, the contexts build a stack in parallel to the execution
// stack, with the top-most context being the current context. All contexts
// have the following slots:
//
// [ scope_info     ]  This is the scope info describing the current context. It
//                     contains the names of statically allocated context slots,
//                     and stack-allocated locals.  The names are needed for
//                     dynamic lookups in the presence of 'with' or 'eval', and
//                     for the debugger.
//
// [ previous       ]  A pointer to the previous context.
//
// [ extension      ]  Additional data. This slot is only available when
//                     extension_bit is set. Check using has_extension.
//
//                     For native contexts, it contains the global object.
//                     For module contexts, it contains the module object.
//                     For await contexts, it contains the generator object.
//                     For var block contexts, it may contain an "extension
//                     object".
//                     For with contexts, it contains an "extension object".
//
//                     An "extension object" is used to dynamically extend a
//                     context with additional variables, namely in the
//                     implementation of the 'with' construct and the 'eval'
//                     construct.  For instance, Context::Lookup also searches
//                     the extension object for properties.  (Storing the
//                     extension object is the original purpose of this context
//                     slot, hence the name.)
//
// In addition, function contexts with sloppy eval may have statically
// allocated context slots to store local variables/functions that are accessed
// from inner functions (via static context addresses) or through 'eval'
// (dynamic context lookups).
// The native context contains additional slots for fast access to native
// properties.
//
// Finally, with Harmony scoping, the JSFunction representing a top level
// script will have the ScriptContext rather than a FunctionContext.
// Script contexts from all top-level scripts are gathered in
// ScriptContextTable.

class Context : public HeapObject {
 public:
  NEVER_READ_ONLY_SPACE

  DECL_CAST(Context)
  // [length]: length of the context.
  V8_INLINE int length() const;
  V8_INLINE void set_length(int value);

  // Setter and getter for elements.
  V8_INLINE Object get(int index) const;
  V8_INLINE Object get(IsolateRoot isolate, int index) const;
  V8_INLINE void set(int index, Object value);
  // Setter with explicit barrier mode.
  V8_INLINE void set(int index, Object value, WriteBarrierMode mode);
  // Setter and getter with synchronization semantics.
  V8_INLINE Object synchronized_get(int index) const;
  V8_INLINE Object synchronized_get(IsolateRoot isolate, int index) const;
  V8_INLINE void synchronized_set(int index, Object value);

  DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
                                TORQUE_GENERATED_CONTEXT_FIELDS)
  static const int kScopeInfoOffset = kHeaderSize;
  static const int kPreviousOffset = kScopeInfoOffset + kTaggedSize;

  // TODO(v8:8989): [torque] Support marker constants
  /* TODO(ishell): remove this fixedArray-like header size. */
  static const int kFixedArrayLikeHeaderSize = kScopeInfoOffset;
  static const int kStartOfTaggedFieldsOffset = kScopeInfoOffset;
  /* Header size. */                                                  \
  /* TODO(ishell): use this as header size once MIN_CONTEXT_SLOTS */  \
  /* is removed in favour of offset-based access to common fields. */ \
  static const int kTodoHeaderSize = kPreviousOffset + kTaggedSize;

  // If the extension slot exists, it is the first slot after the header.
  static const int kExtensionOffset = kTodoHeaderSize;

  // Garbage collection support.
  V8_INLINE static constexpr int SizeFor(int length) {
    return kFixedArrayLikeHeaderSize + length * kTaggedSize;
  }

  // Code Generation support.
  // Offset of the element from the beginning of object.
  V8_INLINE static constexpr int OffsetOfElementAt(int index) {
    return SizeFor(index);
  }
  // Offset of the element from the heap object pointer.
  V8_INLINE static constexpr int SlotOffset(int index) {
    return SizeFor(index) - kHeapObjectTag;
  }

  // Initializes the variable slots of the context. Lexical variables that need
  // initialization are filled with the hole.
  void Initialize(Isolate* isolate);

  // TODO(ishell): eventually migrate to the offset based access instead of
  // index-based.
  // The default context slot layout; indices are FixedArray slot indices.
  enum Field {
    // TODO(shell): use offset-based approach for accessing common values.
    // These slots are in all contexts.
    SCOPE_INFO_INDEX,
    PREVIOUS_INDEX,

    // This slot only exists if the extension_flag bit is set.
    EXTENSION_INDEX,

// These slots are only in native contexts.
#define NATIVE_CONTEXT_SLOT(index, type, name) index,
    NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_SLOT)
#undef NATIVE_CONTEXT_SLOT

    // Properties from here are treated as weak references by the full GC.
    // Scavenge treats them as strong references.
    OPTIMIZED_CODE_LIST,    // Weak.
    DEOPTIMIZED_CODE_LIST,  // Weak.
    NEXT_CONTEXT_LINK,      // Weak.

    // Total number of slots.
    NATIVE_CONTEXT_SLOTS,
    FIRST_WEAK_SLOT = OPTIMIZED_CODE_LIST,
    FIRST_JS_ARRAY_MAP_SLOT = JS_ARRAY_PACKED_SMI_ELEMENTS_MAP_INDEX,

    // TODO(shell): Remove, once it becomes zero
    MIN_CONTEXT_SLOTS = EXTENSION_INDEX,
    MIN_CONTEXT_EXTENDED_SLOTS = EXTENSION_INDEX + 1,

    // This slot holds the thrown value in catch contexts.
    THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS,

    // These slots hold values in debug evaluate contexts.
    WRAPPED_CONTEXT_INDEX = MIN_CONTEXT_EXTENDED_SLOTS,
    BLOCK_LIST_INDEX = MIN_CONTEXT_EXTENDED_SLOTS + 1
  };

  static const int kExtensionSize =
      (MIN_CONTEXT_EXTENDED_SLOTS - MIN_CONTEXT_SLOTS) * kTaggedSize;
  static const int kExtendedHeaderSize = kTodoHeaderSize + kExtensionSize;

  // A region of native context entries containing maps for functions created
  // by Builtins::kFastNewClosure.
  static const int FIRST_FUNCTION_MAP_INDEX = SLOPPY_FUNCTION_MAP_INDEX;
  static const int LAST_FUNCTION_MAP_INDEX = CLASS_FUNCTION_MAP_INDEX;

  static const int kNoContext = 0;
  static const int kInvalidContext = 1;

  // Direct slot access.
  inline void set_scope_info(ScopeInfo scope_info);

  inline Object unchecked_previous();
  inline Context previous();
  inline void set_previous(Context context);

  inline Object next_context_link();

  inline bool has_extension();
  inline HeapObject extension();
  inline void set_extension(HeapObject object);
  JSObject extension_object();
  JSReceiver extension_receiver();
  V8_EXPORT_PRIVATE ScopeInfo scope_info();

  // Find the module context (assuming there is one) and return the associated
  // module object.
  SourceTextModule module();

  // Get the context where var declarations will be hoisted to, which
  // may be the context itself.
  Context declaration_context();
  bool is_declaration_context();

  // Get the next closure's context on the context chain.
  Context closure_context();

  // Returns a JSGlobalProxy object or null.
  V8_EXPORT_PRIVATE JSGlobalProxy global_proxy();

  // Get the JSGlobalObject object.
  V8_EXPORT_PRIVATE JSGlobalObject global_object();

  // Get the script context by traversing the context chain.
  Context script_context();

  // Compute the native context.
  inline NativeContext native_context() const;

  // Predicates for context types.  IsNativeContext is already defined on
  // Object.
  inline bool IsFunctionContext() const;
  inline bool IsCatchContext() const;
  inline bool IsWithContext() const;
  inline bool IsDebugEvaluateContext() const;
  inline bool IsAwaitContext() const;
  inline bool IsBlockContext() const;
  inline bool IsModuleContext() const;
  inline bool IsEvalContext() const;
  inline bool IsScriptContext() const;

  inline bool HasSameSecurityTokenAs(Context that) const;

  Handle<Object> ErrorMessageForCodeGenerationFromStrings();

  static int IntrinsicIndexForName(Handle<String> name);
  static int IntrinsicIndexForName(const unsigned char* name, int length);

#define NATIVE_CONTEXT_FIELD_ACCESSORS(index, type, name) \
  inline void set_##name(type value);                     \
  inline bool is_##name(type value) const;                \
  inline type name() const;
  NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSORS)
#undef NATIVE_CONTEXT_FIELD_ACCESSORS

  // Lookup the slot called name, starting with the current context.
  // There are three possibilities:
  //
  // 1) result->IsContext():
  //    The binding was found in a context.  *index is always the
  //    non-negative slot index.  *attributes is NONE for var and let
  //    declarations, READ_ONLY for const declarations (never ABSENT).
  //
  // 2) result->IsJSObject():
  //    The binding was found as a named property in a context extension
  //    object (i.e., was introduced via eval), as a property on the subject
  //    of with, or as a property of the global object.  *index is -1 and
  //    *attributes is not ABSENT.
  //
  // 3) result->IsModule():
  //    The binding was found in module imports or exports.
  //     *attributes is never ABSENT. imports are READ_ONLY.
  //
  // 4) result.is_null():
  //    There was no binding found, *index is always -1 and *attributes is
  //    always ABSENT.
  static Handle<Object> Lookup(Handle<Context> context, Handle<String> name,
                               ContextLookupFlags flags, int* index,
                               PropertyAttributes* attributes,
                               InitializationFlag* init_flag,
                               VariableMode* variable_mode,
                               bool* is_sloppy_function_name = nullptr);

  static inline int FunctionMapIndex(LanguageMode language_mode,
                                     FunctionKind kind, bool has_shared_name,
                                     bool needs_home_object);

  static int ArrayMapIndex(ElementsKind elements_kind) {
    DCHECK(IsFastElementsKind(elements_kind));
    return elements_kind + FIRST_JS_ARRAY_MAP_SLOT;
  }

  inline Map GetInitialJSArrayMap(ElementsKind kind) const;

  static const int kNotFound = -1;

  // Dispatched behavior.
  DECL_PRINTER(Context)
  DECL_VERIFIER(Context)

  using BodyDescriptor = FlexibleBodyDescriptor<kStartOfTaggedFieldsOffset>;

 private:
#ifdef DEBUG
  // Bootstrapping-aware type checks.
  static bool IsBootstrappingOrValidParentContext(Object object, Context kid);
#endif

  OBJECT_CONSTRUCTORS(Context, HeapObject);
};

class NativeContext : public Context {
 public:
  DECL_CAST(NativeContext)
  // TODO(neis): Move some stuff from Context here.

  inline void AllocateExternalPointerEntries(Isolate* isolate);

  // [microtask_queue]: pointer to the MicrotaskQueue object.
  DECL_GETTER(microtask_queue, MicrotaskQueue*)
  inline void set_microtask_queue(Isolate* isolate, MicrotaskQueue* queue);

  inline void synchronized_set_script_context_table(
      ScriptContextTable script_context_table);
  inline ScriptContextTable synchronized_script_context_table() const;

  // Dispatched behavior.
  DECL_PRINTER(NativeContext)
  DECL_VERIFIER(NativeContext)

  // Layout description.
#define NATIVE_CONTEXT_FIELDS_DEF(V)                                        \
  /* TODO(ishell): move definition of common context offsets to Context. */ \
  V(kStartOfNativeContextFieldsOffset,                                      \
    (FIRST_WEAK_SLOT - MIN_CONTEXT_EXTENDED_SLOTS) * kTaggedSize)           \
  V(kEndOfStrongFieldsOffset, 0)                                            \
  V(kStartOfWeakFieldsOffset,                                               \
    (NATIVE_CONTEXT_SLOTS - FIRST_WEAK_SLOT) * kTaggedSize)                 \
  V(kEndOfWeakFieldsOffset, 0)                                              \
  V(kEndOfNativeContextFieldsOffset, 0)                                     \
  V(kEndOfTaggedFieldsOffset, 0)                                            \
  /* Raw data. */                                                           \
  V(kMicrotaskQueueOffset, kSystemPointerSize)                              \
  /* Total size. */                                                         \
  V(kSize, 0)

  DEFINE_FIELD_OFFSET_CONSTANTS(Context::kExtendedHeaderSize,
                                NATIVE_CONTEXT_FIELDS_DEF)
#undef NATIVE_CONTEXT_FIELDS_DEF

  class BodyDescriptor;

  // The native context stores a list of all optimized code and a list of all
  // deoptimized code, which are needed by the deoptimizer.
  V8_EXPORT_PRIVATE void AddOptimizedCode(Code code);
  void SetOptimizedCodeListHead(Object head);
  Object OptimizedCodeListHead();
  void SetDeoptimizedCodeListHead(Object head);
  Object DeoptimizedCodeListHead();

  inline OSROptimizedCodeCache GetOSROptimizedCodeCache();

  void ResetErrorsThrown();
  void IncrementErrorsThrown();
  int GetErrorsThrown();

 private:
  STATIC_ASSERT(OffsetOfElementAt(EMBEDDER_DATA_INDEX) ==
                Internals::kNativeContextEmbedderDataOffset);

  OBJECT_CONSTRUCTORS(NativeContext, Context);
};

using ContextField = Context::Field;

}  // namespace internal
}  // namespace v8

#include "src/objects/object-macros-undef.h"

#endif  // V8_OBJECTS_CONTEXTS_H_


text:
using glm::mat4;

class SceneToon : public Scene
{
private:
    GLSLProgram prog;

    int width, height;
    float tPrev;
    VBOPlane *plane;
    VBOTeapot *teapot;
    VBOTorus *torus;

    mat4 model;
    mat4 view;
    mat4 projection;
    float angle;

    void setMatrices();
    void compileAndLinkShader();

public:
    SceneToon();

    void initScene();
    void update( float t );
    void render();
    void resize(int, int);
};

#endif //GL4COOKBOOK_SCENETOON_H

redpajama_set_name: RedPajamaGithub


text:
var miniExcludes = {
		"put-selector/README.md": 1,
		"put-selector/package": 1
	},
	amdExcludes = {
	},
	copyOnly = {
		"put-selector/node-html": 1
	},
	isJsRe = /\.js$/,
	isTestRe = /\/test\//;

var profile = {
	resourceTags: {
		test: function(filename, mid){
			return isTestRe.test(filename);
		},

		miniExclude: function(filename, mid){
			return isTestRe.test(filename) || mid in miniExcludes;
		},

		amd: function(filename, mid){
			return isJsRe.test(filename) && !(mid in amdExcludes);
		},

		copyOnly: function(filename, mid){
			return mid in copyOnly;
		}
	}
};


text:
from eunike.objects import EIOOAM, EIOOXM
from eunike.routing.backendmgr import BackendManager
from satella.instrumentation import CounterCollection

def register_objects(rlayer, confobjs, oams, oxms, insmgr):
    """
    Called as part of Routing Layer initialization

    @type oams: dict(handle::str => OAMInterface)
    @type oxms: dict(handle::str => OXMInterface)
    @param insmgr: root CounterCollection
    """

    eio_oam = {}
    bem = BackendManager(rlayer)

    for handle, oamcls in oams.items():
        sec, = [x for x in confobjs['oams'] if x['handle'] == handle]
        cc = CounterCollection('a-%s' % (handle, ), u'OAM %s' % (handle, ))
        insmgr.add(cc)
        io = EIOOAM(handle, rlayer, bem)
        eio_oam[handle] = oamcls(io, sec, cc), io, sec, cc

    eio_oxm = {}

    for handle, oxmcls in oxms.items():
        sec, = [x for x in confobjs['oxms'] if x['handle'] == handle]
        cc = CounterCollection('x-%s' % (handle, ), u'OXM %s' % (handle, ))
        insmgr.add(cc)
        io = EIOOXM(handle, rlayer, bem)
        eio_oxm[handle] = oxmcls(io, sec, cc), io, sec, cc

    bem.add_backends(eio_oam, eio_oxm)

    rlayer.bm = bem


text:
<component name="ArtifactManager">
  <artifact type="apk" name="artifact5">
    <output-path>$PROJECT_DIR$/out/artifacts/artifact1</output-path>
    <properties id="android-properties">
      <options>
        <option name="runProGuard" value="true" />
      </options>
    </properties>
    <root id="archive" name="artifact1.apk">
      <element id="android-final-package" facet="module1/android/Android" />
    </root>
  </artifact>
</component>


text:
import './accounts.js';
import './register-api.js';
import './slingshot';
import './fixtures';    // Temporary data


text:
package cmdline

import (
	"regexp"
)

type command struct {
	name         string
	description  string
	minArgs      int
	maxArgs      int
	areArgsValid func([]string) bool
	usage        string
}

var (
	START_COMMAND = &command{
		name: "start",
		description: "Start the h2c process. The h2c process must be started before running any other\n" +
			"command. To run h2c as a background process, run '" + StartCmd + "'.",
		minArgs: 0,
		maxArgs: 0,
		usage:   "h2c start [options]",
	}
	CONNECT_COMMAND = &command{
		name:        "connect",
		description: "Connect to a server using https.",
		minArgs:     1,
		maxArgs:     1,
		areArgsValid: func(args []string) bool {
			return regexp.MustCompile("^(https?://)?[^:]+(:[0-9]+)?$").MatchString(args[0])
		},
		usage: "h2c connect [options] <host>:<port>",
	}
	DISCONNECT_COMMAND = &command{
		name:        "disconnect",
		description: "Disconnect from server.",
		minArgs:     0,
		maxArgs:     0,
		usage:       "h2c disconnect",
	}
	GET_COMMAND = &command{
		name:        "get",
		description: "Perform a GET request.",
		minArgs:     1,
		maxArgs:     1,
		areArgsValid: func(args []string) bool {
			return true
		},
		usage: "h2c get [options] <path>",
	}
	PUT_COMMAND = &command{
		name:        "put",
		description: "Perform a PUT request.",
		minArgs:     1,
		maxArgs:     1,
		areArgsValid: func(args []string) bool {
			return true
		},
		usage: "h2c put [options] <path>",
	}
	POST_COMMAND = &command{
		name:        "post",
		description: "Perform a POST request.",
		minArgs:     1,
		maxArgs:     1,
		areArgsValid: func(args []string) bool {
			return true
		},
		usage: "h2c post [options] <path>",
	}
	SET_COMMAND = &command{
		name:        "set",
		description: "Set a header. The header will be included in any subsequent request.",
		minArgs:     2,
		maxArgs:     2,
		areArgsValid: func(args []string) bool {
			return true
		},
		usage: "h2c set <header-name> <header-value>",
	}
	UNSET_COMMAND = &command{
		name: "unset",
		description: "Undo 'h2c set'. The header will no longer be included in subsequent requests.\n" +
			"If <header-value> is omitted, all headers with <header-name> are removed.\n" +
			"Otherwise, only the specific value is removed but other headers with the same\n" +
			"name remain.",
		minArgs: 1,
		maxArgs: 2,
		areArgsValid: func(args []string) bool {
			return true
		},
		usage: "h2c unset <header-name> [<header-value>]",
	}
	PING_COMMAND = &command{
		name:        "ping",
		description: "Send ping frames.",
		minArgs:     0,
		maxArgs:     0,
		usage:       "h2c ping [options]",
	}
	PID_COMMAND = &command{
		name:        "pid",
		description: "Show the process id of the h2c process.",
		minArgs:     0,
		maxArgs:     0,
		usage:       "h2c pid",
	}
	STREAM_INFO_COMMAND = &command{
		name:        "stream-info",
		description: "List streams and their status.",
		minArgs:     0,
		maxArgs:     0,
		usage:       "h2c stream-info",
	}
	PUSH_LIST_COMMAND = &command{
		name:        "push-list",
		description: "List responses that are available as push promises.",
		minArgs:     0,
		maxArgs:     0,
		usage:       "h2c push-list",
	}
	STOP_COMMAND = &command{
		name:        "stop",
		description: "Stop the h2c process.",
		minArgs:     0,
		maxArgs:     0,
		usage:       "h2c stop",
	}
	WIRETAP_COMMAND = &command{
		name: "wiretap",
		description: "Forward HTTP/2 traffic and print captured frames to the console.\n" +
			"The wiretap command listens on localhost:port and fowards all traffic to remotehost:port.",
		minArgs: 2,
		maxArgs: 2,
		usage:   "h2c wiretap <localhost:port> <remotehost:port>\n",
	}
	VERSION_COMMAND = &command{
		name:        "version",
		description: "Print the version of h2c.",
		minArgs:     0,
		maxArgs:     0,
		usage:       "h2c version",
	}
)

func (c *command) Name() string {
	return c.name
}

var commands = []*command{
	START_COMMAND,
	CONNECT_COMMAND,
	DISCONNECT_COMMAND,
	GET_COMMAND,
	PUT_COMMAND,
	POST_COMMAND,
	SET_COMMAND,
	UNSET_COMMAND,
	PING_COMMAND,
	PID_COMMAND,
	PUSH_LIST_COMMAND,
	STREAM_INFO_COMMAND,
	STOP_COMMAND,
	WIRETAP_COMMAND,
	VERSION_COMMAND,
}

type option struct {
	short        string
	long         string
	description  string
	commands     []*command
	hasParam     bool
	isParamValid func(string) bool
}

func (o *option) Name() string {
	return o.long
}

func (o *option) IsSet(m map[string]string) bool {
	_, ok := m[o.long]
	return ok
}

func (o *option) Get(m map[string]string) string {
	val, _ := m[o.long]
	return val
}

func (o *option) Set(val string, m map[string]string) {
	m[o.long] = val
}

func (o *option) Delete(m map[string]string) {
	delete(m, o.long)
}

var (
	INCLUDE_FRAMES_OPTION = &option{
		short:       "-i",
		long:        "--include",
		description: "Use with --dump to show only the specified frame times. Example: --include HEADERS,CONTINUATION",
		commands:    []*command{START_COMMAND},
		hasParam:    true,
		isParamValid: func(param string) bool {
			return regexp.MustCompile("^[A-Za-z_]+(,\\s*[A-Za-z_]+)?$").MatchString(param)
		},
	}
	EXCLUDE_FRAMES_OPTION = &option{
		short:       "-e",
		long:        "--exclude",
		description: "Use with --dump to exclude the specified frame times. Example: --exclude PING,PRIORITY",
		commands:    []*command{START_COMMAND},
		hasParam:    true,
		isParamValid: func(param string) bool {
			return INCLUDE_FRAMES_OPTION.isParamValid(param)
		},
	}
	INCLUDE_HEADERS_OPTION = &option{
		short:       "-i",
		long:        "--include",
		description: "Show response headers in the output.",
		commands:    []*command{GET_COMMAND, PUT_COMMAND, POST_COMMAND},
		hasParam:    false,
	}
	INCLUDE_CLOSED_STREAMS_OPTION = &option{
		short:       "-c",
		long:        "--closed",
		description: "Include closed streams.",
		commands:    []*command{STREAM_INFO_COMMAND},
		hasParam:    false,
	}
	TIMEOUT_OPTION = &option{
		short:       "-t",
		long:        "--timeout",
		description: "Timeout in seconds while waiting for response.",
		commands:    []*command{GET_COMMAND, PUT_COMMAND, POST_COMMAND},
		hasParam:    true,
		isParamValid: func(param string) bool {
			return regexp.MustCompile("^[0-9]+$").MatchString(param)
		},
	}
	CONTENT_TYPE_OPTION = &option{
		short:       "-c",
		long:        "--content-type",
		description: "Value of the Content-Type header.",
		commands:    []*command{PUT_COMMAND, POST_COMMAND},
		hasParam:    true,
		isParamValid: func(param string) bool {
			return true
		},
	}
	DATA_OPTION = &option{
		short:       "-d",
		long:        "--data",
		description: "The data to be sent. May not be used when --file is present.",
		commands:    []*command{PUT_COMMAND, POST_COMMAND},
		hasParam:    true,
		isParamValid: func(param string) bool {
			return true
		},
	}
	FILE_OPTION = &option{
		short:       "-f",
		long:        "--file",
		description: "Post the content of file. Use '--file -' to read from stdin.",
		commands:    []*command{PUT_COMMAND, POST_COMMAND},
		hasParam:    true,
		isParamValid: func(param string) bool {
			return true
		},
	}
	HELP_OPTION = &option{
		short:       "-h",
		long:        "--help",
		description: "Show this help message.",
		commands:    commands, // help option is available for all commands.
		hasParam:    false,
	}
	DUMP_OPTION = &option{
		short:       "-d",
		long:        "--dump",
		description: "Dump traffic to console.",
		commands:    []*command{START_COMMAND},
		hasParam:    false,
	}
	INTERVAL_OPTION = &option{
		short:       "-i",
		long:        "--interval",
		description: "Ping repeatedly. The time interval can be milliseconds (example: 500ms), seconds (example: 1s), or minutes (example: 2m). If ping is already running, this will update the time interval.",
		commands:    []*command{PING_COMMAND},
		hasParam:    true,
		isParamValid: func(param string) bool {
			return regexp.MustCompile("^[1-9][0-9]*(ms|s|m)$").MatchString(param)
		},
	}
	STOP_OPTION = &option{
		short:       "-s",
		long:        "--stop",
		description: "Stop pinging repeatedly.",
		commands:    []*command{PING_COMMAND},
		hasParam:    false,
	}
)

var options = []*option{
	INCLUDE_FRAMES_OPTION,
	EXCLUDE_FRAMES_OPTION,
	INCLUDE_HEADERS_OPTION,
	INCLUDE_CLOSED_STREAMS_OPTION,
	TIMEOUT_OPTION,
	CONTENT_TYPE_OPTION,
	HELP_OPTION,
	DUMP_OPTION,
	DATA_OPTION,
	FILE_OPTION,
	INTERVAL_OPTION,
	STOP_OPTION,
}


text:
namespace BNolan.RandomSelection.Library
{
    public class Item<T>
    {
        ///
        /// Unique identifier for this item
        ///
        public string UniqueId { get; set; }

        ///
        /// Object to associate with the unique id
        ///
        public T Value { get; set; }

        ///
        /// Number of entries this item should get. The default is one but if the item
        /// should have an entry in the pool more than one time then set the number of total entries
        /// for this item through this property
        ///
        public int Entries { get; set; }

        ///
        /// Default constructor Initializes
        /// Weight to 1
        ///
        public Item()
        {
            Entries = 1;
        }

        ///
        /// Constructor with UniqueId and
        /// Name set from input with
        /// Weightdefaulted to 1
        ///
        /// <param name="uniqueId">Unique Id for the item</param>
        /// <param name="value">Object associated with the unique id</param>
        public Item(string uniqueId,
            T value)
            : this()
        {
            UniqueId = uniqueId;
            Value = value;
        }

        ///
        /// Constructor with UniqueId, Name,
        /// Weight set from input
        ///
        /// <param name="uniqueId">Unique Id for the item</param>
        /// <param name="value">Object associated with the unique id</param>
        /// <param name="entries">Weight associated with the item</param>
        public Item(string uniqueId,
            T value,
            int entries)
            : this(uniqueId, value)
        {
            Entries = entries;
        }

        ///
        /// Gets the string representation of the Value object associated with the Item
        ///
        /// <returns>String representation of the Item.Value</returns>
        public override string ToString()
        {
            return Value.ToString();
        }
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpSapRfc
{
    public class SharpRfcCallException : SharpRfcException
    {
        public string RequestBody { get; private set; }

        public SharpRfcCallException(string message, string requestBody)
            : this(message, requestBody, null)
        {
        }

        public SharpRfcCallException(string message, Exception innerException)
            : this(message, null, innerException)
        {
        }

        public SharpRfcCallException(string message, string requestBody, Exception innerException)
            : base(message, innerException)
        {
            this.RequestBody = requestBody;
        }

        public override string ToString()
        {
            if (string.IsNullOrEmpty(this.RequestBody))
                return base.ToString();

            return string.Format("{0} Request Body was: {1}", base.ToString(), this.RequestBody);
        }
    }
}


text:
package subreddit.android.appstore.screens.details;

import android.app.Activity;
import android.content.SharedPreferences;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import dagger.Module;
import dagger.Provides;
import subreddit.android.appstore.backend.data.AppInfo;
import subreddit.android.appstore.backend.scrapers.MediaScraper;
import subreddit.android.appstore.util.dagger.FragmentScope;
import subreddit.android.appstore.util.mvp.PresenterFactory;

@Module
public class AppDetailsModule {
    private final AppInfo appInfo;

    public AppDetailsModule(Activity activity) {
        Gson gson = new GsonBuilder().create();
        appInfo = AppInfo.fromJson(gson, activity.getIntent().getStringExtra(AppDetailsActivity.ARG_KEY));
    }

    @Provides
    @FragmentScope
    public AppInfo provideAppInfo() {
        return appInfo;
    }

    @Provides
    @FragmentScope
    public PresenterFactory<AppDetailsContract.Presenter> providePresenterFactory(
            final SharedPreferences preferences, final MediaScraper mediaScraper, final AppInfo appInfo
    ) {
        return new PresenterFactory<AppDetailsContract.Presenter>() {
            @Override
            public AppDetailsContract.Presenter create() {
                return new AppDetailsPresenter(preferences, mediaScraper, appInfo);
            }

            @Override
            public Class<? extends AppDetailsContract.Presenter> getTypeClazz() {
                return AppDetailsPresenter.class;
            }
        };
    }
}


text:
import { Component, Input } from '@angular/core';

@Component({
    selector: 'tdlt-modal',
    template: require('./modal.pug'),
    styles: [ require('./modal.scss').toString() ]
})
export class ModalComponent {

    @Input() public title: string;
    @Input() public content: string;

    public active: boolean = false;

    constructor() {
    }

    open() {
        this.active = true;
    }

    close() {
        this.active = false;
    }
}


text:
layout: base
title:  'Dependencies'
generated: 'true'
permalink: hu/dep/index.html
---

# Dependencies

{% include hu-dep-table.html %}

----------

Alphabetical listing

{% assign sorted = site.hu-dep | sort: 'title' %}{% for p in sorted %}
* [{{ p.title }}](): {{ p.shortdef }}{% endfor %}


text:
# Import system modules
import sys, string, os, win32com.client
from urllib import urlretrieve

# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1") # Create the geoprocessor object
gp.CheckOutExtension("spatial")                                 # Check out the required license
gp.overwriteoutput = 1                                          # Overwrite existing files

# WCS URL for downloading SRTM90 tiles
wcsUrl = 'http://ebm.nceas.ucsb.edu/cgi-bin/mapserv?map=/maps/srtm_90m.map' \
         '&Version=1.0.0&request=GetCoverage&Coverage=srtm&service=WCS&CRS=EPSG:4326&Format=' \
         'image/geotiffint16&resx=0.0008333333&resy=0.0008333333&BBOX='

# input coordinates: inputUlx inputUly inputLlx inputLly, ex: -124 40 -122 42
# domain checking. OGC WCS spec uses BBOX of {minx, miny, maxx, maxy}.
domain = {'x' : [float(sys.argv[1]), float(sys.argv[3])],
          'y' : [float(sys.argv[2]), float(sys.argv[4])]}

bBox = [min(domain['x']), min(domain['y']), max(domain['x']), max(domain['y'])]

# convert the floats back into a string, perform list comprehension
urlBbox = ','.join(["%.6f" % k for k in bBox])
urlFull = wcsUrl + urlBbox

#print urlFull
outputDir = sys.argv[5]
if outputDir == '#':
  outputDir = "F:\\dev\\srtm_hydro\\b\\"

outputName = sys.argv[6]
if outputName == '#':
  outputName = 'test'

outputBase = outputDir + outputName
outputFile = outputBase + '.tif'
print "downloading SRTM 90m (%s):"% urlBbox,
urlReturn  = urlretrieve(urlFull, outputFile)
print "\tcomplete."

basinFlowdir   = outputBase + '_fdir'
basinFlowacc   = outputBase + '_facc'
basinFtmp      = outputBase + '_ftmp'
basinFill      = outputBase + '_fill'
basinRaster    = outputBase
basinShapefile = outputBase + '_basin.shp'

try:
  # incoming GeoTiffs have no proper nulls, set these
  print "removing null values:",
  gp.SetNull_sa(outputFile, outputFile, basinFtmp, "VALUE = -32768")
  print "\t\t\t\t\tcomplete."

  # process the DEM with a fill operation, default depth 100m
  print "filling dem sinks:"
  gp.Fill_sa(basinFtmp, basinFill, "25")
  print "\t\t\t\t\t\t\tcomplete."

  # Process: Flow Direction...
  print "computing flowdirection:",
  gp.FlowDirection_sa(basinFill, basinFlowdir, "NORMAL", '#')
  print "\t\t\t\tcomplete."

  # Process: Flow Accumulation...
  print "computing flowaccumulation:",
  gp.FlowAccumulation_sa(basinFlowdir, basinFlowacc, "")
  print "\t\t\t\tcomplete."

  # Process: Batch Build Pyramids...
  print "generating image overviews:",
  gp.BatchBuildPyramids_management(basinFlowdir+';'+basinFlowacc+';'+basinFill)
  print "\t\t\t\tcomplete."

  # Process: Basin...
  print "computing basins:",
  gp.Basin_sa(basinFlowdir, basinRaster)
  print "\t\t\t\t\tcomplete."

  # Process: Raster to Polygon...
  print "vectorizing basins:",
  gp.RasterToPolygon_conversion(basinRaster, basinShapefile, "NO_SIMPLIFY", "VALUE")
  print "\t\t\t\t\tcomplete."
  print "output basins: %s" %basinShapefile

except:
    # report geoprocessing errors
    print gp.GetMessages()


text:
typedef enum
{
    //! @brief Ready event
    TWR_CMWX1ZZABZ_EVENT_READY = 0,

    //! @brief Error event
    TWR_CMWX1ZZABZ_EVENT_ERROR = 1,

    //! @brief RF frame transmission started event
    TWR_CMWX1ZZABZ_EVENT_SEND_MESSAGE_START = 2,

    //! @brief RF frame transmission finished event
    TWR_CMWX1ZZABZ_EVENT_SEND_MESSAGE_DONE = 3,

    //! @brief Configuration save done
    TWR_CMWX1ZZABZ_EVENT_CONFIG_SAVE_DONE = 4,

    //! @brief OTAA join success
    TWR_CMWX1ZZABZ_EVENT_JOIN_SUCCESS = 5,

    //! @brief OTAA join error
    TWR_CMWX1ZZABZ_EVENT_JOIN_ERROR = 6,

    //! @brief Received message
    TWR_CMWX1ZZABZ_EVENT_MESSAGE_RECEIVED = 7,

    //! @brief Retransmission of the confirmed message
    TWR_CMWX1ZZABZ_EVENT_MESSAGE_RETRANSMISSION = 8,

    //! @brief Sent message confirmed
    TWR_CMWX1ZZABZ_EVENT_MESSAGE_CONFIRMED = 9,

    //! @brief Sent message not confirmed
    TWR_CMWX1ZZABZ_EVENT_MESSAGE_NOT_CONFIRMED = 10,

    //! @brief RF quality response
    TWR_CMWX1ZZABZ_EVENT_RFQ = 11,

    //! @brief Frame counter response
    TWR_CMWX1ZZABZ_EVENT_FRAME_COUNTER = 12,

    TWR_CMWX1ZZABZ_EVENT_LINK_CHECK_OK = 13,

    TWR_CMWX1ZZABZ_EVENT_LINK_CHECK_NOK = 14,

    TWR_CMWX1ZZABZ_EVENT_MODEM_FACTORY_RESET = 15,

    TWR_CMWX1ZZABZ_EVENT_CUSTOM_AT = 16

} twr_cmwx1zzabz_event_t;

//! @brief CMWX1ZZABZ instance

typedef struct twr_cmwx1zzabz_t twr_cmwx1zzabz_t;

//! @brief LoRa mode ABP/OTAA

typedef enum
{
    TWR_CMWX1ZZABZ_CONFIG_MODE_ABP = 0,
    TWR_CMWX1ZZABZ_CONFIG_MODE_OTAA = 1

} twr_cmwx1zzabz_config_mode_t;

//! @brief Frequency modes and standards

typedef enum
{
    TWR_CMWX1ZZABZ_CONFIG_BAND_AS923 = 0,
    TWR_CMWX1ZZABZ_CONFIG_BAND_AU915 = 1,
    TWR_CMWX1ZZABZ_CONFIG_BAND_EU868 = 5,
    TWR_CMWX1ZZABZ_CONFIG_BAND_KR920 = 6,
    TWR_CMWX1ZZABZ_CONFIG_BAND_IN865 = 7,
    TWR_CMWX1ZZABZ_CONFIG_BAND_US915 = 8

} twr_cmwx1zzabz_config_band_t;

//! @brief LoRa device class A or C

typedef enum
{
    TWR_CMWX1ZZABZ_CONFIG_CLASS_A = 0,
    TWR_CMWX1ZZABZ_CONFIG_CLASS_C = 2

} twr_cmwx1zzabz_config_class_t;

//! @brief Datarate for AS923

typedef enum
{
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AS923_SF12_125KHZ = 0,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AS923_SF11_125KHZ = 1,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AS923_SF10_125KHZ = 2,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AS923_SF9_125KHZ = 3,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AS923_SF8_125KHZ = 4,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AS923_SF7_125KHZ = 5,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AS923_SF7_250KHZ = 6,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AS923_FSK_50KBPS = 7,

} twr_cmwx1zzabz_config_datarate_as923_t;

//! @brief Datarate for AU915

typedef enum
{
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF12_125KHZ = 0,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF11_125KHZ = 1,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF10_125KHZ = 2,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF9_125KHZ = 3,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF8_125KHZ = 4,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF7_125KHZ = 5,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF8_500KHZ = 6,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF12_500KHZ = 8,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF11_500KHZ = 9,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF10_500KHZ = 10,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF9_500KHZ = 11,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF8_500KHZ_2 = 12,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_AU915_SF7_500KHZ = 13

} twr_cmwx1zzabz_config_datarate_au915_t;

//! @brief Datarate for EU868

typedef enum
{
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_EU868_SF12_125KHZ = 0,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_EU868_SF11_125KHZ = 1,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_EU868_SF10_125KHZ = 2,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_EU868_SF9_125KHZ = 3,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_EU868_SF8_125KHZ = 4,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_EU868_SF7_125KHZ = 5,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_EU868_SF7_250KHZ = 6,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_EU868_FSK_50KBPS = 7

} twr_cmwx1zzabz_config_datarate_eu868_t;

//! @brief Datarate for KR920

typedef enum
{
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_KR920_SF12_125KHZ = 0,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_KR920_SF11_125KHZ = 1,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_KR920_SF10_125KHZ = 2,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_KR920_SF9_125KHZ = 3,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_KR920_SF8_125KHZ = 4,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_KR920_SF7_125KHZ = 5

} twr_cmwx1zzabz_config_datarate_kr920_t;

//! @brief Datarate for US915

typedef enum
{
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF10_125KHZ = 0,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF9_125KHZ = 1,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF8_125KHZ = 2,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF7_125KHZ = 3,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF8_500KHZ = 4,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF12_500KHZ = 8,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF11_500KHZ = 9,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF10_500KHZ = 10,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF9_500KHZ = 11,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF8_500KHZ_2 = 12,
    TWR_CMWX1ZZABZ_CONFIG_DATARATE_US915_SF7_500KHZ = 13

} twr_cmwx1zzabz_config_datarate_us915_t;

//! @cond

typedef enum
{
    TWR_CMWX1ZZABZ_CONFIG_INDEX_DEVADDR = 0,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_DEVEUI = 1,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_APPEUI = 2,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_NWKSKEY = 3,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_APPSKEY = 4,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_APPKEY = 5,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_BAND = 6,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_MODE = 7,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_CLASS = 8,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_RX2 = 9,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_NWK = 10,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_ADAPTIVE_DATARATE = 11,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_DATARATE = 12,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_REP = 13,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_RTYNUM = 14,
    TWR_CMWX1ZZABZ_CONFIG_INDEX_LAST_ITEM

} twr_cmwx1zzabz_config_index_t;

typedef enum
{
    TWR_CMWX1ZZABZ_STATE_READY,
    TWR_CMWX1ZZABZ_STATE_ERROR,
    TWR_CMWX1ZZABZ_STATE_INITIALIZE,
    TWR_CMWX1ZZABZ_STATE_INITIALIZE_AT_RESPONSE,
    TWR_CMWX1ZZABZ_STATE_IDLE,
    TWR_CMWX1ZZABZ_STATE_INITIALIZE_COMMAND_SEND,
    TWR_CMWX1ZZABZ_STATE_INITIALIZE_COMMAND_RESPONSE,

    TWR_CMWX1ZZABZ_STATE_CONFIG_SAVE_SEND,
    TWR_CMWX1ZZABZ_STATE_CONFIG_SAVE_RESPONSE,

    TWR_CMWX1ZZABZ_STATE_SEND_MESSAGE_COMMAND,
    TWR_CMWX1ZZABZ_STATE_SEND_MESSAGE_CONFIRMED_COMMAND,
    TWR_CMWX1ZZABZ_STATE_SEND_MESSAGE_RESPONSE,

    TWR_CMWX1ZZABZ_STATE_JOIN_SEND,
    TWR_CMWX1ZZABZ_STATE_JOIN_RESPONSE,

    TWR_CMWX1ZZABZ_STATE_CUSTOM_COMMAND_SEND,
    TWR_CMWX1ZZABZ_STATE_CUSTOM_COMMAND_RESPONSE,

    TWR_CMWX1ZZABZ_STATE_LINK_CHECK_SEND,
    TWR_CMWX1ZZABZ_STATE_LINK_CHECK_RESPONSE,
    TWR_CMWX1ZZABZ_STATE_LINK_CHECK_RESPONSE_ANS,

    TWR_CMWX1ZZABZ_STATE_RECEIVE,
    TWR_CMWX1ZZABZ_STATE_RECOVER_BAUDRATE_UART,
    TWR_CMWX1ZZABZ_STATE_RECOVER_BAUDRATE_REBOOT

} twr_cmwx1zzabz_state_t;

typedef struct
{
    twr_cmwx1zzabz_config_band_t band;
    twr_cmwx1zzabz_config_mode_t mode;
    twr_cmwx1zzabz_config_class_t class;
    char devaddr[8 + 1];
    char deveui[16 + 1];
    char appeui[16 + 1];
    char nwkskey[32 + 1];
    char appskey[32 + 1];
    char appkey[32 + 1];
    uint32_t rx2_frequency;
    uint8_t rx2_datarate;
    uint8_t nwk_public;
    bool adaptive_datarate;
    uint8_t datarate;
    uint8_t repetition_unconfirmed;
    uint8_t repetition_confirmed;

} twr_cmwx1zzabz_config;

struct twr_cmwx1zzabz_t
{
    twr_scheduler_task_id_t _task_id;
    twr_uart_channel_t _uart_channel;
    twr_cmwx1zzabz_state_t _state;
    twr_cmwx1zzabz_state_t _state_after_sleep;
    twr_fifo_t _tx_fifo;
    twr_fifo_t _rx_fifo;
    uint8_t _tx_fifo_buffer[TWR_CMWX1ZZABZ_TX_FIFO_BUFFER_SIZE];
    uint8_t _rx_fifo_buffer[TWR_CMWX1ZZABZ_RX_FIFO_BUFFER_SIZE];
    void (*_event_handler)(twr_cmwx1zzabz_t *, twr_cmwx1zzabz_event_t, void *);
    void *_event_param;
    char _command[TWR_CMWX1ZZABZ_TX_FIFO_BUFFER_SIZE];
    char _response[TWR_CMWX1ZZABZ_RX_FIFO_BUFFER_SIZE];
    uint8_t _response_length;
    uint8_t _message_buffer[TWR_CMWX1ZZABZ_TX_MAX_PACKET_SIZE];
    size_t _message_length;
    uint8_t _message_port;
    uint8_t _init_command_index;
    uint8_t _save_command_index;
    bool _save_flag;
    uint32_t _save_config_mask;
    twr_cmwx1zzabz_config _config;
    bool _join_command;
    bool _link_check_command;
    bool _custom_command;
    char _custom_command_buf[TWR_CMWX1ZZABZ_CUSTOM_COMMAND_BUFFER_SIZE];
    uint8_t _tx_port;
    bool _debug;

    char _fw_version[TWR_CMWX1ZZABZ_FW_VERSION_BUFFER_SIZE];

    int32_t _cmd_rfq_rssi;
    int32_t _cmd_rfq_snr;

    uint32_t _cmd_frmcnt_uplink;
    uint32_t _cmd_frmcnt_downlink;

    uint8_t _cmd_link_check_margin;
    uint8_t _cmd_link_check_gwcnt;

    twr_tick_t _timeout;
};

//! @endcond

//! @brief Initialize CMWX1ZZABZ
//! @param[in] self Instance
//! @param[in] uart_channel UART channel where TX and RX signals are connected

void twr_cmwx1zzabz_init(twr_cmwx1zzabz_t *self, twr_uart_channel_t uart_channel);

//! @brief Deinitialize CMWX1ZZABZ
//! @param[in] self Instance

void twr_cmwx1zzabz_deinit(twr_cmwx1zzabz_t *self);

//! @brief Reboot and initialize CMWX1ZZABZ
//! @param[in] self Instance

void twr_cmwx1zzabz_reboot(twr_cmwx1zzabz_t *self);

//! @brief Set callback function
//! @param[in] self Instance
//! @param[in] event_handler Function address
//! @param[in] event_param Optional event parameter (can be NULL)

void twr_cmwx1zzabz_set_event_handler(twr_cmwx1zzabz_t *self, void (*event_handler)(twr_cmwx1zzabz_t *, twr_cmwx1zzabz_event_t, void *), void *event_param);

//! @brief Check if modem is ready for commands
//! @param[in] self Instance
//! @return true If ready
//! @return false If not ready

bool twr_cmwx1zzabz_is_ready(twr_cmwx1zzabz_t *self);

//! @brief Send LoRa message
//! @param[in] self Instance
//! @param[in] buffer Pointer to data to be transmitted
//! @param[in] length Length of data to be transmitted in bytes (must be from 1 to 51 bytes)
//! @return true If command was accepted for processing
//! @return false If command was denied for processing

bool twr_cmwx1zzabz_send_message(twr_cmwx1zzabz_t *self, const void *buffer, size_t length);

//! @brief Send LoRa confirmed message
//! @param[in] self Instance
//! @param[in] buffer Pointer to data to be transmitted
//! @param[in] length Length of data to be transmitted in bytes (must be from 1 to 51 bytes)
//! @return true If command was accepted for processing
//! @return false If command was denied for processing

bool twr_cmwx1zzabz_send_message_confirmed(twr_cmwx1zzabz_t *self, const void *buffer, size_t length);

//! @brief Set DEVADDR
//! @param[in] self Instance
//! @param[in] devaddr Pointer to 8 character string

void twr_cmwx1zzabz_set_devaddr(twr_cmwx1zzabz_t *self, char *devaddr);

//! @brief Get DEVADDR
//! @param[in] self Instance
//! @param[in] devaddr Pointer to at least 8+1 character string

void twr_cmwx1zzabz_get_devaddr(twr_cmwx1zzabz_t *self, char *devaddr);

//! @brief Set DEVEUI
//! @param[in] self Instance
//! @param[in] deveui Pointer to 16 character string. WARNING, this value should not be changed as it is unique number programmed in the factory!

void twr_cmwx1zzabz_set_deveui(twr_cmwx1zzabz_t *self, char *deveui);

//! @brief Get DEVEUI
//! @param[in] self Instance
//! @param[in] deveui Pointer to at least 16+1 character string.

void twr_cmwx1zzabz_get_deveui(twr_cmwx1zzabz_t *self, char *deveui);

//! @brief Set APPEUI
//! @param[in] self Instance
//! @param[in] appeui Pointer to 16 character string

void twr_cmwx1zzabz_set_appeui(twr_cmwx1zzabz_t *self, char *appeui);

//! @brief Get APPEUI
//! @param[in] self Instance
//! @param[in] appeui Pointer to at least 16+1 character string

void twr_cmwx1zzabz_get_appeui(twr_cmwx1zzabz_t *self, char *appeui);

//! @brief Set NWKSKEY
//! @param[in] self Instance
//! @param[in] nwkskey Pointer to 32 character string

void twr_cmwx1zzabz_set_nwkskey(twr_cmwx1zzabz_t *self, char *nwkskey);

//! @brief Set NWKSKEY
//! @param[in] self Instance
//! @param[in] nwkskey Pointer to at least 32+1 character string

void twr_cmwx1zzabz_get_nwkskey(twr_cmwx1zzabz_t *self, char *nwkskey);

//! @brief Set APPSKEY
//! @param[in] self Instance
//! @param[in] appskey Pointer to 32 character string

void twr_cmwx1zzabz_set_appskey(twr_cmwx1zzabz_t *self, char *appskey);

//! @brief Get APPSKEY
//! @param[in] self Instance
//! @param[in] appskey Pointer to at least 32+1 character string

void twr_cmwx1zzabz_get_appskey(twr_cmwx1zzabz_t *self, char *appskey);

//! @brief Set APPKEY
//! @param[in] self Instance
//! @param[in] appkey Pointer to 32 character string

void twr_cmwx1zzabz_set_appkey(twr_cmwx1zzabz_t *self, char *appkey);

//! @brief Get APPKEY
//! @param[in] self Instance
//! @param[in] appkey Pointer to at least 32+1 character string

void twr_cmwx1zzabz_get_appkey(twr_cmwx1zzabz_t *self, char *appkey);

//! @brief Set BAND
//! @param[in] self Instance
//! @param[in] band Set correct frequency and modulation for EU, US and other countries

void twr_cmwx1zzabz_set_band(twr_cmwx1zzabz_t *self, twr_cmwx1zzabz_config_band_t band);

//! @brief Get BAND
//! @param[in] self Instance
//! @return Band value

twr_cmwx1zzabz_config_band_t twr_cmwx1zzabz_get_band(twr_cmwx1zzabz_t *self);

//! @brief Set ABP/OTAA mode
//! @param[in] self Instance
//! @param[in] mode ABP or OTAA mode

void twr_cmwx1zzabz_set_mode(twr_cmwx1zzabz_t *self, twr_cmwx1zzabz_config_mode_t mode);

//! @brief Get ABP/OTAA mode
//! @param[in] self Instance
//! @return ABP or OTAA mode

twr_cmwx1zzabz_config_mode_t twr_cmwx1zzabz_get_mode(twr_cmwx1zzabz_t *self);

//! @brief Set device class
//! @param[in] self Instance
//! @param[in] class Supported are Class A and C

void twr_cmwx1zzabz_set_class(twr_cmwx1zzabz_t *self, twr_cmwx1zzabz_config_class_t class);

//! @brief Get device class
//! @param[in] self Instance
//! @return Class A or C

twr_cmwx1zzabz_config_class_t twr_cmwx1zzabz_get_class(twr_cmwx1zzabz_t *self);

//! @brief Start LoRa OTAA join procedure
//! @param[in] self Instance
//! @note The output of the join is handled by callback events
//! @see twr_cmwx1zzabz_event_t

void twr_cmwx1zzabz_join(twr_cmwx1zzabz_t *self);

//! @brief Get port of the received message
//! @param[in] self Instance
//! @return port

uint8_t twr_cmwx1zzabz_get_received_message_port(twr_cmwx1zzabz_t *self);

//! @brief Get length of the received message
//! @param[in] self Instance
//! @return length

uint32_t twr_cmwx1zzabz_get_received_message_length(twr_cmwx1zzabz_t *self);

//! @brief Get received message data
//! @param[in] self Instance
//! @param[in] buffer Destination buffer for received data
//! @param[in] buffer_size Size of the destination buffer
//! @return Length of the received message. Zero if the destination buffer is not big enough.

uint32_t twr_cmwx1zzabz_get_received_message_data(twr_cmwx1zzabz_t *self, uint8_t *buffer, uint32_t buffer_size);

//! @brief Set the port for the transmission of the messages
//! @param[in] self Instance
//! @param[in] port Port

void twr_cmwx1zzabz_set_port(twr_cmwx1zzabz_t *self, uint8_t port);

//! @brief Get the port for the transmission of the messages
//! @param[in] self Instance
//! @return Port

uint8_t twr_cmwx1zzabz_get_port(twr_cmwx1zzabz_t *self);

//! @brief Set the frequency and datarate for RX2 receive window
//! @param[in] self Instance
//! @param[in] frequency Frequency in Hz
//! @param[in] datarate Datarate

void twr_cmwx1zzabz_set_rx2(twr_cmwx1zzabz_t *self, uint32_t frequency, uint8_t datarate);

//! @brief Get the frequency and datarate for RX2 receive window
//! @param[in] self Instance
//! @param[in] frequency Pointer to save frequency in Hz
//! @param[in] datarate Pointer to save datarate

void twr_cmwx1zzabz_get_rx2(twr_cmwx1zzabz_t *self, uint32_t *frequency, uint8_t *datarate);

//! @brief Set the configuration enabling public networks
//! @param[in] self Instance
//! @param[in] public enable public networks

void twr_cmwx1zzabz_set_nwk_public(twr_cmwx1zzabz_t *self, uint8_t public);

//! @brief Get the configuration if public networks are enabled
//! @param[in] self Instance
//! @return public networks enabled

uint8_t twr_cmwx1zzabz_get_nwk_public(twr_cmwx1zzabz_t *self);

//! @brief Set the configuration adaptive data rate
//! @param[in] self Instance
//! @param[in] public enable or disable adaptive data rate

void twr_cmwx1zzabz_set_adaptive_datarate(twr_cmwx1zzabz_t *self, bool enable);

//! @brief Get the configuration if adaptive data rate are enabled
//! @param[in] self Instance
//! @return public adaptive data rate enabled

bool twr_cmwx1zzabz_get_adaptive_datarate(twr_cmwx1zzabz_t *self);

//! @brief Set the configuration of datarate
//! @param[in] self Instance
//! @param[in] datarate Datarate

void twr_cmwx1zzabz_set_datarate(twr_cmwx1zzabz_t *self, uint8_t datarate);

//! @brief Get the configuration of datarate
//! @param[in] self Instance
//! @return datarate Datarate (see the enums)

uint8_t twr_cmwx1zzabz_get_datarate(twr_cmwx1zzabz_t *self);

//! @brief Set debugging flag which prints modem communication to twr_log
//! @param[in] self Instance
//! @param[in] debug Boolean value

void twr_cmwx1zzabz_set_debug(twr_cmwx1zzabz_t *self, bool debug);

//! @brief Get pointer to string containg last sent command
//! @param[in] self Instance
//! @return Buffer char* containing last modem response

char *twr_cmwx1zzabz_get_error_command(twr_cmwx1zzabz_t *self);

//! @brief Get pointer to string containg response on last sent command
//! @param[in] self Instance
//! @return Buffer char* containing last modem response

char *twr_cmwx1zzabz_get_error_response(twr_cmwx1zzabz_t *self);

//! @brief Send custom AT command to LoRa Module
//! @param[in] self Instance
//! @param[in] at_command AT command

bool twr_cmwx1zzabz_custom_at(twr_cmwx1zzabz_t *self, char *at_command);

//! @brief Request RF quality of the last received packet (JOIN, LNPARAM, confirmed message)
//! @param[in] self Instance

bool twr_cmwx1zzabz_rfq(twr_cmwx1zzabz_t *self);

//! @brief Get RF quality values in callback
//! @param[in] self Instance
//! @param[out] rssi RSSI
//! @param[out] snr SNR
//! @return true

bool twr_cmwx1zzabz_get_rfq(twr_cmwx1zzabz_t *self, int32_t *rssi, int32_t *snr);

//! @brief Request frame counter value
//! @param[in] self Instance

bool twr_cmwx1zzabz_frame_counter(twr_cmwx1zzabz_t *self);

//! @brief Get frame counter value
//! @param[in] self Instance
//! @param[out] uplink Uplink frame counter
//! @param[out] downlink Downlink frame counter
//! @return true

bool twr_cmwx1zzabz_get_frame_counter(twr_cmwx1zzabz_t *self, uint32_t *uplink, uint32_t *downlink);

//! @brief Request send of link check packet
//! @param[in] self Instance

bool twr_cmwx1zzabz_link_check(twr_cmwx1zzabz_t *self);

//! @brief Get link check values
//! @param[in] self Instance
//! @param[out] margin Margin id dBm
//! @param[out] gateway_count Number of gateways that received link check packet
//! @return true

bool twr_cmwx1zzabz_get_link_check(twr_cmwx1zzabz_t *self, uint8_t *margin, uint8_t *gateway_count);

//! @brief Send factory reset command to LoRa Module
//! @param[in] self Instance

bool twr_cmwx1zzabz_factory_reset(twr_cmwx1zzabz_t *self);

//! @brief Get firmware version string
//! @param[in] self Instance
//! @return Pointer to the string containing version

char *twr_cmwx1zzabz_get_fw_version(twr_cmwx1zzabz_t *self);

//! @brief Set number of transmissions of unconfirmed message
//! @param[in] self Instance
//! @param[in] repeat Number of transmissions

void twr_cmwx1zzabz_set_repeat_unconfirmed(twr_cmwx1zzabz_t *self, uint8_t repeat);

//! @brief Get number of transmissions of unconfirmed message
//! @param[in] self Instance
//! @return Number of transmissions

uint8_t twr_cmwx1zzabz_get_repeat_unconfirmed(twr_cmwx1zzabz_t *self);

//! @brief Set number of transmissions of confirmed message
//! @param[in] self Instance
//! @param[in] repeat Number of transmissions

void twr_cmwx1zzabz_set_repeat_confirmed(twr_cmwx1zzabz_t *self, uint8_t repeat);

//! @brief Get number of transmissions of confirmed message
//! @param[in] self Instance
//! @return Number of transmissions

uint8_t twr_cmwx1zzabz_get_repeat_confirmed(twr_cmwx1zzabz_t *self);

//! @}

#endif // _TWR_CMWX1ZZABZ_H


text:
package org.apache.logging.log4j.test;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
 *
 */
public class SomethingThatUsesLogging {

    private final Logger logger;

    public SomethingThatUsesLogging() {
        logger = LogManager.getLogger();
    }

    public void doSomething() {
        logger.isEnabled(Level.DEBUG);
    }
}


text:
namespace DynamicDateTime.VariableModels
{
    public static class QuarterVariable
    {
        public static string LastQuarter => "lastquarter";

        public static string NextQuarter => "nextquarter";
    }
}


text:
from flask import (Blueprint,
                   g,
                   render_template,
                   flash,
                   redirect,
                   url_for,
                   abort)
from flask.ext.login import current_user
from ..services import projects, users, pullrequests, issues
from ..forms import NewPullRequestForm
from . import route

bp = Blueprint('pullrequest', __name__, url_prefix='/<u_name>/<p_name>/pulls')

@bp.url_value_preprocessor
def pull_project_code(endpoint, values):
    u_name = values.pop('u_name')
    p_name = values.pop('p_name')
    user = users.first(name=u_name)
    if not user:
        abort(404)
    project = projects.first(name=p_name, owner_id=user.id)
    if not project:
        abort(404)
    g.u_name = u_name
    g.p_name = p_name
    g.project = project

@route(bp, '/')
def index():
    context = {}
    context['u_name'] = g.u_name
    context['p_name'] = g.p_name
    context['project'] = g.project
    context['project_menu'] = 'Pulls'
    project = g.project
    context['pullrequests'] = pullrequests.find(upstream_project_id=project.id)
    return render_template('pullrequests/index.html', **context)

@route(bp, '/new')
def new():
    context = {}
    context['form'] = NewPullRequestForm()
    context['project'] = g.project
    context['project_menu'] = 'Pulls'
    return render_template('pullrequests/new.html', **context)

@route(bp, '/create', methods=['post'])
def create():
    context = {}
    context['u_name'] = g.u_name
    context['p_name'] = g.p_name
    context['project_menu'] = 'Pulls'
    project = g.project
    form = NewPullRequestForm()
    if form.validate_on_submit():
        p = project.create_pullrequest(creator_id=current_user.id,
                                       **form.data)
        flash('New pullrequest was successfully created!', 'info')
        return redirect(url_for('.index', **context))
    context['form'] = form
    context['project'] = project
    return render_template('pullrequests/new.html', **context)

@route(bp, '/<id>')
def pullrequest_index(id):
    context = {}
    context['u_name'] = g.u_name
    context['p_name'] = g.p_name
    context['project'] = g.project
    context['project_menu'] = 'Pulls'
    issue = issues.first(project_id=g.project.id, number=id)
    p = pullrequests.first(upstream_project_id=g.project.id,
                           issue_id=issue.id)
    context['pullrequest'] = p
    context['commits'] = p.repository.commits
    context['diff'] = p.repository.diff
    return render_template('pullrequests/pull.html', **context)


text:
.. spelling::

  autotools

CMake Modules
-------------

 - :ref:`pkg.autoutils` - CMake utilities to imitate autotools functions
 - :ref:`pkg.Sugar` - CMake tools and examples


text:
'use strict';

//window.appName = 'uiglp';

angular.module('bayres.login', [])

    .config(['$routeProvider', function($routeProvider) {
      $routeProvider.when('/login', {
        templateUrl: 'login/login.html',
        controller: 'LoginController',
        data: {requiresLogin: false}
      });
    }])
    .controller('LoginController', LoginController);

LoginController.$inject = ['$location', 'UserService', 'LinksService', 'BayresService', 'CartVars',
  'CartService', 'AcUtils'];

function LoginController($location, UserService, LinksService, BayresService, CartVars,
                         CartService, AcUtils) {
  var vm = this;

  vm.message = '';
  vm.recoveryPassword = false;
  vm.screenWidth = screen.width;

  //METODOS
  vm.login = login;
  vm.passwordEnter = passwordEnter;
  vm.createUsuario = createUsuario;
  vm.recoveryPwd = recoveryPwd;

  vm.loginForm = {
    mail:'',
    password:''
  };

  function login() {
    if(vm.loginForm.mail.trim().length > 0 && vm.loginForm.password.trim().length > 0) {
      UserService.login(vm.loginForm.mail.trim(), vm.loginForm.password.trim(), 1, function(data){
        if(data != -1) {
          vm.message = '';
          BayresService.usuario = {id:data.user.usuario_id, nombre: data.user.nombre, apellido: data.user.apellido, mail:data.user.mail, rol:data.user.rol_id};
          BayresService.isLogged = true;

          CartVars.clearCache = true;
          CartService.reloadLastCart(BayresService.usuario.id, function(carrito) {
            //console.log(carrito);
            if (carrito.length > 0) {
              BayresService.tieneCarrito = true;
              BayresService.miCarrito = carritoEntity(BayresService.usuario.id, carrito[0].carrito_id, carrito[0].fecha);

              if(BayresService.carrito.length > 0) {
                var carritoToDelete = [];
                for(var i=0; i < carrito[0].productos.length; i++){
                  carritoToDelete.push(carrito[0].productos[i].carrito_detalle_id);
                }

                for(var i=0; i < BayresService.carrito.length; i++) {
                  for(var j=0; j < carrito[0].productos.length; j++) {
                    if(BayresService.carrito[i].producto_id == carrito[0].productos[j].producto_id) {
                      BayresService.carrito[i].cantidad = BayresService.carrito[i].cantidad + carrito[0].productos[j].cantidad;
                      carrito[0].productos.splice(j, 1);
                    }
                  }
                }
                for(var i=0; i < carrito[0].productos.length; i++) {
                  BayresService.carrito.push(carrito[0].productos[i]);
                }
                //console.log(carritoToDelete);
                //console.log(BayresService.carrito);
                CartService.removeFromCart(carritoToDelete, function(data){
                  //console.log(data);
                  if(data) {
                    CartService.addToCart(BayresService.miCarrito.carrito_id, BayresService.carrito, function(data){
                      if(data != -1) {
                        for(var i=0; i < BayresService.carrito.length; i++) {
                          for(var j=0; j < CartVars.carrito.length; j++){
                            if(CartVars.carrito[j].producto_id == BayresService.carrito[i].producto_id){
                              if(CartVars.carrito[j].nombre === undefined)
                                CartVars.carrito[j].nombre = BayresService.carrito[i].nombre;
                            }
                          }
                        }
                        BayresService.miCarrito = {carrito_id: carrito[0].carrito_id, status: 0, usuario_id: BayresService.usuario.id, total:CartVars.carrito_total()};
                        CartService.update(BayresService.miCarrito, function(miCarrito){
                          //console.log(miCarrito);
                          if(miCarrito) {
                            console.log('Update Ok');
                            BayresService.carrito = [];
                          } else {
                            console.log('Update Error');
                          }
                        });
                      }
                    });
                  } else {
                    console.log('Error borrando carritos');
                  }
                });
              } else {
                CartVars.carrito = carrito[0].productos;
                //console.log(CartVars.carrito);
                if(CartVars.carrito.length > 0 && BayresService.carrito.length == 0)
                  CartVars.broadcast();
              }
            }
          });
          //console.log(BayresService.carrito);
          if(!BayresService.tieneCarrito && BayresService.carrito.length > 0) {
            var carrito = {'usuario_id': BayresService.usuario.id, 'total': BayresService.carrito_total(), 'status': 0};

            CartService.create(carrito, function(carritoCreado) {
              if (carritoCreado != -1) {
                BayresService.tieneCarrito = true;
                BayresService.miCarrito = carritoCreado;

                CartService.addToCart(carritoCreado.carrito_id, BayresService.carrito, function(data){
                  if(data != -1) {
                    for(var i=0; i < BayresService.carrito.length; i++) {
                      for(var j=0; j < CartVars.carrito.length; j++){
                        if(CartVars.carrito[j].producto_id == BayresService.carrito[i].producto_id){
                          if(CartVars.carrito[j].nombre === undefined)
                            CartVars.carrito[j].nombre = BayresService.carrito[i].nombre;
                        }
                      }
                    }
                    BayresService.carrito = [];
                  }
                });
              }
            });
          }
          vm.recoveryPassword = false;
          $location.path('/main');
          LinksService.selectedIncludeTop = 'main/ofertas.html';
        } else {
          vm.message = 'Usuario o contraseña erroneo';
          vm.recoveryPassword = true;
        }
      });
    } else {
      vm.message = 'Ingrese una mail y contraseña';
    }
  }

  function carritoEntity(usuario_id, carrito_id, fecha) {
    var carrito = {
      'usuario_id': usuario_id,
      'total': CartVars.carrito_total(),
      'status': 0
    };

    if(carrito_id != -1)
      carrito.carrito_id = carrito_id;

    if(fecha !== null && fecha !== undefined)
      carrito.fecha = fecha;

    return carrito;
  }

  function passwordEnter(event) {
    if(event.keyCode == 13) {
      vm.login();
    }
  }

  function createUsuario() {
    $location.path('/usuarios');
    LinksService.selectedIncludeTop = 'usuarios/usuario.html';
  }

  function recoveryPwd() {
    if(vm.loginForm.mail != undefined) {
      if (vm.loginForm.mail.trim().length > 0) {
        if (AcUtils.validateEmail(vm.loginForm.mail.trim())) {
          UserService.userExist(vm.loginForm.mail.trim(), function (data) {
            if (data != -1) {
              UserService.forgotPassword(vm.loginForm.mail.trim(), function (data) {
                vm.recoveryPassword = false;
                $location.path('/main');
                LinksService.selectedIncludeTop = 'main/ofertas.html';
              });
            }
            else {
              vm.message = 'El mail ingresado no existe';
            }
          });
        }
        else {
          vm.message = 'El mail no tiene un formato valido';
        }
      }
      else {
        vm.message = 'Ingrese un mail';
      }
    }
    else {
      vm.message = 'Ingrese un mail';
    }
  }

}


text: This is the template found exclusively in http://getskel.com


text:
import copy

import click

from globus_cli.parsing import command

_command_length = 16

@command(
    "list-commands",
    short_help="List all CLI Commands",
    help=(
        "List all Globus CLI Commands with short help output. "
        "For full command help, run the command with the "
        "`--help` flag"
    ),
)
def list_commands():
    """
    Prints the name and a short description of every command available in the globus
    cli. Commands are grouped by their parent commands,
    e.g. 'globus endpoint activate' is listed as 'activate' under 'globus endpoint'.

    Note that commands with the same listed name under different parent commands
    are distinct. e.g. 'globus task update' is a distinct command from
    'globus endpoint update'.
    """

    def _print_cmd(command):
        # print commands with short_help
        indent = 4
        min_space = 2

        short_help = command.get_short_help_str()

        # if the output would be pinched too close together, or if the command
        # name would overflow, use two separate lines
        if len(command.name) > _command_length - min_space:
            click.echo(" " * indent + command.name)
            click.echo(" " * (indent + _command_length) + short_help)
        # otherwise, it's all cool to cram into one line, just ljust command
        # names so that they form a nice column
        else:
            click.echo(
                " " * indent + f"{command.name.ljust(_command_length)}{short_help}"
            )

    def _print_cmd_group(command, parent_names):
        parents = " ".join(parent_names)
        if parents:
            parents = parents + " "
        click.echo(f"\n=== {parents}{command.name} ===\n")

    def _recursive_list_commands(command, parent_names=None):
        if parent_names is None:
            parent_names = []

        # names of parent commands, including this one, for passthrough to
        # recursive calls
        new_parent_names = copy.copy(parent_names) + [command.name]

        # group-style commands are printed as headers
        if isinstance(command, click.MultiCommand):
            _print_cmd_group(command, parent_names)

            # get the set of subcommands and recursively print all of them
            group_cmds = [
                v
                for v in command.commands.values()
                if isinstance(v, click.MultiCommand)
            ]
            func_cmds = [v for v in command.commands.values() if v not in group_cmds]
            # we want to print them all, but func commands first
            for cmd in func_cmds + group_cmds:
                _recursive_list_commands(cmd, parent_names=new_parent_names)

        # individual commands are printed solo
        else:
            _print_cmd(command)

    # get the root context (the click context for the entire CLI tree)
    root_ctx = click.get_current_context().find_root()

    _recursive_list_commands(root_ctx.command)
    # get an extra newline at the end
    click.echo("")


text:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <title>My First Fountain Pen</title>
    <meta name="description" content="Zian "Zane" Liu - Bioengineer, synthetic biologist, regulatory consultant, STEM outreach organizer, political junkie, menswear enthusiast, fountain pen user, coffee addict, and more..." />

    <meta name="HandheldFriendly" content="True" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <link rel="shortcut icon" href="/assets/images/favicon.ico" >

    <link rel="stylesheet" type="text/css" href="/assets/css/screen.css" />
    <link rel="stylesheet" type="text/css"
          href="//fonts.googleapis.com/css?family=Merriweather:300,700,700italic,300italic|Open+Sans:700,400" />
    <link rel="stylesheet" type="text/css" href="/assets/css/syntax.css" />

    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/default.min.css">

        <link rel="canonical" href="/" />
    <meta name="referrer" content="origin" />
    <link rel="next" href="/page2/" />

    <meta property="og:site_name" content="Zian "Zane" Liu" />
    <meta property="og:type" content="website" />
    <meta property="og:title" content="Zian "Zane" Liu" />
    <meta property="og:description" content="Bioengineer, synthetic biologist, regulatory consultant, STEM outreach organizer, political junkie, menswear enthusiast, fountain pen user, coffee addict, and more..." />
    <meta property="og:url" content="/" />
    <meta property="og:image" content="/assets/images/cover1.jpg" />

    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:title" content="Zian "Zane" Liu" />
    <meta name="twitter:description" content="Bioengineer, synthetic biologist, regulatory consultant, STEM outreach organizer, political junkie, menswear enthusiast, fountain pen user, coffee addict, and more..." />
    <meta name="twitter:url" content="/" />
    <meta name="twitter:image:src" content="/assets/images/cover1.jpg" />

    <meta name="generator" content="Jekyll 3.0.0" />
    <link rel="alternate" type="application/rss+xml" title="Zian "Zane" Liu" href="/feed.xml" />

Menu

        Close

Home

About Zian

Resume

Projects

Leadership

Menswear Advice

Interests

Contact Me

Follow @chairmanzian

            Menu

My First Fountain Pen

            <time class="post-date" datetime="2016-06-25">25 Jun 2016</time>

                on

                       Interests,

                       Fountainpen

Sometime in elementary school (for me, it was second grade), every Chinese kid would need to switch from writing with pencil to writing with a fountain pen - in every class. In addition to teaching us to write neatly, writing with a fountain pen was supposed to instill in us the value of doing things correctly the first time around. After all, ink, unlike graphite, was permanent, and showed our mistakes. So, if crossed-out sections or evidence of mysteriously ripped-out pages were found in our noteboks, we would be called up to the front of the class and berated for all to see.

Like any other eight-year-old having barely two years of handwriting experience, I dreaded writing with a fountain pen. Unlike the tip of a pencil, which writes in all directions, the fountain pen's nib only put down ink properly at one angle. Furthermore, clumsy as I was, every night's pen-refilling ritual left my hands dyed in blue. So, when we were given the opportunity to begin using gel pens (liquid ink, writes in all directions) halfway through third grade, I eagerly made the switch. I never thought I would ever voluntarily pick up a fountain pen again.

So, finding my old fountain pen from elementary schook during my trip to China was an strange yet interesting experience. I'm sure that eight-year-old Zian would never have imagined that thirteen years later, he had somehow become a fountain pen enthusiast, and own way too many bottles of ink and an unreasonable number of pens, but still feeling that he needed more. There was also a sense of nostalgia - coming back after finishing college and at the verge of graduate school, and seeing the equipment that helped me begin my academic journey all those years ago.

Unfortunately, the child-sized pen no longer feels comfortable in my hands, and years of disuse has left it clogged with ink. Like many Hero fountain pens made in that era, it also now has a cracked section, which is now unable to attach to the barrel, and the cap no longer closes tightly.

But let it, in its own, particular way, serve as a memento for reflection and introspection for years to come.

                's Picture

Zian Liu

 Bioengineer, synthetic biologist, and medical device regulatory professional. Constantly caffeinated. Owner of way too many navy suits.

                     Silicon Valley
                     zane@chairmanzian.com

Share this post

                    Twitter

                    Facebook

                    Google+

Dimple Your Tie!

Well, technically, it's a choice, but really, do dimple your tie. In ties, a dimple...

No Longer Eat Alone

I wrote this essay in the beginning of my Freshman year of college. Now that...

Zian "Zane" Liu © 2018

Proudly published with Jekyll using Jasper