text
large_stringlengths
384
2.05k
rank_avg
float64
1
4.19k
rank_max
float64
1
8.21k
rank_min
float64
1
5.03k
rank_median
float64
1
4.21k
rank_by_avgsim
float64
1
4.19k
avgsim_to_github
float32
0.77
0.85
dataset
large_stringclasses
1 value
: 1 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] m_text: Give your terrain texture a name! m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontSharedMaterials: [] m_fontMaterial: {fileID: 0} m_fontMaterials: [] m_fontColor32: serializedVersion: 2 rgba: 4291820027 m_fontColor: {r: 0.9843137, g: 0.9764706, b: 0.8117647, a: 1} m_enableVertexGradient: 0 m_colorMode: 3 m_fontColorGradient: topLeft: {r: 1, g: 1, b: 1, a: 1} topRight: {r: 1, g: 1, b: 1, a: 1} bottomLeft: {r: 1, g: 1, b: 1, a: 1} bottomRight: {r: 1, g: 1, b: 1, a: 1} m_fontColorGradientPreset: {fileID: 0} m_spriteAsset: {fileID: 0} m_tintAllSprites: 0 m_overrideHtmlColors: 0 m_faceColor: serializedVersion: 2 rgba: 4294967295 m_outlineColor: serializedVersion: 2 rgba: 4278190080 m_fontSize: 18 m_fontSizeBase: 18 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 0 m_textAlignment: 257 m_characterSpacing: 0 m_wordSpacing: 0 m_lineSpacing: 0 m_lineSpacingMax: 0 m_paragraphSpacing: 0 m_charWidthMaxAdj: 0 m_enableWordWrapping: 1 m_wordWrappingRatios: 0.4 m_overflowMode: 0 m_firstOverflowCharacterIndex: -1 m_linkedTextComponent: {fileID: 0} m_isLinkedTextComponent: 0 m_isTextTruncated: 0 m_enableKerning: 1 m_enableExtraPadding: 0 checkPaddingRequired: 0 m_isRichText: 1 m_parseCtrlCharacters: 1 m_isOrthographic: 1 m_isCullingEnabled: 0 m_ignoreRectMaskCulling: 0 m_ignoreCulling: 1 m_horizontalMapping: 0 m_verticalMapping: 0 m_uvLineOffset: 0 m_geometrySortingOrder: 0 m_VertexBufferAutoSizeReduction: 1 m_firstVisibleCharacter: 0 m_useMaxVisibleDescender: 1 m_pageToDisplay: 1 m_margin: {x: 0, y: 0, z: 0, w: 0} m_textInfo: textComponent: {fileID: 8839143297831761377} characterCount: 33 spriteCount: 0 s
null
null
null
null
null
null
github_plus_top10pct_by_avg
paceCount: 5 wordCount: 6 linkCount: 0 lineCount: 1 pageCount: 1 materialCount: 1 m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 m_spriteAnimator: {fileID: 0} m_hasFontAssetChanged: 0 m_subTextObjects: - {fileID: 0} - {fileID: 0} - {fileID: 0} - {fileID: 0} - {fileID: 0} - {fileID: 0} - {fileID: 0} - {fileID: 0} m_baseMaterial: {fileID: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0} --- !u!1001 &2394534739825395366 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 1749581104624286704} m_Modifications: - target: {fileID: 5378799052751929778, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Name value: TextButton objectReference: {fileID: 0} - target: {fileID: 1479800314232047194, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.r value: 0.3137255 objectReference: {fileID: 0} - target: {fileID: 1479800314232047194, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.g value: 0.31764707 objectReference: {fileID: 0} - target: {fileID: 1479800314232047194, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.b value: 0.30980393 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalPosition.z value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, typ
null
null
null
null
null
null
github_plus_top10pct_by_avg
e: 3} propertyPath: m_LocalRotation.x value: -0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalRotation.y value: -0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalRotation.z value: -0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_RootOrder value: 1 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchoredPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910,
null
null
null
null
null
null
github_plus_top10pct_by_avg
guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchorMin.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchorMin.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchorMax.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Pivot.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Pivot.y value: 1 objectReference: {fileID: 0} - target: {fileID: 1208266180855391641, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_PreferredHeight value: 40 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_havePropertiesChanged value: 0 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_isInputParsingRequired value: 0 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_text value: OK objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, g
null
null
null
null
null
null
github_plus_top10pct_by_avg
uid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.characterCount value: 2 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.spaceCount value: 0 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.wordCount value: 1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.lineCount value: 1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.pageCount value: 1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_firstOverflowCharacterIndex value: -1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_enableAutoSizing value: 1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_fontSize value: 17.1 objectReference: {fileID: 0} - target: {fileID: 3759142112673032445, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_padding value: 0 objectReference: {fileID: 0} - target: {fileID: 2925752997128898584, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Material value: objectReference: {fileID: 0} - target: {fileID: 2925752997128898584, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.r value: 0.3137255 objectReference: {fileID: 0}
null
null
null
null
null
null
github_plus_top10pct_by_avg
- target: {fileID: 2925752997128898584, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.g value: 0.31764707 objectReference: {fileID: 0} - target: {fileID: 2925752997128898584, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.b value: 0.30980393 objectReference: {fileID: 0} - target: {fileID: 7592762545067635800, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: radius value: 6 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} --- !u!224 &1093255859136528568 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} m_PrefabInstance: {fileID: 2394534739825395366} m_PrefabAsset: {fileID: 0} --- !u!114 &2310727790410682723 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 83952138638415813, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} m_PrefabInstance: {fileID: 2394534739825395366} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Name: m_EditorClassIdentifier: --- !u!1001 &2545334527945517866 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 1749581104624286704} m_Modifications: - target: {fileID: 5378799052751929778, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Name value: TextButton (1) objectReference: {fileID: 0} - target: {fileID: 1479800314232047194, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.r value: 0.3137255 objectReference: {fileID: 0} - target: {fileID: 1479800314232047194, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_C
null
null
null
null
null
null
github_plus_top10pct_by_avg
olor.g value: 0.31764707 objectReference: {fileID: 0} - target: {fileID: 1479800314232047194, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.b value: 0.30980393 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalPosition.z value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalRotation.x value: -0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalRotation.y value: -0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalRotation.z value: -0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_RootOrder value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3,
null
null
null
null
null
null
github_plus_top10pct_by_avg
type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchoredPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchorMin.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchorMin.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchorMax.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Pivot.x value: 0 objectReference: {fileID: 0} - target: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa
null
null
null
null
null
null
github_plus_top10pct_by_avg
5e313276529cd3, type: 3} propertyPath: m_Pivot.y value: 1 objectReference: {fileID: 0} - target: {fileID: 1208266180855391641, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_PreferredHeight value: 40 objectReference: {fileID: 0} - target: {fileID: 1208266180855391641, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_FlexibleWidth value: 1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_havePropertiesChanged value: 0 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_isInputParsingRequired value: 0 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_text value: Cancel objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.characterCount value: 6 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.spaceCount value: 0 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.wordCount value: 1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.lineCount value: 1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_textInfo.pageCount value: 1 objectReference: {fileID: 0} - target: {fil
null
null
null
null
null
null
github_plus_top10pct_by_avg
eID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_enableAutoSizing value: 1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_firstOverflowCharacterIndex value: -1 objectReference: {fileID: 0} - target: {fileID: 8042467681023276156, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_fontSize value: 17.1 objectReference: {fileID: 0} - target: {fileID: 3759142112673032445, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_padding value: 0 objectReference: {fileID: 0} - target: {fileID: 2925752997128898584, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Material value: objectReference: {fileID: 0} - target: {fileID: 2925752997128898584, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.r value: 0.3137255 objectReference: {fileID: 0} - target: {fileID: 2925752997128898584, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.g value: 0.31764707 objectReference: {fileID: 0} - target: {fileID: 2925752997128898584, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: m_Color.b value: 0.30980393 objectReference: {fileID: 0} - target: {fileID: 7592762545067635800, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} propertyPath: radius value: 6 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} --- !u!224 &956388772858572084 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 3321157068342330910, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} m_PrefabInstance: {fileID: 2545334527945517866} m_PrefabAsset: {fileID: 0} --- !u!114 &24839
null
null
null
null
null
null
github_plus_top10pct_by_avg
04802973023471 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 83952138638415813, guid: 598805c720ef32d4fa5e313276529cd3, type: 3} m_PrefabInstance: {fileID: 2545334527945517866} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Name: m_EditorClassIdentifier: --- !u!1001 &4153264261717023845 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 4153264261330621393} m_Modifications: - target: {fileID: 8732058293161486459, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_Name value: CloseButton objectReference: {fileID: 0} - target: {fileID: 7753949821495507838, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_Color.r value: 0.4 objectReference: {fileID: 0} - target: {fileID: 7753949821495507838, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_Color.g value: 0.6 objectReference: {fileID: 0} - target: {fileID: 7753949821495507838, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_Color.b value: 0.8 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalPosition.z value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalRotation.x
null
null
null
null
null
null
github_plus_top10pct_by_avg
value: -0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalRotation.y value: -0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalRotation.z value: -0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_RootOrder value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_AnchoredPosition.x value: 460 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_SizeDelta.x value: 30 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b,
null
null
null
null
null
null
github_plus_top10pct_by_avg
type: 3} propertyPath: m_SizeDelta.y value: 30 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_AnchorMin.x value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_AnchorMin.y value: 1 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_AnchorMax.x value: 0 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_AnchorMax.y value: 1 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_Pivot.x value: 1 objectReference: {fileID: 0} - target: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_Pivot.y value: 1 objectReference: {fileID: 0} - target: {fileID: 7357386075552011529, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_IgnoreLayout value: 0 objectReference: {fileID: 0} - target: {fileID: 7357386075552011529, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_PreferredHeight value: 30 objectReference: {fileID: 0} - target: {fileID: 7357386075552011529, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_PreferredWidth value: 30 objectReference: {fileID: 0} - target: {fileID: 7357386075552011529, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} propertyPath: m_FlexibleWidth value: -1 objectReference: {fileID: 0} - target: {fileID: 7357386075552011529, guid: b367a7dbfda1ae249843776e21232d4b, t
null
null
null
null
null
null
github_plus_top10pct_by_avg
ype: 3} propertyPath: m_FlexibleHeight value: -1 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} --- !u!224 &7335350715391774470 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 6660609766976541539, guid: b367a7dbfda1ae249843776e21232d4b, type: 3} m_PrefabInstance: {fileID: 4153264261717023845} m_PrefabAsset: {fileID: 0} --- !u!1001 &6885557603678681849 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 4153264261279501447} m_Modifications: - target: {fileID: 6258128341235689163, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_fontAsset value: objectReference: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - target: {fileID: 6258128341235689163, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_sharedMaterial value: objectReference: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - target: {fileID: 6258128341235689163, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_textInfo.materialCount value: 1 objectReference: {fileID: 0} - target: {fileID: 2800697708764036826, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_fontAsset value: objectReference: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - target: {fileID: 2800697708764036826, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_sharedMaterial value: objectReference: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - target: {fileID: 5321015225614398905, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_Material value: objectReference: {fileID: 0} - target: {fileID: 5321015225614398905, guid
null
null
null
null
null
null
github_plus_top10pct_by_avg
: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_sharedMaterial value: objectReference: {fileID: 0} - target: {fileID: 5321015225614398905, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_padding value: 0 objectReference: {fileID: 0} - target: {fileID: 4250229368836075453, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchorMin.y value: 0 objectReference: {fileID: 0} - target: {fileID: 4250229368836075453, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} - target: {fileID: 4250229368836075453, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchoredPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 4250229368836075453, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 4250229368836075453, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} - target: {fileID: 4250229368836075453, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892582066047809, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchorMin.x value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892582066047809, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchorMin.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892582066047809, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchorMax.x value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892582066047809, guid:
null
null
null
null
null
null
github_plus_top10pct_by_avg
000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892582066047809, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchoredPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892582066047809, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892582066047809, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892582066047809, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892582066047809, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_RootOrder value: 3 objectReference: {fileID: 0} - target: {fileID: 1771892581888439675, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchorMin.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892581888439675, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892581888439675, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchoredPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892581888439675, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892581888439675, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_SizeDelta.x value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892581888
null
null
null
null
null
null
github_plus_top10pct_by_avg
439675, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1771892581888439674, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_text value: Name objectReference: {fileID: 0} - target: {fileID: 1771892581888439674, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_textInfo.characterCount value: 4 objectReference: {fileID: 0} - target: {fileID: 1771892581888439674, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_fontAsset value: objectReference: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - target: {fileID: 1771892581888439674, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_sharedMaterial value: objectReference: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} - target: {fileID: 5168647803870263437, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} propertyPath: m_Material value: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} --- !u!224 &5123245634172989880 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 1771892582066047809, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} m_PrefabInstance: {fileID: 6885557603678681849} m_PrefabAsset: {fileID: 0} --- !u!114 &4403153595967029429 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 7103670801904745036, guid: 000f1a7818c5dd848a195cf888e421d2, type: 3} m_PrefabInstance: {fileID: 6885557603678681849} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3} m_Name: m_EditorClassIdentifier: <?php declare(strict_types=1); /* These are tests f
null
null
null
null
null
null
github_plus_top10pct_by_avg
rom Locutus for porting TODO: implement adding automatically (if it's possible) Array ( [code] => var $string = "\t\t\t\nThis is\tan example\nstring\n" var $tok = strtok($string, " \n\t") var $b = '' while ($tok !== false) {$b += "Word="+$tok+"\n"; $tok = strtok(" \n\t");} var $result = $b [returns] => "Word=This\nWord=is\nWord=an\nWord=example\nWord=string\n" ) */ class Strtok extends PHPUnit\Framework\TestCase { public function test() { $input = ['test1', 'tEsT2', 'TEST3']; $actual = \Zubr\strtok(/* put stuff here */); $expected = \strtok(/* put stuff here */); $this->assertEquals($expected, $actual); } } # Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer that turns <> into !=.""" # Local imports from .. import pytree from ..pgen2 import token from .. import fixer_base class FixNe(fixer_base.BaseFix): # This is so simple that we don't need the pattern compiler. _accept_type = token.NOTEQUAL def match(self, node): # Override return node.value == u"<>" def transform(self, node, results): new = pytree.Leaf(token.NOTEQUAL, u"!=", prefix=node.prefix) return new package org.junit.tests; import static org.junit.Assert.*; import java.lang.annotation.Annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.Description; import org.junit.runner.Request; public class AnnotatedDescriptionTest { @Retention(RetentionPolicy.RUNTIME) public @interface MyOwnAnnotation { } @MyOwnAnnotation public static class AnnotatedClass { @Test public void a() { } } @Test public void annotationsExistOnDescriptionsOfClasses() { assertTrue((describe(AnnotatedClass.class).getAnnotation( MyOwnAnnotation.class) != null)); } @Test public void getAnnotationsReturnsAllAnnotations() { assertEquals(1, describe(ValueAnnotatedClass.class).getAnno
null
null
null
null
null
null
github_plus_top10pct_by_avg
tations() .size()); } @Ignore public static class IgnoredClass { @Test public void a() { } } @Test public void annotationsExistOnDescriptionsOfIgnoredClass() { assertTrue((describe(IgnoredClass.class).getAnnotation(Ignore.class) != null)); } @Retention(RetentionPolicy.RUNTIME) public @interface ValuedAnnotation { String value(); } @ValuedAnnotation("hello") public static class ValueAnnotatedClass { @Test public void a() { } } @Test public void descriptionOfTestClassHasValuedAnnotation() { Description description= describe(ValueAnnotatedClass.class); assertEquals("hello", description.getAnnotation(ValuedAnnotation.class) .value()); } @Test public void characterizeCreatingMyOwnAnnotation() { Annotation annotation= new Ignore() { public String value() { return "message"; } public Class<? extends Annotation> annotationType() { return Ignore.class; } }; assertEquals(Ignore.class, annotation.annotationType()); } private Description describe(Class<?> testClass) { return Request.aClass(testClass).getRunner().getDescription(); } } /* * JBoss, Home of Professional Open Source * Copyright 2015, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.weld.tests.decorators.overloading; import java.util.Collection; import java.util.Set; import jakarta.decorator.Decorator; imp
null
null
null
null
null
null
github_plus_top10pct_by_avg
ort jakarta.decorator.Delegate; import jakarta.inject.Inject; import org.jboss.weld.test.util.ActionSequence; /** * * @author Martin Kouba */ @Decorator public class BravoServiceDecorator implements BravoService { @Inject @Delegate private BravoService delegate; @Override public void run(Set<Integer> values) { ActionSequence.addAction(Set.class.getName()); delegate.run(values); } @Override public void run(Collection<Integer> values) { ActionSequence.addAction(Collection.class.getName()); delegate.run(values); } } // // Addin.cs // // Author: // Lluis Sanchez Gual // // Copyright (C) 2005 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Collections; using System.IO; using System.Xml; using System.Xml.Serialization; using System.Collections.Specialized; using Mono.Addins.Description; using Mono.Addins.Database; using System.Linq; namespace Mono.Addins { //
null
null
null
null
null
null
github_plus_top10pct_by_avg
/ <summary> /// An add-in. /// </summary> public class Addin { AddinInfo addin; string sourceFile; WeakReference desc; AddinDatabase database; bool? isLatestVersion; bool? isUserAddin; string id; string domain; internal Addin (AddinDatabase database, string domain, string id) { this.database = database; this.id = id; this.domain = domain; LoadAddinInfo (); } /// <summary> /// Full identifier of the add-in, including namespace and version. /// </summary> public string Id { get { return id; } } /// <summary> /// Namespace of the add-in. /// </summary> public string Namespace { get { return this.AddinInfo.Namespace; } } /// <summary> /// Identifier of the add-in (without namespace) /// </summary> public string LocalId { get { return this.AddinInfo.LocalId; } } /// <summary> /// Version of the add-in /// </summary> public string Version { get { return this.AddinInfo.Version; } } /// <summary> /// Display name of the add-in /// </summary> public string Name { get { return this.AddinInfo.Name; } } /// <summary> /// Custom properties specified in the add-in header /// </summary> public AddinPropertyCollection Properties { get { return this.AddinInfo.Properties; } } internal string PrivateDataPath { get { return Path.Combine (database.AddinPrivateDataPath, Path.GetFileNameWithoutExtension (Description.FileName)); } } /// <summary> /// Checks version compatibility. /// </summary> /// <param name="version"> /// An add-in version. /// </param> /// <returns> /// True if the provided version is compatible with this add-in. /// </returns> /// <remarks> /// This method checks the CompatVersion property to know if the provided version is compatible with the version of this add-in. /// </remarks> public bool SupportsVersion (string version) { return AddinInfo.SupportsVersion (version); } /// <summary> /// Returns a <see cref="System.String"/> that
null
null
null
null
null
null
github_plus_top10pct_by_avg
represents the current <see cref="Mono.Addins.Addin"/>. /// </summary> /// <returns> /// A <see cref="System.String"/> that represents the current <see cref="Mono.Addins.Addin"/>. /// </returns> public override string ToString () { return Id; } internal AddinInfo AddinInfo { get { if (addin == null) { try { addin = AddinInfo.ReadFromDescription (Description); } catch (Exception ex) { throw new InvalidOperationException ("Could not read add-in file: " + database.GetDescriptionPath (domain, id), ex); } } return addin; } } /// <summary> /// Gets or sets the enabled status of the add-in. /// </summary> /// <remarks> /// This property can be used to enable or disable an add-in. /// The enabled status of an add-in is stored in the add-in registry, /// so when an add-in is disabled, it will be disabled for all applications /// sharing the same registry. /// When an add-in is enabled or disabled, the extension points currently loaded /// in memory will be properly updated to include or exclude extensions from the add-in. /// </remarks> public bool Enabled { get { if (!IsLatestVersion) return false; return AddinInfo.IsRoot ? true : database.IsAddinEnabled (Description.Domain, AddinInfo.Id, true); } set { if (value) database.EnableAddin (Description.Domain, AddinInfo.Id, true); else database.DisableAddin (Description.Domain, AddinInfo.Id); } } internal bool IsLatestVersion { get { if (isLatestVersion == null) { string id, version; Addin.GetIdParts (AddinInfo.Id, out id, out version); var addins = database.GetInstalledAddins (null, AddinSearchFlagsInternal.IncludeAll | AddinSearchFlagsInternal.LatestVersionsOnly); isLatestVersion = addins.Any (a => Addin.GetIdName (a.Id) == id && a.Version == version); } return isLatestVersion.Value; } set { isLatestVersion = value; } } /// <summary> /// Returns 'true' if the add-in is inst
null
null
null
null
null
null
github_plus_top10pct_by_avg
alled in the user's personal folder /// </summary> public bool IsUserAddin { get { if (isUserAddin == null) SetIsUserAddin (Description); return isUserAddin.Value; } } void SetIsUserAddin (AddinDescription adesc) { string installPath = database.Registry.DefaultAddinsFolder; if (installPath [installPath.Length - 1] != Path.DirectorySeparatorChar) installPath += Path.DirectorySeparatorChar; isUserAddin = adesc != null && Path.GetFullPath (adesc.AddinFile).StartsWith (installPath); } /// <summary> /// Path to the add-in file (it can be an assembly or a standalone XML manifest) /// </summary> public string AddinFile { get { if (sourceFile == null && addin == null) LoadAddinInfo (); return sourceFile; } } void LoadAddinInfo () { if (addin == null) { try { AddinDescription m = Description; sourceFile = m.AddinFile; addin = AddinInfo.ReadFromDescription (m); } catch (Exception ex) { throw new InvalidOperationException ("Could not read add-in file: " + database.GetDescriptionPath (domain, id), ex); } } } /// <summary> /// Description of the add-in /// </summary> public AddinDescription Description { get { if (desc != null) { AddinDescription d = desc.Target as AddinDescription; if (d != null) return d; } var configFile = database.GetDescriptionPath (domain, id); AddinDescription m; database.ReadAddinDescription (new ConsoleProgressStatus (true), configFile, out m); if (m == null) { try { if (File.Exists (configFile)) { // The file is corrupted. Remove it. File.Delete (configFile); } } catch { // Ignore } throw new InvalidOperationException ("Could not read add-in description"); } if (addin == null) { addin = AddinInfo.ReadFromDescription (m); sourceFile = m.AddinFile; } SetIsUserAddin (m); if (!isUserAddin.Value) m.Flags |= AddinFlags.CantUninstall;
null
null
null
null
null
null
github_plus_top10pct_by_avg
desc = new WeakReference (m); return m; } } internal void ResetCachedData () { // The domain may have changed (?!) // This check has been commented out because GetFolderDomain will fail if sourceFile changed // or if there is no folder info for the add-in (it may happen when using pre-generated add-in // scan data files). // A domain change at run-time is an unlikely scenario and not properly supported anyway in // other parts of the code. In general, changes in an already loaded add-in are not supported. // if (sourceFile != null) // domain = database.GetFolderDomain (null, Path.GetDirectoryName (sourceFile)); desc = null; addin = null; } /// <summary> /// Compares two add-in versions /// </summary> /// <returns> /// -1 if v1 is greater than v2, 0 if v1 == v2, 1 if v1 less than v2 /// </returns> /// <param name='v1'> /// A version /// </param> /// <param name='v2'> /// A version /// </param> public static int CompareVersions (string v1, string v2) { string[] a1 = v1.Split ('.'); string[] a2 = v2.Split ('.'); for (int n=0; n<a1.Length; n++) { if (n >= a2.Length) return -1; if (a1[n].Length == 0) { if (a2[n].Length != 0) return 1; continue; } try { int n1 = int.Parse (a1[n]); int n2 = int.Parse (a2[n]); if (n1 < n2) return 1; else if (n1 > n2) return -1; } catch { return 1; } } if (a2.Length > a1.Length) return 1; return 0; } /// <summary> /// Returns the identifier of an add-in /// </summary> /// <returns> /// The full identifier. /// </returns> /// <param name='ns'> /// Namespace of the add-in /// </param> /// <param name='id'> /// Name of the add-in /// </param> /// <param name='version'> /// Version of the add-in /// </param> public static string GetFullId (string ns, string id, string version) { string res; if (id.StartsWith ("::", StringComparison.Ordinal)) res = id.Substring
null
null
null
null
null
null
github_plus_top10pct_by_avg
(2); else if (ns != null && ns.Length > 0) res = ns + "." + id; else res = id; if (version != null && version.Length > 0) return res + "," + version; else return res; } /// <summary> /// Given a full add-in identifier, returns the namespace and name of the add-in (it removes the version number) /// </summary> /// <param name='addinId'> /// Add-in identifier. /// </param> public static string GetIdName (string addinId) { int i = addinId.IndexOf (','); if (i != -1) return addinId.Substring (0, i); else return addinId; } /// <summary> /// Given a full add-in identifier, returns the version the add-in /// </summary> /// <returns> /// The version. /// </returns> public static string GetIdVersion (string addinId) { int i = addinId.IndexOf (','); if (i != -1) return addinId.Substring (i + 1).Trim (); else return string.Empty; } /// <summary> /// Splits a full add-in identifier in name and version /// </summary> /// <param name='addinId'> /// Add-in identifier. /// </param> /// <param name='name'> /// The resulting name /// </param> /// <param name='version'> /// The resulting version /// </param> public static void GetIdParts (string addinId, out string name, out string version) { int i = addinId.IndexOf (','); if (i != -1) { name = addinId.Substring (0, i); version = addinId.Substring (i+1).Trim (); } else { name = addinId; version = string.Empty; } } } } #import "EXPMatchers+beNil.h" #import "EXPMatchers+equal.h" #import "EXPMatchers+beInstanceOf.h" #import "EXPMatchers+beKindOf.h" #import "EXPMatchers+beSubclassOf.h" #import "EXPMatchers+conformTo.h" #import "EXPMatchers+beTruthy.h" #import "EXPMatchers+beFalsy.h" #import "EXPMatchers+contain.h" #import "EXPMatchers+beSupersetOf.h" #import "EXPMatchers+haveCountOf.h" #import "EXPMatchers+beIdenticalTo.h" #import "EXPMatchers+beGreaterThan.h" #import "EXPMatchers+beGreaterThanOrEqualTo.h" #import "E
null
null
null
null
null
null
github_plus_top10pct_by_avg
XPMatchers+beLessThan.h" #import "EXPMatchers+beLessThanOrEqualTo.h" #import "EXPMatchers+beInTheRangeOf.h" #import "EXPMatchers+beCloseTo.h" #import "EXPMatchers+raise.h" #import "EXPMatchers+raiseWithReason.h" #import "EXPMatchers+respondTo.h" #import "EXPMatchers+notify.h" #import "EXPMatchers+beginWith.h" #import "EXPMatchers+endWith.h" /* * ws protocol handler plugin for "generic sessions" * * Copyright (C) 2010-2016 Andy Green <andy@warmcat.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation: * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #define LWS_DLL #define LWS_INTERNAL #include "../lib/libwebsockets.h" #include <sqlite3.h> #include <string.h> #define LWSGS_VERIFIED_ACCEPTED 100 enum { FGS_USERNAME, FGS_PASSWORD, FGS_PASSWORD2, FGS_EMAIL, FGS_REGISTER, FGS_GOOD, FGS_BAD, FGS_REG_GOOD, FGS_REG_BAD, FGS_ADMIN, FGS_FORGOT, FGS_FORGOT_GOOD, FGS_FORGOT_BAD, FGS_FORGOT_POST_GOOD, FGS_FORGOT_POST_BAD, FGS_CHANGE, FGS_CURPW, FGS_DELETE, }; struct lwsgs_user { char username[32]; char ip[16]; lwsgw_hash pwhash; lwsgw_hash pwsalt; lwsgw_hash token; time_t created; time_t last_forgot_validated; char email[100]; int verified; }; struct per_vhost_data__gs { struct lws_email email; struct lwsgs_user u; struct lws_context *context; char session_db[256]; char admin_user[32]; char confounder[32]; char email_contact_person[128]; char email_title[128]; char email_template[128]; char email_c
null
null
null
null
null
null
github_plus_top10pct_by_avg
onfirm_url[128]; lwsgw_hash admin_password_sha1; sqlite3 *pdb; int timeout_idle_secs; int timeout_absolute_secs; int timeout_anon_absolute_secs; int timeout_email_secs; time_t last_session_expire; char email_inited; }; struct per_session_data__gs { struct lws_spa *spa; lwsgw_hash login_session; lwsgw_hash delete_session; unsigned int login_expires; char onward[256]; char result[500 + LWS_PRE]; char urldec[500 + LWS_PRE]; int result_len; char ip[46]; struct lws_process_html_state phs; int spos; unsigned int logging_out:1; }; /* utils.c */ int lwsgs_lookup_callback_user(void *priv, int cols, char **col_val, char **col_name); void lwsgw_cookie_from_session(lwsgw_hash *sid, time_t expires, char **p, char *end); int lwsgs_get_sid_from_wsi(struct lws *wsi, lwsgw_hash *sid); int lwsgs_lookup_session(struct per_vhost_data__gs *vhd, const lwsgw_hash *sid, char *username, int len); int lwsgs_get_auth_level(struct per_vhost_data__gs *vhd, const char *username); int lwsgs_check_credentials(struct per_vhost_data__gs *vhd, const char *username, const char *password); void sha1_to_lwsgw_hash(unsigned char *hash, lwsgw_hash *shash); unsigned int lwsgs_now_secs(void); int lwsgw_check_admin(struct per_vhost_data__gs *vhd, const char *username, const char *password); int lwsgs_hash_password(struct per_vhost_data__gs *vhd, const char *password, struct lwsgs_user *u); int lwsgs_new_session_id(struct per_vhost_data__gs *vhd, lwsgw_hash *sid, const char *username, int exp); int lwsgs_lookup_user(struct per_vhost_data__gs *vhd, const char *username, struct lwsgs_user *u); int lwsgw_update_session(struct per_vhost_data__gs *vhd, lwsgw_hash *hash, const char *user); int lwsgw_expire_old_sessions(struct per_vhost_data__gs *vhd); /* handlers.c */ int lwsgs_handler_confirm(struct per_vhost_data__gs *vhd, struct lws *wsi, struct per_session_data__gs *pss); int lwsgs_handler_forgot(struct per_vhost_data__gs *vhd, struct lws *wsi, struct per_session_dat
null
null
null
null
null
null
github_plus_top10pct_by_avg
a__gs *pss); int lwsgs_handler_check(struct per_vhost_data__gs *vhd, struct lws *wsi, struct per_session_data__gs *pss); int lwsgs_handler_change_password(struct per_vhost_data__gs *vhd, struct lws *wsi, struct per_session_data__gs *pss); int lwsgs_handler_forgot_pw_form(struct per_vhost_data__gs *vhd, struct lws *wsi, struct per_session_data__gs *pss); int lwsgs_handler_register_form(struct per_vhost_data__gs *vhd, struct lws *wsi, struct per_session_data__gs *pss); [ { "keys": ["ctrl+.", "ctrl+x"], "command": "margo_open_extension", }, { "keys": ["ctrl+.", "ctrl+1"], "command": "open_file", "args": { "file": "${packages}/GoSublime/README.md" } }, { "keys": ["ctrl+.", "ctrl+2"], "command": "open_file", "args": { "file": "${packages}/GoSublime/USAGE.md" } }, { "keys": ["ctrl+.", "ctrl+3"], "command": "gs_sanity_check" }, { "keys": ["ctrl+.", "ctrl+4"], "command": "open_file", "args": { "file": "${packages}/GoSublime/GoSublime.sublime-settings" } }, { "keys": ["ctrl+.", "ctrl+5"], "command": "open_file", "args": { "file": "${packages}/User/GoSublime.sublime-settings" } }, { "keys": ["ctrl+space"], "command": "auto_complete", "args": {"disable_auto_insert": true, "api_completions_only": true, "next_completion_if_showing": false}, "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "keys": ["ctrl+.", "ctrl+p"], "command": "gs_palette", "args": {"palette": "imports", "direct": true}, "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "keys": ["ctrl+.", "ctrl+d"], "command": "gs_palette", "args": {"palette": "declarations", "direct": true}, "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "keys": ["ctrl+.", "ctrl+e"], "command": "margo_issues", }, { "keys": ["ctrl+.", "ctrl+c"], "command": "margo_user_cmds", }, { "keys": ["ctrl+.", "ctrl+["], "command": "gs_palette", "args": {"palette": "ju
null
null
null
null
null
null
github_plus_top10pct_by_avg
mp_back"}, "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "keys": ["ctrl+.", "ctrl+i"], "command": "gs_palette", "args": {"palette": "jump_to_imports"}, "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "keys": ["ctrl+.", "ctrl+b"], "command": "gs9o_build", "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "keys": ["ctrl+.", "ctrl+r"], "command": "gs9o_open", "args": {"run": ["replay"], "focus_view": false}, }, { "keys": ["ctrl+.", "ctrl+g"], "command": "gs9o_open", "args": {"run": [".actuate"], "focus_view": false, "show_view": false}, "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "keys": ["ctrl+.", "ctrl+g"], "command": "gs9o_open_selection", "context": [{ "key": "selector", "operator": "equal", "operand": "text.9o" }] }, { "keys": ["ctrl+.", "ctrl+h"], "command": "gs_doc", "args": {"mode": "hint"}, "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "keys": ["ctrl+.", "ctrl+."], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "GoSublime: "} }, { "keys": ["ctrl+.", "ctrl+f"], "command": "margo_fmt", }, { "keys": ["ctrl+.", "ctrl+n"], "command": "gs_new_go_file" }, { "keys": ["ctrl+.", "ctrl+a"], "command": "gs_browse_declarations" }, { "keys": ["ctrl+.", "ctrl+l"], "command": "gs_browse_declarations", "args": { "dir": "." }, "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "keys": ["ctrl+.", "ctrl+o"], "command": "gs_browse_packages" }, { "keys": ["ctrl+.", "ctrl+m"], "command": "gs_browse_files" }, { "keys": ["ctrl+.", "ctrl+t"], "command": "margo_user_cmds", "args": {"action": "QueryTestCmds"}, }, { "keys": ["ctrl+.", "ctrl+space"], "command": "gs_show_call_tip", "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] }, { "ke
null
null
null
null
null
null
github_plus_top10pct_by_avg
ys": ["ctrl+9"], "command": "gs9o_win_open" }, { "keys": ["ctrl+.","ctrl+9"], "command": "gs9o_win_open" }, { "keys": ["ctrl+.","ctrl+0"], "command": "margo_show_hud" }, { "keys": ["ctrl+space"], "command": "auto_complete", "args": {"disable_auto_insert": true, "api_completions_only": true, "next_completion_if_showing": false}, "context": [{ "key": "selector", "operator": "equal", "operand": "text.9o" }] }, { "keys": ["enter"], "command": "gs9o_exec", "args": {"save_hist": true}, "context": [{ "key": "selector", "operator": "equal", "operand": "text.9o" }] }, { "keys": ["enter"], "command": "commit_completion", "context": [ { "key": "auto_complete_visible" }, { "key": "setting.auto_complete_commit_on_tab", "operand": false }, { "key": "selector", "operator": "equal", "operand": "text.9o" } ] }, { "keys": ["ctrl+enter"], "command": "gs9o_insert_line", "context": [{ "key": "selector", "operator": "equal", "operand": "text.9o" }] }, { "keys": ["ctrl+shift+enter"], "command": "gs9o_insert_line", "args": {"after": false}, "context": [{ "key": "selector", "operator": "equal", "operand": "text.9o" }] }, { "keys": ["up"], "command": "gs9o_move_hist", "args": {"up": true}, "context": [ { "key": "selector", "operator": "equal", "operand": "prompt.9o" }, { "key": "auto_complete_visible", "operand": false } ] }, { "keys": ["down"], "command": "gs9o_move_hist", "args": {"up": false}, "context": [ { "key": "selector", "operator": "equal", "operand": "prompt.9o" }, { "key": "auto_complete_visible", "operand": false } ] } ] // Copyright 2012-present Oliver Eilhard. All rights reserved. // Use of this source code is governed by a MIT-license. // See http://olivere.mit-license.org/license.txt for details. package elastic import ( "encoding/json" "testing" ) func TestTermSuggesterSource(t *testing.T) { s := NewTermSuggester("name"). Text("n"). Field("suggest") src, err := s.Source(true) if err != nil { t.Fatal
null
null
null
null
null
null
github_plus_top10pct_by_avg
(err) } data, err := json.Marshal(src) if err != nil { t.Fatalf("marshaling to JSON failed: %v", err) } got := string(data) expected := `{"name":{"text":"n","term":{"field":"suggest"}}}` if got != expected { t.Errorf("expected\n%s\n,got:\n%s", expected, got) } } func TestTermSuggesterWithPrefixLengthSource(t *testing.T) { s := NewTermSuggester("name"). Text("n"). Field("suggest"). PrefixLength(0) src, err := s.Source(true) if err != nil { t.Fatal(err) } data, err := json.Marshal(src) if err != nil { t.Fatalf("marshaling to JSON failed: %v", err) } got := string(data) expected := `{"name":{"text":"n","term":{"field":"suggest","prefix_length":0}}}` if got != expected { t.Errorf("expected\n%s\n,got:\n%s", expected, got) } } # 前端每周清单第 22 期:ES8 正式发布、React 与 GraphQL 开发指南和性能优化,Vue.js 2.4.0 发布以及使用 TypeScript 开发 Vue.js 应用 `前端` `前端每周清单` [前端每周清单](http://www.infoq.com/cn/FE-Weekly)专注前端领域内容,分为新闻热点、开发教程、工程实践、深度阅读、开源项目、巅峰人生等栏目。关注【前端之巅】微信公众号(ID:frontshow),及时获取前端每周清单。 ## 新闻热点 `国内国外,前端最新动态` - [ECMAScript 2017(ES8)正式发布](https://parg.co/b10):ECMAScript 2017 或 ES8 于 2017 年六月底由 TC39 正式发布,可以在[这里](https://www.ecma-international.org/ecma-262/8.0/index.html)浏览完整的版本;ES8 中代表性的特征包括了 String padding、Object.values、Object.entries、Object.getOwnPropertyDescriptors、 函数参数列表与调用中的尾部逗号、异步函数、共享内存与原子操作等。 - [Vue.js 2.4.0 发布](https://github.com/vuejs/vue/releases/tag/v2.4.0):Vue.js 2.4.0 版本提供了内置的服务端渲染与异步组件支持,从而保证了在服务端渲染中也能使用异步组件,而不再是局限于路由中使用。此外该版本还简化了包装组件的写�
null
null
null
null
null
null
github_plus_top10pct_by_avg
��、提供了 v-on 等一系列新的指令或者 API 特性,并且修复了老版本中存在的错误;更多详细内容可参考原文,或者阅读 [ Vue.js 2.4.0 中的 4 个重大变化](https://parg.co/b17)一文。 - [npm 5.2.0 内置 npx 包执行器](https://parg.co/bIw):近日发布的 npm 5.2.0 版本中内置了伴生命令:npx,类似于 npm 简化了项目开发中的依赖安装与管理,该工具致力于提升开发者使用包提供的命令行的体验。npx 允许我们使用本地安装的命令行工具而不需要再定义 npm run-script,并且允许我们仅执行一次脚本而不需要再将其实际安装到本地;同时 npx 还允许我们以不同的 node 版本来运行指定命令、允许我们交互式地开发 node 命令行工具以及便捷地安装来自于 gist 的脚本。 - [Babylon.js 3.0 发布](https://parg.co/b1C):Babylon.js 是基于 HTML5 与 WebGL 的创建 3D 交互应用的开源框架,它提供了易用的 API 与开箱即用的性能优化。近日发布的 3.0 版本是 Babylon 重要的里程碑之一,该版本包含了大量的新特性与错误修复,支持 WebGL 2、WebVR 1.1、gITF 2.0、PBR 等多个特性。 - [Node.js 发布重大安全更新](https://parg.co/b1a):近日 Node.js 发布重大安全更新,主要针对固定哈希表种子值(Constant HashTable Seeds)等多个 Bug。目前流行中几个版本的 Node.js(8.x,7.x,V6 LTS,V4 LTS)中都使用了固定的哈希表种子值,这有可能会导致 Node.js 应用受到基于哈希洪水的 DoS 攻击;暂时的修复方式是默认关闭 V8 的快照功能,导致依赖于 `vm.runInNewContext` 的代码会有所性能损耗,不过未来会选择合适的方案重新实现该部分代码。 ## 开发教程 `步步为营,掌握基础技能` - [Progressive Web Apps 入门教程](https://parg.co/b1n):或许你已经对 PWA 有所耳闻,或者已经真实使用过某个 PWA 应用;本文并不着眼于详细介绍 PWA 的内部原理与工作机制�
null
null
null
null
null
null
github_plus_top10pct_by_avg
��而是希望以简明扼要的语义引导读者构建 PWA 应用。本文依次介绍了如何测试自身应用的 PWA 评分、构建图标与说明、添加 Service Worker、发布到 Github Pages 等;更多 PWA 相关资料参考 [ https://parg.co/bVh  ](https://parg.co/bVh)。 - [GraphQL 全栈教程](https://github.com/howtographql/howtographql):HowToGraphQL 是介绍 GraphQL 的全栈教程,由 Graphcool 以及很多其他优秀的贡献者协作而成。该教程首先是对于 GraphQL 设计理念、基础概念以及先进特性的介绍,然后介绍了在 React、Vue、Expo 等前端项目中如何使用 GraphQL,以及如何使用 Graphcool、JavaScript、Java 等语言快速搭建 GraphQL 服务端;更多 GraphQL 相关资料参考 [ https://parg.co/b1e ](https://parg.co/b1e)。 - [Vue.js 项目中使用 TypeScript](https://parg.co/b1j):Vue.js 是优秀的渐进式前端框架,而 TypeScript 则可以为项目添加静态类型检测的特性,本文即是介绍如何在 Vue.js 项目中使用 TypeScript。本文以 Vue.js 中的单文件组件为例,首先讨论了 tsconfig.json 的基本配置以及如何引入 Webpack 并配置合适的 loader;然后介绍了 TypeScript 的基础用法,更多 Vue.js 相关资料参考[ https://parg.co/byL ](https://parg.co/byL)。 - [NgRx 的设计模式与技巧分享](https://blog.nrwl.io/ngrx-patterns-and-techniques-f46126e2b1e5):状态管理一直是构建前端应用过程中的难点之一,Angular 也为我们提供了多种不同的设计模式来进行状态管理;而本文即是介绍如何使用 NgRx 这个库进行状态管理。NgRx 是非常简单易用,没有太多限制条件的状态管理库;本文首先概述了 NgRx 的核心概念与设计原则,然后以实际的项目为例介绍了如何使用 NgRx 处理 Action 以及副作用。 - [从零到一学习如何用 Babylon.js 创建跨平台的 WebVR 体验](https://parg.co/b1i):WebVR 允许我们跨平台地在多设备上发布应用与内容,而�
null
null
null
null
null
null
github_plus_top10pct_by_avg
�文即介绍如何利用 Babylon.js 创建跨平台地 WebVR 应用。本文首先介绍了可供开发者使用的 VR 设备与扩展,然后介绍如何搭建基础的开发环境、如何开发 WebVR 的基本帧动画、如何响应用户交互并且添加第三方控制器等内容。 ## 工程实践 `立足实践,提示实际水平` - [用强类型语言 GraphQL 增强 React](https://parg.co/b1X):GraphQL、React 这两项技术都来自 Facebook,它们共同成长。在本文中,Shane Stillwell 展示了 GraphQL 作为一种强类型的基于 JavaScript 的语言,如何帮助开发者与他们的数据建立联系并改善跨服务边界的封送处理。GraphQL 是可扩展的,并可与 REST 共存,可以在任意后端软件中实现;更多 GraphQL 相关资料参考 [ https://parg.co/b1e ](https://parg.co/b1e)。 - [高性能 React 开发:3 个常用的辅助工具](https://parg.co/b1v):我们可以使用 React 开发高性能的应用,不过有时候一些小的错误却会导致严重的性能错误。缓慢的组件挂载、过深的组件树以及不必要的渲染都有可能会削弱应用用户体验。幸而现在有很多优秀的工具能够帮助我们应对这些性能问题,而作者在本文中即是详细地介绍了三个辅助工具及相关技术以提升应用性能;更多 React 相关资料参考[ https://parg.co/bM1 ](https://parg.co/bM1)。 - [你可能并不知道的 16 个 SCSS 特性](https://gist.github.com/jareware/4738651):作者自 2009 年以来一直使用 SCSS/SASS 来进行大部分的样式工作,而本文即是对于某些有用但是并不一定为人所知的 SCSS 特性进行介绍。本文介绍的特性包括了父选择器的灵活用法、控制流指令、默认函数参数、扩展操作符等等;更多 CSS/SCSS 相关资料参考[ https://parg.co/baH  ](https://parg.co/baH)。 - [大幅度减少 CSS 包体大小](https://parg.co/b19):本文作者介绍了自己在构建某个在线售票的网站过程中,如何利�
null
null
null
null
null
null
github_plus_top10pct_by_avg
��样式类名分割与作用域隔离来大幅度减少 CSS 打包文件体积的实践技巧。作者主要使用 CSS Modules,然后自定义了其样式类名生成规则来保证生成较短的样式类名并且使用作用域隔离来保证样式隔离。 - [扩展 Node.js 应用](https://parg.co/b1y):Node.js 设计的初衷之一即是保证其可扩展性,本文则详细介绍了开发者应该了解的可用于扩展 Node.js 应用的内建工具。本文首先介绍了复制、分解、分割等常用的设计思想,然后讨论了如何利用 Node.js 内置的 Cluster 模块来保证应用的可扩展性与如何提供零停机重启的特性。 ## 深度阅读 `深度思考,升华开发智慧` - [常见 Web 框架的内部技术纵览](https://parg.co/b1Q):该系列文章从用户界面开发、用户体验设计以及内部技术纵览等多个角度讨论了现代 Web 框架的设计理念与思路;而本文着重于讨论不同的 Web 框架,对于某些共通的基本需求的不同实现方式,包括了它们支持的运行环境、如何与现有的规范保持一致、如何提供函数式支持、如何保证前向兼容性、如何进行国际化等多个方面。 - [Node.js 实战第二版](https://github.com/azat-co/practicalnode):该仓库是 Azat Mardan 的著作 Practical Node.js 第二版参考的开源发布地址,包含了十二个章节与相关的示范代码,非常值得一读。该书依次介绍了 Node.js 环境搭建与 Express.js 初探、基于 Mocha 的单元测试、模板引擎、数据持久化与性能优化、项目调试、部署与发布等章节;更多 Node.js 相关资料参考 [ https://parg.co/be0 ](https://parg.co/be0)。 - [解构 React Fiber,了解其工作流程](http://makersden.io/blog/look-inside-fiber/):调和算法是 React 的核心机制之一,而在即将发布的 16.0.0 版本中 React 会引入 Fiber 替代现有的 Stack Reconciler。本文则是深入浅出地介绍 Fiber 工作流程与代码逻辑,首先从�
null
null
null
null
null
null
github_plus_top10pct_by_avg
��户端渲染的入口函数 `render` 开始,然后介绍在状态变化之后一系列地响应步骤;更多相关资料参考 [ https://parg.co/bM1  ](https://parg.co/bM1)。 - [代码风格约定与标准](https://github.com/Kristories/awesome-guidelines):本仓库提供了一系列的各个语言的常用代码风格约定与标准,与 JavaScript 相关的包含了来自 Google、Airbnb 等多个公司或者社区的样式规范,还有包括 HTML、CSS、SCSS 等一系列 Web 相关的规范。 - [ES2015 中集合迭代器的优化](https://parg.co/b1w):ECMAScript 2015 中引入了 Map 与 Set 等常用的集合;这些集合同样实现了迭代器的特性,因此也就允许我们使用 `for-of` 或者扩展操作符来迭代操作这些集合。不过在很多的评测中这些新引入的集合的迭代遍历性能并不是很好,本文则详细介绍了引擎中导致 Set 等集合迭代性能较差的原因,并且给出了解决方案与未来的实现规划。 ## 开源项目 `乐于分享,共推前端发展` - [Pell](https://github.com/jaredreich/pell):Pell 是仅有 1KB 的所谓所见即所得的富文本编辑器,其不需要依赖于 jQuery、BootStrap 等第三方库。Pell 主要以 ES6 语法开发,并且支持自定义的 SCSS 文件或者复写 CSS 样式来自定义风格,也是非常不错的值得借鉴的编辑器开发示例。 - [doppio](https://github.com/plasma-umass/doppio): doppio 是基于 TypeScript 0.5.0 版本编写的 Java 虚拟机(JVM),其支持 Node.js 6.0 以上版本,并且内置了 Java 8 JDK 环境;doppio 是个有趣的尝试打破浏览器语言栅栏的尝试,浏览其源代码也可以学习如何编写 Java 虚拟机。 - [Bundle Buddy](https://github.com/samccone/bundle-buddy):Bundle Buddy 能够通过分析编译生成的 SourceMap 来寻找 JavaScript 代码块之间的源代码冗余情况。该工具能够帮助开发者寻找合适的代码分割点以降低最终发布应用的不稳定性,同时还能提升�
null
null
null
null
null
null
github_plus_top10pct_by_avg
�面加载性能。 - [gpu.js](https://github.com/gpujs/gpu.js):在[上周的前端每周清单](https://zhuanlan.zhihu.com/p/27815800)中我们介绍过 GPGPU(General Purpose Computing on GPUs)的概念与基于 WebGL 的实现方式,而 gpu.js 就是提供了浏览器中快速实现 GPGPU 的单文件 JavaScript 库。gpu.js 能够自动地将某些特定的 JavaScript 函数编译为中间语言,然后利用 WebGLS API 使其运行在 GPU 中;而在某些无法使用 GPU 的环境下,仍然会将这些函数以正常的 JavaScript 执行流运行。 - [TagUI](https://github.com/tebelorg/TagUI): TagUI 是通用的 Web 自动化交互,提供了开箱即用的声明式流程配置使用特性,支持 Chrome、Firefox、PhantomJS、Headless Chrome 等多个运行环境;同时 TagUI 还提供了 Chrome 插件以记录具体步骤以及对象存储和灵活的数据库存储支持。 ## 巅峰人生 ## 前端之巅 「前端之巅」是 InfoQ 旗下关注前端技术的垂直社群,加入前端之巅学习群请关注「前端之巅」公众号后回复“加群”。投稿请发邮件到 editors@cn.infoq.com,注明“前端之巅投稿”。 ![前端之巅微信底图-5.jpg](http://upload-images.jianshu.io/upload_images/1647496-01712a993d2b23de.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Notebook[{ Cell[TextData[{ "New in: ", Cell["9.0", "HistoryData", CellTags->"New"], " | Modified in: ", Cell[" ", "HistoryData", CellTags->"Modified"], " | Obsolete in: ", Cell[" ", "HistoryData", CellTags->"Obsolete"], " | Excised in: ", Cell[" ", "HistoryData", CellTags->"Excised"] }], "History", CellID->1247902091], Cell[CellGroupData[{ Cell["Categorization", "CategorizationSection", CellID->1122911449], Cell["Symbol", "Categorization", CellLabel->"Entity Type", CellID->686433507], Cell["FeynCalc", "Categorization", CellLabel->"Paclet Name", CellID->605800465], Cell["FeynCalc`", "Categorization", CellLabel->"Context", CellID->468444828], Cell["FeynCalc/ref/B0
null
null
null
null
null
null
github_plus_top10pct_by_avg
0", "Categorization", CellLabel->"URI"] }, Open ]], Cell[CellGroupData[{ Cell["Keywords", "KeywordsSection", CellID->477174294], Cell["XXXX", "Keywords", CellID->1164421360] }, Closed]], Cell[CellGroupData[{ Cell["Syntax Templates", "TemplatesSection", CellID->1872225408], Cell[BoxData[""], "Template", CellLabel->"Additional Function Template", CellID->1562036412], Cell[BoxData[""], "Template", CellLabel->"Arguments Pattern", CellID->158391909], Cell[BoxData[""], "Template", CellLabel->"Local Variables", CellID->1360575930], Cell[BoxData[""], "Template", CellLabel->"Color Equal Signs", CellID->793782254] }, Closed]], Cell[CellGroupData[{ Cell["Details", "DetailsSection", CellID->307771771], Cell["XXXX", "Details", CellLabel->"Lead", CellID->670882175], Cell["XXXX", "Details", CellLabel->"Developers", CellID->350963985], Cell["XXXX", "Details", CellLabel->"Authors", CellID->8391405], Cell["XXXX", "Details", CellLabel->"Feature Name", CellID->3610269], Cell["XXXX", "Details", CellLabel->"QA", CellID->401364205], Cell["XXXX", "Details", CellLabel->"DA", CellID->350204745], Cell["XXXX", "Details", CellLabel->"Docs", CellID->732958810], Cell["XXXX", "Details", CellLabel->"Features Page Notes", CellID->222905350], Cell["XXXX", "Details", CellLabel->"Comments", CellID->240026365] }, Closed]], Cell[CellGroupData[{ Cell["B00", "ObjectName", CellID->1224892054], Cell[TextData[{ Cell[" ", "ModInfo"], Cell[BoxData[ RowBox[{"B00", "[", RowBox[{"pp", ",", " ", RowBox[{"ma", "^", "2"}], ",", RowBox[{"mb", "^", "2"}]}], "]"}]], "InlineFormula"], " \[LineSeparator]", "is the Passarino-Veltman ", Cell[BoxData[ FormBox[ SubscriptBox["B", "00"], TraditionalForm]]], "-function, i.e., the coefficient function of the metric tensor. All \ arguments are scalars and have dimension mass^2." }], "Usage", CellID->982511436], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Options", "[", "B00", "]"}]], "Input", CellTags->"B00", CellLabel->"In[1]:=", CellID
null
null
null
null
null
null
github_plus_top10pct_by_avg
->356334892], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{"BReduce", "\[Rule]", "True"}], "}"}], TraditionalForm]], "Output", CellTags->"B00", CellLabel->"Out[1]=", CellID->729895507] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Tutorials", "TutorialsSection", CellID->250839057], Cell["XXXX", "Tutorials", CellID->341631938] }, Open ]], Cell[CellGroupData[{ Cell["Related Demonstrations", "RelatedDemonstrationsSection", CellID->1268215905], Cell["XXXX", "RelatedDemonstrations", CellID->1129518860] }, Open ]], Cell[CellGroupData[{ Cell["Related Links", "RelatedLinksSection", CellID->1584193535], Cell["XXXX", "RelatedLinks", CellID->1038487239] }, Open ]], Cell[CellGroupData[{ Cell["See Also", "SeeAlsoSection", CellID->1255426704], Cell[TextData[{ ButtonBox["B0", BaseStyle->"Link", ButtonData:>"paclet:FeynCalc/ref/B0", ButtonNote->"B0"], ", ", ButtonBox["B1", BaseStyle->"Link", ButtonData:>"paclet:FeynCalc/ref/B1", ButtonNote->"B1"], ", ", ButtonBox["PaVe", BaseStyle->"Link", ButtonData:>"paclet:FeynCalc/ref/PaVe", ButtonNote->"PaVe"], "." }], "SeeAlso"] }, Open ]], Cell[CellGroupData[{ Cell["More About", "MoreAboutSection", CellID->38303248], Cell["XXXX", "MoreAbout", CellID->1665078683] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ InterpretationBox[GridBox[{ { StyleBox["Examples", "PrimaryExamplesSection"], ButtonBox[ RowBox[{ RowBox[{"More", " ", "Examples"}], " ", "\[RightTriangle]"}], BaseStyle->"ExtendedExamplesLink", ButtonData:>"ExtendedExamples"]} }], $Line = 0; Null]], "PrimaryExamplesSection", CellID->880084151], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"B00", "[", RowBox[{ RowBox[{"SPD", "[", "p", "]"}], ",", SuperscriptBox["m", "2"], ",", SuperscriptBox["M", "2"]}], "]"}]], "Input", CellTags->"B00", CellLabel->"In[11]:=", CellID->1556776794], Cell[BoxData[ FormBox[ RowBox[{ FractionBox[ RowBox[{ RowBox[{"(", RowBox[{ SuperscriptBox
null
null
null
null
null
null
github_plus_top10pct_by_avg
["m", "2"], "-", RowBox[{"2", " ", "m", " ", "M"}], "+", SuperscriptBox["M", "2"], "-", FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm]}], ")"}], " ", RowBox[{"(", RowBox[{ SuperscriptBox["m", "2"], "+", RowBox[{"2", " ", "m", " ", "M"}], "+", SuperscriptBox["M", "2"], "-", FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm]}], ")"}], " ", FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"B\"\>", "\<\"0\"\>"], "(", RowBox[{ FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm], ",", SuperscriptBox["m", "2"], ",", SuperscriptBox["M", "2"]}], ")"}], TraditionalForm], HoldForm], TraditionalForm]}], RowBox[{"4", " ", RowBox[{"(", RowBox[{"1", "-", "D"}], ")"}], " ", FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm]}]], "+", FractionBox[ RowBox[{ FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"A\"\>", "\<\"0\"\>"], "(", SuperscriptBox["M", "2"], ")"}], TraditionalForm], HoldForm], TraditionalForm], " ", RowBox[{"(", RowBox[{ SuperscriptBox["m", "2"], "-", SuperscriptBox["M", "2"], "-", FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm]}], ")"}]}], RowBox[{"4", " ", RowBox[{"(", RowBox[{"1", "-", "D"}], ")"}], " ", FormBox[ SuperscriptB
null
null
null
null
null
null
github_plus_top10pct_by_avg
ox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm]}]], "-", FractionBox[ RowBox[{ FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"A\"\>", "\<\"0\"\>"], "(", SuperscriptBox["m", "2"], ")"}], TraditionalForm], HoldForm], TraditionalForm], " ", RowBox[{"(", RowBox[{ SuperscriptBox["m", "2"], "-", SuperscriptBox["M", "2"], "+", FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm]}], ")"}]}], RowBox[{"4", " ", RowBox[{"(", RowBox[{"1", "-", "D"}], ")"}], " ", FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm]}]]}], TraditionalForm]], "Output", CellTags->"B00", CellLabel->"Out[11]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"B00", "[", RowBox[{ RowBox[{"SPD", "[", "p", "]"}], ",", SuperscriptBox["m", "2"], ",", SuperscriptBox["m", "2"]}], "]"}]], "Input", CellTags->"B00", CellLabel->"In[13]:=", CellID->1244341296], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"-", FractionBox[ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"4", " ", SuperscriptBox["m", "2"]}], "-", FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm]}], ")"}], " ", FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"B\"\>", "\<\"0\"\>"], "(", RowBox[{ FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm], ",", SuperscriptBox["m", "2"], ",",
null
null
null
null
null
null
github_plus_top10pct_by_avg
SuperscriptBox["m", "2"]}], ")"}], TraditionalForm], HoldForm], TraditionalForm]}], RowBox[{"4", " ", RowBox[{"(", RowBox[{"1", "-", "D"}], ")"}]}]]}], "-", FractionBox[ FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"A\"\>", "\<\"0\"\>"], "(", SuperscriptBox["m", "2"], ")"}], TraditionalForm], HoldForm], TraditionalForm], RowBox[{"2", " ", RowBox[{"(", RowBox[{"1", "-", "D"}], ")"}]}]]}], TraditionalForm]], "Output", CellTags->"B00", CellLabel->"Out[13]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"B00", "[", RowBox[{ RowBox[{"SPD", "[", "p", "]"}], ",", SuperscriptBox["m", "2"], ",", SuperscriptBox["M", "2"], ",", RowBox[{"BReduce", "\[Rule]", "False"}]}], "]"}]], "Input", CellTags->"B00", CellLabel->"In[15]:=", CellID->1245211962], Cell[BoxData[ FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"B\"\>", "\<\"00\"\>"], "(", RowBox[{ FormBox[ SuperscriptBox[ FormBox[ FormBox["p", TraditionalForm], TraditionalForm], "2"], TraditionalForm], ",", SuperscriptBox["m", "2"], ",", SuperscriptBox["M", "2"]}], ")"}], TraditionalForm], HoldForm], TraditionalForm]], "Output", CellTags->"B00", CellLabel->"Out[15]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"B00", "[", RowBox[{"0", ",", SuperscriptBox["m", "2"], ",", SuperscriptBox["m", "2"]}], "]"}]], "Input", CellTags->"B00", CellLabel->"In[16]:=", CellID->1891605192], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"-", FractionBox[ RowBox[{ SuperscriptBox["m", "2"], " ", FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"B\"\>", "\<\"0\"\>"], "(", RowBox[{"0", ",", SuperscriptBox["m", "2"], ",", SuperscriptBox["m", "2"]}], ")"}], TraditionalForm], HoldForm
null
null
null
null
null
null
github_plus_top10pct_by_avg
], TraditionalForm]}], RowBox[{"1", "-", "D"}]]}], "-", FractionBox[ FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"A\"\>", "\<\"0\"\>"], "(", SuperscriptBox["m", "2"], ")"}], TraditionalForm], HoldForm], TraditionalForm], RowBox[{"2", " ", RowBox[{"(", RowBox[{"1", "-", "D"}], ")"}]}]]}], TraditionalForm]], "Output", CellTags->"B00", CellLabel->"Out[16]="] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"B00", "[", RowBox[{ RowBox[{"SmallVariable", "[", SuperscriptBox["M", "2"], "]"}], ",", SuperscriptBox["m", "2"], ",", SuperscriptBox["m", "2"]}], "]"}]], "Input", CellTags->"B00", CellLabel->"In[20]:=", CellID->1823175928], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"-", FractionBox[ RowBox[{ SuperscriptBox["m", "2"], " ", FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"B\"\>", "\<\"0\"\>"], "(", RowBox[{ SuperscriptBox["M", "2"], ",", SuperscriptBox["m", "2"], ",", SuperscriptBox["m", "2"]}], ")"}], TraditionalForm], HoldForm], TraditionalForm]}], RowBox[{"1", "-", "D"}]]}], "-", FractionBox[ FormBox[ TagBox[ FormBox[ RowBox[{ SubscriptBox["\<\"A\"\>", "\<\"0\"\>"], "(", SuperscriptBox["m", "2"], ")"}], TraditionalForm], HoldForm], TraditionalForm], RowBox[{"2", " ", RowBox[{"(", RowBox[{"1", "-", "D"}], ")"}]}]]}], TraditionalForm]], "Output", CellTags->"B00", CellLabel->"Out[20]="] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["More Examples", "ExtendedExamplesSection", CellTags->"ExtendedExamples", CellID->1854448968], Cell[BoxData[ InterpretationBox[Cell["Scope", "ExampleSection"], $Line = 0; Null]], "ExampleSection", CellID->1293636265], Cell[BoxData[ InterpretationBox[Cell["Generalizations & Extensions", "ExampleSection"], $Line = 0; Nul
null
null
null
null
null
null
github_plus_top10pct_by_avg
l]], "ExampleSection", CellID->1020263627], Cell[CellGroupData[{ Cell[BoxData[ InterpretationBox[Cell["Options", "ExampleSection"], $Line = 0; Null]], "ExampleSection", CellID->2061341341], Cell[BoxData[ InterpretationBox[Cell["XXXX", "ExampleSubsection"], $Line = 0; Null]], "ExampleSubsection", CellID->1757724783], Cell[BoxData[ InterpretationBox[Cell["XXXX", "ExampleSubsection"], $Line = 0; Null]], "ExampleSubsection", CellID->1295379749] }, Closed]], Cell[BoxData[ InterpretationBox[Cell["Applications", "ExampleSection"], $Line = 0; Null]], "ExampleSection", CellID->258228157], Cell[BoxData[ InterpretationBox[Cell["Properties & Relations", "ExampleSection"], $Line = 0; Null]], "ExampleSection", CellID->2123667759], Cell[BoxData[ InterpretationBox[Cell["Possible Issues", "ExampleSection"], $Line = 0; Null]], "ExampleSection", CellID->1305812373], Cell[BoxData[ InterpretationBox[Cell["Interactive Examples", "ExampleSection"], $Line = 0; Null]], "ExampleSection", CellID->1653164318], Cell[BoxData[ InterpretationBox[Cell["Neat Examples", "ExampleSection"], $Line = 0; Null]], "ExampleSection", CellID->589267740] }, Open ]] }, WindowSize->{700, 770}, WindowMargins->{{Automatic, 552}, {Automatic, -35}}, Visible->True, PrivateNotebookOptions->{"FileOutlineCache"->False}, CreateCellID->False, CellContext->"Global`", TrackCellChangeTimes->False, FrontEndVersion->"10.3 for Linux x86 (64-bit) (December 10, 2015)", StyleDefinitions->FrontEnd`FileName[{"Wolfram"}, "FunctionPageStyles.nb", CharacterEncoding -> "UTF-8"] ] // SPDX-License-Identifier: GPL-2.0 /* * Pioctl operations for Coda. * Original version: (C) 1996 Peter Braam * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University * * Carnegie Mellon encourages users of this code to contribute improvements * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>. */ #include <linux/types.h> #include <linux/kernel.h> #include <linux/time.h> #include <linux/fs.h> #include <linux/stat.h> #include <linux/errno
null
null
null
null
null
null
github_plus_top10pct_by_avg
.h> #include <linux/string.h> #include <linux/namei.h> #include <linux/module.h> #include <linux/uaccess.h> #include <linux/coda.h> #include "coda_psdev.h" #include "coda_linux.h" /* pioctl ops */ static int coda_ioctl_permission(struct inode *inode, int mask); static long coda_pioctl(struct file *filp, unsigned int cmd, unsigned long user_data); /* exported from this file */ const struct inode_operations coda_ioctl_inode_operations = { .permission = coda_ioctl_permission, .setattr = coda_setattr, }; const struct file_operations coda_ioctl_operations = { .unlocked_ioctl = coda_pioctl, .llseek = noop_llseek, }; /* the coda pioctl inode ops */ static int coda_ioctl_permission(struct inode *inode, int mask) { return (mask & MAY_EXEC) ? -EACCES : 0; } static long coda_pioctl(struct file *filp, unsigned int cmd, unsigned long user_data) { struct path path; int error; struct PioctlData data; struct inode *inode = file_inode(filp); struct inode *target_inode = NULL; struct coda_inode_info *cnp; /* get the Pioctl data arguments from user space */ if (copy_from_user(&data, (void __user *)user_data, sizeof(data))) return -EINVAL; /* * Look up the pathname. Note that the pathname is in * user memory, and namei takes care of this */ error = user_path_at(AT_FDCWD, data.path, data.follow ? LOOKUP_FOLLOW : 0, &path); if (error) return error; target_inode = d_inode(path.dentry); /* return if it is not a Coda inode */ if (target_inode->i_sb != inode->i_sb) { error = -EINVAL; goto out; } /* now proceed to make the upcall */ cnp = ITOC(target_inode); error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); out: path_put(&path); return error; } <?php namespace Oro\Bundle\WorkflowBundle\Tests\Unit\Entity; use Oro\Bundle\WorkflowBundle\Entity\WorkflowDefinition; use Oro\Bundle\WorkflowBundle\Entity\WorkflowRestriction; use Oro\Bundle\WorkflowBundle\Entity\WorkflowStep; use Symfony\Component\PropertyAccess\PropertyAccess; class WorkflowRestrictionTest extends \
null
null
null
null
null
null
github_plus_top10pct_by_avg
PHPUnit\Framework\TestCase { /** * @dataProvider propertiesDataProvider * * @param string $property * @param mixed $value */ public function testSettersAndGetters($property, $value) { $restriction = new WorkflowRestriction(); $accessor = PropertyAccess::createPropertyAccessor(); $accessor->setValue($restriction, $property, $value); $this->assertEquals($value, $accessor->getValue($restriction, $property)); } public function propertiesDataProvider() { return [ ['attribute', 'test'], ['step', new WorkflowStep()], ['definition', new WorkflowDefinition()], ['entityClass', 'TestEntity'], ['field', 'test'], ['mode', 'full'], ['values', []], ]; } public function testImport() { $restriction = new WorkflowRestriction(); $step = new WorkflowStep(); $step->setName('step'); $definition = new WorkflowDefinition(); $definition->addStep($step); $restriction->setAttribute('attribute'); $restriction->setStep($step); $restriction->setEntityClass('TestEntity'); $restriction->setField('test'); $restriction->setMode('allow'); $restriction->setValues(['1']); $newRestriction = new WorkflowRestriction(); $newRestriction->setDefinition($definition); $this->assertEquals($newRestriction, $newRestriction->import($restriction)); $this->assertEquals('attribute', $newRestriction->getAttribute()); $this->assertEquals($step, $newRestriction->getStep()); $this->assertEquals('TestEntity', $newRestriction->getEntityClass()); $this->assertEquals('test', $newRestriction->getField()); $this->assertEquals('allow', $newRestriction->getMode()); $this->assertEquals(['1'], $newRestriction->getValues()); $this->assertEquals($restriction->getHashKey(), $newRestriction->getHashKey()); } } /****
null
null
null
null
null
null
github_plus_top10pct_by_avg
*************************************************************************** * Copyright (c) 2012 VMware, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v10.html * * Contributors: * VMware, Inc. - initial API and implementation *******************************************************************************/ package org.springframework.ide.eclipse.wizard.template.infrastructure.ui; import java.util.Map; /** * @author Terry Denney * @author Leo Dos Santos * @author Christian Dupuis */ public interface WizardUI { public void collectInput(Map<String, Object> collectedInput, Map<String, String> inputKinds); } /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * This file is available under and governed by the GNU General Public * Licen
null
null
null
null
null
null
github_plus_top10pct_by_avg
se version 2 only, as published by the Free Software Foundation. * However, the following notice accompanied the original version of this * file: * * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at * http://creativecommons.org/publicdomain/zero/1.0/ */ package java.util.concurrent; import java.security.AccessControlContext; import java.security.AccessControlException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Collection; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import sun.security.util.SecurityConstants; import static java.lang.ref.Reference.reachabilityFence; /** * Factory and utility methods for {@link Executor}, {@link * ExecutorService}, {@link ScheduledExecutorService}, {@link * ThreadFactory}, and {@link Callable} classes defined in this * package. This class supports the following kinds of methods: * * <ul> * <li>Methods that create and return an {@link ExecutorService} * set up with commonly useful configuration settings. * <li>Methods that create and return a {@link ScheduledExecutorService} * set up with commonly useful configuration settings. * <li>Methods that create and return a "wrapped" ExecutorService, that * disables reconfiguration by making implementation-specific methods * inaccessible. * <li>Methods that create and return a {@link ThreadFactory} * that sets newly created threads to a known state. * <li>Methods that create and return a {@link Callable} * out of other closure-like forms, so they can be used * in execution methods requiring {@code Callable}. * </ul> * * @author Doug Lea * @since 1.5 */ // 【任务执行框架】的工厂,该类负责生成:【任务执行框架】对象、Callable类型的任务对象、线程工厂对象 public class Executors { /** Cannot instantiate. */
null
null
null
null
null
null
github_plus_top10pct_by_avg
private Executors() { } /*▼ 【工作池】 ████████████████████████████████████████████████████████████████████████████████┓ */ /** * Creates a work-stealing thread pool using the number of * {@linkplain Runtime#availableProcessors available processors} * as its target parallelism level. * * @return the newly created thread pool * * @see #newWorkStealingPool(int) * @since 1.8 */ // 并行度与处理器数量相同的【工作池】 public static ExecutorService newWorkStealingPool() { return new ForkJoinPool(Runtime.getRuntime().availableProcessors(), ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); } /** * Creates a thread pool that maintains enough threads to support * the given parallelism level, and may use multiple queues to * reduce contention. The parallelism level corresponds to the * maximum number of threads actively engaged in, or available to * engage in, task processing. The actual number of threads may * grow and shrink dynamically. A work-stealing pool makes no * guarantees about the order in which submitted tasks are * executed. * * @param parallelism the targeted parallelism level * * @return the newly created thread pool * * @throws IllegalArgumentException if {@code parallelism <= 0} * @since 1.8 */ // 并行度为parallelism的【工作池】 public static ExecutorService newWorkStealingPool(int parallelism) { return new ForkJoinPool(parallelism, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); } /*▲ 【工作池】 ██████████████████████████████████████████████████████████�
null
null
null
null
null
null
github_plus_top10pct_by_avg
��█████████████████████┛ */ /*▼ 【任务执行框架代理】 ████████████████████████████████████████████████████████████████████████████████┓ */ /** * Returns an object that delegates all defined {@link * ExecutorService} methods to the given executor, but not any * other methods that might otherwise be accessible using * casts. This provides a way to safely "freeze" configuration and * disallow tuning of a given concrete implementation. * * @param executor the underlying implementation * * @return an {@code ExecutorService} instance * * @throws NullPointerException if executor null */ // 不可配置 public static ExecutorService unconfigurableExecutorService(ExecutorService executor) { if(executor == null) { throw new NullPointerException(); } return new DelegatedExecutorService(executor); } /*▲ 【任务执行框架代理】 ████████████████████████████████████████████████████████████████████████████████┛ */ /*▼ 【线程池】 ████████████████████████████████████████████████████████████████████████████████┓ */ /** * Creates a thread pool that creates new threads as needed, but * will reuse previously constructed threads when they are * available. These pools will typically improve the performance * of programs that execute many short-lived asynchronous tasks. * Calls to {@code
null
null
null
null
null
null
github_plus_top10pct_by_avg
execute} will reuse previously constructed * threads if available. If no existing thread is available, a new * thread will be created and added to the pool. Threads that have * not been used for sixty seconds are terminated and removed from * the cache. Thus, a pool that remains idle for long enough will * not consume any resources. Note that pools with similar * properties but different details (for example, timeout parameters) * may be created using {@link ThreadPoolExecutor} constructors. * * @return the newly created thread pool */ /* *【缓冲线程池】 * * 提交新任务之后,会创建一个新线程执行它,该新线程在空闲期的存活时长为60秒。 * 换句话说,每个线程在空闲60秒之后就被销毁了,所以适合做缓冲(不是缓存)。 * * 配置: * - 阻塞队列 : SynchronousQueue * -【核心阙值】: 0 * -【最大阙值】: 无限 */ public static ExecutorService newCachedThreadPool() { return new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); } /** * Creates a thread pool that creates new threads as needed, but * will reuse previously constructed threads when they are * available, and uses the provided * ThreadFactory to create new threads when needed. * * @param threadFactory the factory to use when creating new threads * * @return the newly created thread pool * * @throws NullPointerException if threadFactory is null */ /* *【缓冲线程池】,允许自行指定线程工厂 * * 提交新任务之后,会创建一个新线程执行它,该新线程在空闲期的存活时长为60秒。 * 换句话说,每个线程在空闲60秒之后就被销毁了,所以适合做缓冲(不是缓存)。 * * 配置: * - 阻塞队列 : SynchronousQueue * -【核心阙值】: 0 * -【�
null
null
null
null
null
null
github_plus_top10pct_by_avg
��大阙值】: 无限 */ public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory) { return new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), threadFactory); } /** * Creates a thread pool that reuses a fixed number of threads * operating off a shared unbounded queue. At any point, at most * {@code nThreads} threads will be active processing tasks. * If additional tasks are submitted when all threads are active, * they will wait in the queue until a thread is available. * If any thread terminates due to a failure during execution * prior to shutdown, a new one will take its place if needed to * execute subsequent tasks. The threads in the pool will exist * until it is explicitly {@link ExecutorService#shutdown shutdown}. * * @param nThreads the number of threads in the pool * * @return the newly created thread pool * * @throws IllegalArgumentException if {@code nThreads <= 0} */ /* *【固定容量线程池】 * * 线程池中常驻线程数量为nThreads * * 配置: * - 阻塞队列 : LinkedBlockingQueue * -【核心阙值】: nThreads * -【最大阙值】: nThreads */ public static ExecutorService newFixedThreadPool(int nThreads) { return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); } /** * Creates a thread pool that reuses a fixed number of threads * operating off a shared unbounded queue, using the provided * ThreadFactory to create new threads when needed. At any point, * at most {@code nThreads} threads will be active processing * tasks. If additional tasks are submitted when all threads are * active, they will wait in the queue until a thread is * available. If any thread terminates due to a failure during * execution prior to shutdown, a
null
null
null
null
null
null
github_plus_top10pct_by_avg
new one will take its place if * needed to execute subsequent tasks. The threads in the pool will * exist until it is explicitly {@link ExecutorService#shutdown * shutdown}. * * @param nThreads the number of threads in the pool * @param threadFactory the factory to use when creating new threads * * @return the newly created thread pool * * @throws NullPointerException if threadFactory is null * @throws IllegalArgumentException if {@code nThreads <= 0} */ /* *【固定容量线程池】,允许自行指定线程工厂 * * 线程池中常驻线程数量为nThreads * * 配置: * - 阻塞队列 : LinkedBlockingQueue * -【核心阙值】: nThreads * -【最大阙值】: nThreads */ public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory) { return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory); } /** * Creates a thread pool that can schedule commands to run after a * given delay, or to execute periodically. * * @param corePoolSize the number of threads to keep in the pool, * even if they are idle * * @return the newly created scheduled thread pool * * @throws IllegalArgumentException if {@code corePoolSize < 0} */ /* *【定时任务线程池】 * * 用于执行一次性或周期性的定时任务 * * 配置: * - 阻塞队列 : DelayedWorkQueue * -【核心阙值】: corePoolSize * -【最大阙值】: 无限 */ public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize) { return new ScheduledThreadPoolExecutor(corePoolSize); } /** * Creates a thread pool that can schedule commands to run after a * given delay, or to execute periodically. * * @param corePoolSize the number
null
null
null
null
null
null
github_plus_top10pct_by_avg
of threads to keep in the pool, * even if they are idle * @param threadFactory the factory to use when the executor * creates a new thread * * @return the newly created scheduled thread pool * * @throws IllegalArgumentException if {@code corePoolSize < 0} * @throws NullPointerException if threadFactory is null */ /* *【定时任务线程池】,允许自行指定线程工厂 * * 用于执行一次性或周期性的定时任务 * * 配置: * - 阻塞队列 : DelayedWorkQueue * -【核心阙值】: corePoolSize * -【最大阙值】: 无限 */ public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, ThreadFactory threadFactory) { return new ScheduledThreadPoolExecutor(corePoolSize, threadFactory); } /** * Creates a single-threaded executor that can schedule commands * to run after a given delay, or to execute periodically. * (Note however that if this single * thread terminates due to a failure during execution prior to * shutdown, a new one will take its place if needed to execute * subsequent tasks.) Tasks are guaranteed to execute * sequentially, and no more than one task will be active at any * given time. Unlike the otherwise equivalent * {@code newScheduledThreadPool(1)} the returned executor is * guaranteed not to be reconfigurable to use additional threads. * * @return the newly created scheduled executor */ /* *【定时任务线程池代理】 * * 用于执行一次性或周期性的定时任务,线程池中只有一个常驻线程。 * * 配置: * - 阻塞队列 : DelayedWorkQueue * -【核心阙值】: 1 * -【最大阙值】: 无限 */ public static ScheduledExecutorService newSingleThreadScheduledExecutor() { return new DelegatedScheduledExecutorService(new ScheduledThreadPo
null
null
null
null
null
null
github_plus_top10pct_by_avg
olExecutor(1)); } /** * Creates a single-threaded executor that can schedule commands * to run after a given delay, or to execute periodically. (Note * however that if this single thread terminates due to a failure * during execution prior to shutdown, a new one will take its * place if needed to execute subsequent tasks.) Tasks are * guaranteed to execute sequentially, and no more than one task * will be active at any given time. Unlike the otherwise * equivalent {@code newScheduledThreadPool(1, threadFactory)} * the returned executor is guaranteed not to be reconfigurable to * use additional threads. * * @param threadFactory the factory to use when creating new threads * * @return the newly created scheduled executor * * @throws NullPointerException if threadFactory is null */ /* *【定时任务线程池代理】,允许自行指定线程工厂 * * 用于执行一次性或周期性的定时任务,线程池中只有一个常驻线程。 * * 配置: * - 阻塞队列 : DelayedWorkQueue * -【核心阙值】: 1 * -【最大阙值】: 无限 */ public static ScheduledExecutorService newSingleThreadScheduledExecutor(ThreadFactory threadFactory) { return new DelegatedScheduledExecutorService(new ScheduledThreadPoolExecutor(1, threadFactory)); } /** * Returns an object that delegates all defined {@link * ScheduledExecutorService} methods to the given executor, but * not any other methods that might otherwise be accessible using * casts. This provides a way to safely "freeze" configuration and * disallow tuning of a given concrete implementation. * * @param executor the underlying implementation * * @return a {@code ScheduledExecutorService} instance * * @throws NullPointerException if executor null */ /* *【定时任务线程池代理】 * * 不可自定义配�
null
null
null
null
null
null
github_plus_top10pct_by_avg
�,只是对指定的【定时任务执行框架】的简单代理 */ public static ScheduledExecutorService unconfigurableScheduledExecutorService(ScheduledExecutorService executor) { if(executor == null) { throw new NullPointerException(); } return new DelegatedScheduledExecutorService(executor); } /** * Creates an Executor that uses a single worker thread operating * off an unbounded queue. (Note however that if this single * thread terminates due to a failure during execution prior to * shutdown, a new one will take its place if needed to execute * subsequent tasks.) Tasks are guaranteed to execute * sequentially, and no more than one task will be active at any * given time. Unlike the otherwise equivalent * {@code newFixedThreadPool(1)} the returned executor is * guaranteed not to be reconfigurable to use additional threads. * * @return the newly created single-threaded Executor */ /* *【Finalizable线程池】 * * 顺序执行普通任务,线程池中最多只有一个线程。 * * 配置: * - 阻塞队列 : LinkedBlockingQueue * -【核心阙值】: 1 * -【最大阙值】: 1 */ public static ExecutorService newSingleThreadExecutor() { return new FinalizableDelegatedExecutorService(new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>())); } /** * Creates an Executor that uses a single worker thread operating * off an unbounded queue, and uses the provided ThreadFactory to * create a new thread when needed. Unlike the otherwise * equivalent {@code newFixedThreadPool(1, threadFactory)} the * returned executor is guaranteed not to be reconfigurable to use * additional threads. * * @param threadFactory the factory to use when creating new threads * * @return the newly created single-threaded Executor * * @th
null
null
null
null
null
null
github_plus_top10pct_by_avg
rows NullPointerException if threadFactory is null */ /* *【Finalizable线程池】,允许自行指定线程工厂 * * 顺序执行普通任务,线程池中最多只有一个线程。 * * 配置: * - 阻塞队列 : LinkedBlockingQueue * -【核心阙值】: 1 * -【最大阙值】: 1 */ public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory) { return new FinalizableDelegatedExecutorService(new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory)); } /*▲ 【线程池】 ████████████████████████████████████████████████████████████████████████████████┛ */ /*▼ 任务对象 ████████████████████████████████████████████████████████████████████████████████┓ */ /** * Returns a {@link Callable} object that, when * called, runs the given task and returns {@code null}. * * @param task the task to run * * @return a callable object * * @throws NullPointerException if task null */ // 包装Runnable任务,无返回值 public static Callable<Object> callable(Runnable task) { if(task == null) { throw new NullPointerException(); } return new RunnableAdapter<Object>(task, null); } /** * Returns a {@link Callable} object that, when * called, runs the given task and returns the given result. This * can be useful when applying methods requiring a * {@code Callable} to an otherwise resultless action. * * @param task the task to run * @param result the result to return * @param <T>
null
null
null
null
null
null
github_plus_top10pct_by_avg
the type of the result * * @return a callable object * * @throws NullPointerException if task null */ // 包装Runnable任务,有返回值 public static <T> Callable<T> callable(Runnable task, T result) { if(task == null) { throw new NullPointerException(); } return new RunnableAdapter<T>(task, result); } /** * Returns a {@link Callable} object that will, when called, * execute the given {@code callable} under the current access * control context. This method should normally be invoked within * an {@link AccessController#doPrivileged AccessController.doPrivileged} * action to create callables that will, if possible, execute * under the selected permission settings holding within that * action; or if not possible, throw an associated {@link * AccessControlException}. * * @param callable the underlying task * @param <T> the type of the callable's result * * @return a callable object * * @throws NullPointerException if callable null */ // 包装Callable任务,使用上下文访问权限控制器 public static <T> Callable<T> privilegedCallable(Callable<T> callable) { if(callable == null) { throw new NullPointerException(); } return new PrivilegedCallable<T>(callable); } /** * Returns a {@link Callable} object that will, when called, * execute the given {@code callable} under the current access * control context, with the current context class loader as the * context class loader. This method should normally be invoked * within an * {@link AccessController#doPrivileged AccessController.doPrivileged} * action to create callables that will, if possible, execute * under the selected permission settings holding within that * action; or if not possible, throw an associated {@link * AccessControlException}. * * @param callable the under
null
null
null
null
null
null
github_plus_top10pct_by_avg
lying task * @param <T> the type of the callable's result * * @return a callable object * * @throws NullPointerException if callable null * @throws AccessControlException if the current access control * context does not have permission to both set and get context * class loader */ // 包装Callable任务,使用上下文访问权限控制器和当前线程的类加载器 public static <T> Callable<T> privilegedCallableUsingCurrentClassLoader(Callable<T> callable) { if(callable == null) { throw new NullPointerException(); } return new PrivilegedCallableUsingCurrentClassLoader<T>(callable); } /** * Returns a {@link Callable} object that, when * called, runs the given privileged action and returns its result. * * @param action the privileged action to run * * @return a callable object * * @throws NullPointerException if action null */ // 包装PrivilegedAction任务 public static Callable<Object> callable(final PrivilegedAction<?> action) { if(action == null) { throw new NullPointerException(); } return new Callable<Object>() { public Object call() { return action.run(); } }; } /** * Returns a {@link Callable} object that, when * called, runs the given privileged exception action and returns * its result. * * @param action the privileged exception action to run * * @return a callable object * * @throws NullPointerException if action null */ // 包装PrivilegedExceptionAction任务 public static Callable<Object> callable(final PrivilegedExceptionAction<?> action) { if(action == null) { throw new NullPointerException(); } return new Callable<Object>() { public Object call() throws
null
null
null
null
null
null
github_plus_top10pct_by_avg
Exception { return action.run(); } }; } /*▲ 任务对象 ████████████████████████████████████████████████████████████████████████████████┛ */ /*▼ 线程工厂 ████████████████████████████████████████████████████████████████████████████████┓ */ /** * Returns a default thread factory used to create new threads. * This factory creates all new threads used by an Executor in the * same {@link ThreadGroup}. If there is a {@link * java.lang.SecurityManager}, it uses the group of {@link * System#getSecurityManager}, else the group of the thread * invoking this {@code defaultThreadFactory} method. Each new * thread is created as a non-daemon thread with priority set to * the smaller of {@code Thread.NORM_PRIORITY} and the maximum * priority permitted in the thread group. New threads have names * accessible via {@link Thread#getName} of * <em>pool-N-thread-M</em>, where <em>N</em> is the sequence * number of this factory, and <em>M</em> is the sequence number * of the thread created by this factory. * * @return a thread factory */ // 默认线程工厂,创建默认线程优先级的非守护线程 public static ThreadFactory defaultThreadFactory() { return new DefaultThreadFactory(); } /** * Returns a thread factory used to create new threads that * have the same permissions as the current thread. * This factory creates threads with the same settings as {@link * Executors#defaultThreadFactory}, additionally setting the * AccessControlContext and contextClassLoader of new threads to * b
null
null
null
null
null
null
github_plus_top10pct_by_avg
e the same as the thread invoking this * {@code privilegedThreadFactory} method. A new * {@code privilegedThreadFactory} can be created within an * {@link AccessController#doPrivileged AccessController.doPrivileged} * action setting the current thread's access control context to * create threads with the selected permission settings holding * within that action. * * <p>Note that while tasks running within such threads will have * the same access control and class loader settings as the * current thread, they need not have the same {@link * java.lang.ThreadLocal} or {@link * java.lang.InheritableThreadLocal} values. If necessary, * particular values of thread locals can be set or reset before * any task runs in {@link ThreadPoolExecutor} subclasses using * {@link ThreadPoolExecutor#beforeExecute(Thread, Runnable)}. * Also, if it is necessary to initialize worker threads to have * the same InheritableThreadLocal settings as some other * designated thread, you can create a custom ThreadFactory in * which that thread waits for and services requests to create * others that will inherit its values. * * @return a thread factory * * @throws AccessControlException if the current access control * context does not have permission to both get and set context * class loader */ // 特权线程工厂 public static ThreadFactory privilegedThreadFactory() { return new PrivilegedThreadFactory(); } /*▲ 线程工厂 ████████████████████████████████████████████████████████████████████████████████┛ */ /* * 以下定义了各种类型的: * * - 任务执行框架 * - 任务 * - 线程工厂
null
null
null
null
null
null
github_plus_top10pct_by_avg
*/ /** * A wrapper class that exposes only the ExecutorService methods of an ExecutorService implementation. */ // 【任务执行框架代理】,限制只能执行ExecutorService接口内的方法 private static class DelegatedExecutorService implements ExecutorService { private final ExecutorService e; DelegatedExecutorService(ExecutorService executor) { e = executor; } public void execute(Runnable command) { try { e.execute(command); } finally { reachabilityFence(this); } } public void shutdown() { e.shutdown(); } public List<Runnable> shutdownNow() { try { return e.shutdownNow(); } finally { reachabilityFence(this); } } public boolean isShutdown() { try { return e.isShutdown(); } finally { reachabilityFence(this); } } public boolean isTerminated() { try { return e.isTerminated(); } finally { reachabilityFence(this); } } public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { try { return e.awaitTermination(timeout, unit); } finally { reachabilityFence(this); } } public Future<?> submit(Runnable task) { try { return e.submit(task); } finally { reachabilityFence(this); } } public <T> Future<T> submit(Callable<T> task) { try { return e.submit(task); } finally { reachabilityFence(this); } } public <T> Future<T>
null
null
null
null
null
null
github_plus_top10pct_by_avg
submit(Runnable task, T result) { try { return e.submit(task, result); } finally { reachabilityFence(this); } } public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException { try { return e.invokeAll(tasks); } finally { reachabilityFence(this); } } public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { try { return e.invokeAll(tasks, timeout, unit); } finally { reachabilityFence(this); } } public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException { try { return e.invokeAny(tasks); } finally { reachabilityFence(this); } } public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { try { return e.invokeAny(tasks, timeout, unit); } finally { reachabilityFence(this); } } } /** * A wrapper class that exposes only the ScheduledExecutorService * methods of a ScheduledExecutorService implementation. */ // 【定时任务执行框架代理】,限制只能执行ExecutorService接口与ScheduledExecutorService接口内的方法 private static class DelegatedScheduledExecutorService extends DelegatedExecutorService implements ScheduledExecutorService { private final ScheduledExecutorService e; DelegatedScheduledExecutorService(ScheduledExecutorService executor) { super(executor); e = executor; } pu
null
null
null
null
null
null
github_plus_top10pct_by_avg
blic ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { return e.schedule(command, delay, unit); } public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { return e.schedule(callable, delay, unit); } public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { return e.scheduleAtFixedRate(command, initialDelay, period, unit); } public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { return e.scheduleWithFixedDelay(command, initialDelay, delay, unit); } } // 【Finalizable任务执行框架代理】 private static class FinalizableDelegatedExecutorService extends DelegatedExecutorService { FinalizableDelegatedExecutorService(ExecutorService executor) { super(executor); } @SuppressWarnings("deprecation") protected void finalize() { super.shutdown(); } } /** * A callable that runs given task and returns given result. */ // 包装Runnable任务 private static final class RunnableAdapter<T> implements Callable<T> { private final Runnable task; private final T result; RunnableAdapter(Runnable task, T result) { this.task = task; this.result = result; } public T call() { task.run(); return result; } public String toString() { return super.toString() + "[Wrapped task = " + task + "]"; } } /** * A callable that runs under established access control settings. */ // 包装Callable任务,使用上下文访问权限控制器 private static final class PrivilegedCallable<T> implements Callable<T> { final Callable<T> task;
null
null
null
null
null
null
github_plus_top10pct_by_avg
final AccessControlContext acc; PrivilegedCallable(Callable<T> task) { this.task = task; this.acc = AccessController.getContext(); } public T call() throws Exception { try { return AccessController.doPrivileged(new PrivilegedExceptionAction<T>() { public T run() throws Exception { return task.call(); } }, acc); } catch(PrivilegedActionException e) { throw e.getException(); } } public String toString() { return super.toString() + "[Wrapped task = " + task + "]"; } } /** * A callable that runs under established access control settings and * current ClassLoader. */ // 包装Callable任务,使用上下文访问权限控制器和当前线程的类加载器 private static final class PrivilegedCallableUsingCurrentClassLoader<T> implements Callable<T> { final Callable<T> task; final AccessControlContext acc; final ClassLoader ccl; PrivilegedCallableUsingCurrentClassLoader(Callable<T> task) { SecurityManager sm = System.getSecurityManager(); if(sm != null) { // Calls to getContextClassLoader from this class // never trigger a security check, but we check // whether our callers have this permission anyways. sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); // Whether setContextClassLoader turns out to be necessary // or not, we fail fast if permission is not available. sm.checkPermission(new RuntimePermission("setContextClassLoader")); } this.task = task; this.acc = AccessController.getContext(); this.ccl = Thread.currentThread().getContextClassLoader(); }
null
null
null
null
null
null
github_plus_top10pct_by_avg
public T call() throws Exception { try { return AccessController.doPrivileged(new PrivilegedExceptionAction<T>() { public T run() throws Exception { Thread t = Thread.currentThread(); ClassLoader cl = t.getContextClassLoader(); if(ccl == cl) { return task.call(); } else { t.setContextClassLoader(ccl); try { return task.call(); } finally { t.setContextClassLoader(cl); } } } }, acc); } catch(PrivilegedActionException e) { throw e.getException(); } } public String toString() { return super.toString() + "[Wrapped task = " + task + "]"; } } /** * The default thread factory. */ // 默认线程工厂,创建默认线程优先级的非守护线程 private static class DefaultThreadFactory implements ThreadFactory { private static final AtomicInteger poolNumber = new AtomicInteger(1); private final AtomicInteger threadNumber = new AtomicInteger(1); private final String namePrefix; private final ThreadGroup group; DefaultThreadFactory() { SecurityManager s = System.getSecurityManager(); group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); namePrefix = "pool-" + poolNumber.getAndIncrement() + "-thread-"; } public Thread newThread(Runnable r) { Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0); if(t.isDaemon()) { t.setDaemon(false); } if(t.get
null
null
null
null
null
null
github_plus_top10pct_by_avg
Priority() != Thread.NORM_PRIORITY) { t.setPriority(Thread.NORM_PRIORITY); } return t; } } /** * Thread factory capturing access control context and class loader. */ // 特权线程工厂 private static class PrivilegedThreadFactory extends DefaultThreadFactory { final AccessControlContext acc; final ClassLoader ccl; PrivilegedThreadFactory() { super(); SecurityManager sm = System.getSecurityManager(); if(sm != null) { /* * Calls to getContextClassLoader from this class never trigger a security check, * but we check whether our callers have this permission anyways. */ sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); // Fail fast sm.checkPermission(new RuntimePermission("setContextClassLoader")); } this.acc = AccessController.getContext(); this.ccl = Thread.currentThread().getContextClassLoader(); } public Thread newThread(final Runnable r) { return super.newThread(new Runnable() { public void run() { AccessController.doPrivileged(new PrivilegedAction<>() { public Void run() { Thread.currentThread().setContextClassLoader(ccl); r.run(); return null; } }, acc); } }); } } } files { 0 1 1 test_job test_namespace strings1.xml 0 1 2 6 test_job test_namespace strings2.xml 0 2 3 13 test_job test_namespace strings3.xml 0 3 4 20 test_job test_namespace strings4.xml 0 4 5 28 test_job test_namespace strings5.xml 0 } # deprecated /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE
null
null
null
null
null
null
github_plus_top10pct_by_avg
HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * * (C) Copyright IBM Corp. 1999 All Rights Reserved. * Copyright 1997 The Open Group Research Institute. All rights reserved. */ package sun.security.krb5.internal; import sun.security.krb5.Config; import sun.security.krb5.KrbException; import sun.security.krb5.Asn1Exception; import sun.security.krb5.internal.util.KerberosFlags; import sun.security.util.*; import java.io.IOException; /** * Implements the ASN.1 KDCOptions type. * * <xmp> * KDCOptions ::= KerberosFlags * -- reserved(0), * -- forwardable(1), * -- forwarded(2), * -- proxiable(3), * -- proxy(4), * -- allow-postdate(5), * -- postdated(6), * -- unused7(7), * -- renewable(8), * -- unused9(9), * -- unused10(10), * -- opt-hardware-auth(11), * -- unused12(12), * -- unused13(13), * -- 15 is reserved for canonicalize * -- unused15(15), * -- 26 was unused in 1510 * -- disable-transited-check
null
null
null
null
null
null
github_plus_top10pct_by_avg
(26), * -- renewable-ok(27), * -- enc-tkt-in-skey(28), * -- renew(30), * -- validate(31) * * KerberosFlags ::= BIT STRING (SIZE (32..MAX)) * -- minimum number of bits shall be sent, * -- but no fewer than 32 * * </xmp> * * <p> * This definition reflects the Network Working Group RFC 4120 * specification available at * <a href="http://www.ietf.org/rfc/rfc4120.txt"> * http://www.ietf.org/rfc/rfc4120.txt</a>. * * <p> * This class appears as data field in the initial request(KRB_AS_REQ) * or subsequent request(KRB_TGS_REQ) to the KDC and indicates the flags * that the client wants to set on the tickets. * * The optional bits are: * <UL> * <LI>KDCOptions.RESERVED * <LI>KDCOptions.FORWARDABLE * <LI>KDCOptions.FORWARDED * <LI>KDCOptions.PROXIABLE * <LI>KDCOptions.PROXY * <LI>KDCOptions.ALLOW_POSTDATE * <LI>KDCOptions.POSTDATED * <LI>KDCOptions.RENEWABLE * <LI>KDCOptions.RENEWABLE_OK * <LI>KDCOptions.ENC_TKT_IN_SKEY * <LI>KDCOptions.RENEW * <LI>KDCOptions.VALIDATE * </UL> * <p> Various checks must be made before honoring an option. The restrictions * on the use of some options are as follows: * <ol> * <li> FORWARDABLE, FORWARDED, PROXIABLE, RENEWABLE options may be set in * subsequent request only if the ticket_granting ticket on which it is based has * the same options (FORWARDABLE, FORWARDED, PROXIABLE, RENEWABLE) set. * <li> ALLOW_POSTDATE may be set in subsequent request only if the * ticket-granting ticket on which it is based also has its MAY_POSTDATE flag set. * <li> POSTDATED may be set in subsequent request only if the * ticket-granting ticket on which it is based also has its MAY_POSTDATE flag set. * <li> RENEWABLE or RENEW may be set in subsequent request only if the * ticket-granting ticket on which it is based also has its RENEWABLE flag set. * <li> POXY may be set in subsequent request only if the ticket-granting ticket * on which it is based also has its PROXIABLE flag set, and th
null
null
null
null
null
null
github_plus_top10pct_by_avg
e address(es) of * the host from which the resulting ticket is to be valid should be included * in the addresses field of the request. * <li>FORWARDED, PROXY, ENC_TKT_IN_SKEY, RENEW, VALIDATE are used only in * subsequent requests. * </ol><p> */ public class KDCOptions extends KerberosFlags { private static final int KDC_OPT_PROXIABLE = 0x10000000; private static final int KDC_OPT_RENEWABLE_OK = 0x00000010; private static final int KDC_OPT_FORWARDABLE = 0x40000000; // KDC Options public static final int RESERVED = 0; public static final int FORWARDABLE = 1; public static final int FORWARDED = 2; public static final int PROXIABLE = 3; public static final int PROXY = 4; public static final int ALLOW_POSTDATE = 5; public static final int POSTDATED = 6; public static final int UNUSED7 = 7; public static final int RENEWABLE = 8; public static final int UNUSED9 = 9; public static final int UNUSED10 = 10; public static final int UNUSED11 = 11; public static final int CNAME_IN_ADDL_TKT = 14; public static final int CANONICALIZE = 15; public static final int RENEWABLE_OK = 27; public static final int ENC_TKT_IN_SKEY = 28; public static final int RENEW = 30; public static final int VALIDATE = 31; private static final String[] names = { "RESERVED", //0 "FORWARDABLE", //1; "FORWARDED", //2; "PROXIABLE", //3; "PROXY", //4; "ALLOW_POSTDATE", //5; "POSTDATED", //6; "UNUSED7", //7; "RENEWABLE", //8; "UNUSED9", //9; "UNUSED10", //10; "UNUSED11", //11; null,null, "CNAME_IN_ADDL_TKT",//14; "CANONICALIZE", //15; null,null,null,null,null,null,null,null,null,null,null, "RENEWABLE_OK", //27; "ENC_TKT_
null
null
null
null
null
null
github_plus_top10pct_by_avg
IN_SKEY", //28; null, "RENEW", //30; "VALIDATE", //31; }; private boolean DEBUG = Krb5.DEBUG; public static KDCOptions with(int... flags) { KDCOptions options = new KDCOptions(); for (int flag: flags) { options.set(flag, true); } return options; } public KDCOptions() { super(Krb5.KDC_OPTS_MAX + 1); setDefault(); } public KDCOptions(int size, byte[] data) throws Asn1Exception { super(size, data); if ((size > data.length * BITS_PER_UNIT) || (size > Krb5.KDC_OPTS_MAX + 1)) throw new Asn1Exception(Krb5.BITSTRING_BAD_LENGTH); } /** * Constructs a KDCOptions from the specified bit settings. * * @param data the bits to be set for the KDCOptions. * @exception Asn1Exception if an error occurs while decoding an ASN1 * encoded data. * */ public KDCOptions(boolean[] data) throws Asn1Exception { super(data); if (data.length > Krb5.KDC_OPTS_MAX + 1) { throw new Asn1Exception(Krb5.BITSTRING_BAD_LENGTH); } } public KDCOptions(DerValue encoding) throws Asn1Exception, IOException { this(encoding.getUnalignedBitString(true).toBooleanArray()); } /** * Constructs a KDCOptions from the passed bit settings. * * @param options the bits to be set for the KDCOptions. * */ public KDCOptions(byte[] options) { super(options.length * BITS_PER_UNIT, options); } /** * Parse (unmarshal) a KDCOptions from a DER input stream. This form * parsing might be used when expanding a value which is part of * a constructed sequence and uses explicitly tagged type. * * @param data the Der input stream value, which contains one or more * marshaled value. * @param explicitTag tag number. * @param optional indicate if this data field is optional * @return an instance of KDCOptions. * @exception A
null
null
null
null
null
null
github_plus_top10pct_by_avg
sn1Exception if an error occurs while decoding an ASN1 encoded data. * @exception IOException if an I/O error occurs while reading encoded data. * */ public static KDCOptions parse(DerInputStream data, byte explicitTag, boolean optional) throws Asn1Exception, IOException { if ((optional) && (((byte)data.peekByte() & (byte)0x1F) != explicitTag)) return null; DerValue der = data.getDerValue(); if (explicitTag != (der.getTag() & (byte)0x1F)) { throw new Asn1Exception(Krb5.ASN1_BAD_ID); } else { DerValue subDer = der.getData().getDerValue(); return new KDCOptions(subDer); } } /** * Sets the value(true/false) for one of the <code>KDCOptions</code>. * * @param option an option bit. * @param value true if the option is selected, false if the option is not selected. * @exception ArrayIndexOutOfBoundsException if array index out of bound occurs. * @see sun.security.krb5.internal.Krb5 */ public void set(int option, boolean value) throws ArrayIndexOutOfBoundsException { super.set(option, value); } /** * Gets the value(true/false) for one of the <code>KDCOptions</code>. * * @param option an option bit. * @return value true if the option is selected, false if the option is not selected. * @exception ArrayIndexOutOfBoundsException if array index out of bound occurs. * @see sun.security.krb5.internal.Krb5 */ public boolean get(int option) throws ArrayIndexOutOfBoundsException { return super.get(option); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("KDCOptions: "); for (int i=0; i<Krb5.KDC_OPTS_MAX+1; i++) { if (get(i)) { if (names[i] != null) { sb.append(names[i]).append(","); } else { sb.append(i).append(","); } } }
null
null
null
null
null
null
github_plus_top10pct_by_avg
return sb.toString(); } private void setDefault() { try { Config config = Config.getInstance(); // If key not present, returns Integer.MIN_VALUE, which is // almost all zero. int options = config.getIntValue("libdefaults", "kdc_default_options"); if ((options & KDC_OPT_RENEWABLE_OK) == KDC_OPT_RENEWABLE_OK) { set(RENEWABLE_OK, true); } else { if (config.getBooleanValue("libdefaults", "renewable")) { set(RENEWABLE_OK, true); } } if ((options & KDC_OPT_PROXIABLE) == KDC_OPT_PROXIABLE) { set(PROXIABLE, true); } else { if (config.getBooleanValue("libdefaults", "proxiable")) { set(PROXIABLE, true); } } if ((options & KDC_OPT_FORWARDABLE) == KDC_OPT_FORWARDABLE) { set(FORWARDABLE, true); } else { if (config.getBooleanValue("libdefaults", "forwardable")) { set(FORWARDABLE, true); } } } catch (KrbException e) { if (DEBUG) { System.out.println("Exception in getting default values for " + "KDC Options from the configuration "); e.printStackTrace(); } } } } /* * Copyright 2016 WebAssembly Community Group participants * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing per
null
null
null
null
null
null
github_plus_top10pct_by_avg
missions and * limitations under the License. */ #include "src/binary-reader-opcnt.h" #include <cassert> #include <cinttypes> #include <cstdarg> #include <cstdint> #include <cstdio> #include "src/binary-reader-nop.h" #include "src/common.h" #include "src/literal.h" #include "src/stream.h" namespace wabt { OpcodeInfo::OpcodeInfo(Opcode opcode, Kind kind) : opcode_(opcode), kind_(kind) {} template <typename T> OpcodeInfo::OpcodeInfo(Opcode opcode, Kind kind, T* data, size_t count) : OpcodeInfo(opcode, kind) { if (count > 0) { data_.resize(sizeof(T) * count); memcpy(data_.data(), data, data_.size()); } } template <typename T> OpcodeInfo::OpcodeInfo(Opcode opcode, Kind kind, T* data, size_t count, T extra) : OpcodeInfo(opcode, kind, data, count) { data_.resize(data_.size() + sizeof(T)); memcpy(data_.data() + data_.size() - sizeof(T), &extra, sizeof(T)); } template <typename T> std::pair<const T*, size_t> OpcodeInfo::GetDataArray() const { if (data_.empty()) { return std::pair<const T*, size_t>(nullptr, 0); } assert(data_.size() % sizeof(T) == 0); return std::make_pair(reinterpret_cast<const T*>(data_.data()), data_.size() / sizeof(T)); } template <typename T> const T* OpcodeInfo::GetData(size_t expected_size) const { auto pair = GetDataArray<T>(); assert(pair.second == expected_size); return pair.first; } template <typename T, typename F> void OpcodeInfo::WriteArray(Stream& stream, F&& write_func) { auto pair = GetDataArray<T>(); for (size_t i = 0; i < pair.second; ++i) { // Write an initial space (to separate from the opcode name) first, then // comma-separate. stream.Writef("%s", i == 0 ? " " : ", "); write_func(pair.first[i]); } } void OpcodeInfo::Write(Stream& stream) { stream.Writef("%s", opcode_.GetName()); switch (kind_) { case Kind::Bare: break; case Kind::Uint32: stream.Writef(" %u (0x%x)", *GetData<uint32_t>(), *GetData<uint32_t>()); break; case Kind::Uint64: s
null
null
null
null
null
null
github_plus_top10pct_by_avg
tream.Writef(" %" PRIu64 " (0x%" PRIx64 ")", *GetData<uint64_t>(), *GetData<uint64_t>()); break; case Kind::Index: stream.Writef(" %" PRIindex, *GetData<Index>()); break; case Kind::Float32: { stream.Writef(" %g", *GetData<float>()); char buffer[WABT_MAX_FLOAT_HEX + 1]; WriteFloatHex(buffer, sizeof(buffer), *GetData<uint32_t>()); stream.Writef(" (%s)", buffer); break; } case Kind::Float64: { stream.Writef(" %g", *GetData<double>()); char buffer[WABT_MAX_DOUBLE_HEX + 1]; WriteDoubleHex(buffer, sizeof(buffer), *GetData<uint64_t>()); stream.Writef(" (%s)", buffer); break; } case Kind::Uint32Uint32: WriteArray<uint32_t>( stream, [&stream](uint32_t value) { stream.Writef("%u", value); }); break; case Kind::BlockSig: { auto type = *GetData<Type>(); if (IsTypeIndex(type)) { stream.Writef(" type:%d", static_cast<int>(type)); } else if (type != Type::Void) { stream.Writef(" %s", GetTypeName(type)); } break; } case Kind::BrTable: { WriteArray<Index>(stream, [&stream](Index index) { stream.Writef("%" PRIindex, index); }); break; } } } bool operator==(const OpcodeInfo& lhs, const OpcodeInfo& rhs) { return lhs.opcode_ == rhs.opcode_ && lhs.kind_ == rhs.kind_ && lhs.data_ == rhs.data_; } bool operator!=(const OpcodeInfo& lhs, const OpcodeInfo& rhs) { return !(lhs == rhs); } bool operator<(const OpcodeInfo& lhs, const OpcodeInfo& rhs) { if (lhs.opcode_ < rhs.opcode_) { return true; } if (lhs.opcode_ > rhs.opcode_) { return false; } if (lhs.kind_ < rhs.kind_) { return true; } if (lhs.kind_ > rhs.kind_) { return false; } if (lhs.data_ < rhs.data_) { return true; } if (lhs.data_ > rhs.data_) { return false; } return false; } bool operator<=(const OpcodeInfo& lhs, const OpcodeInfo& rhs) { return lhs < rhs || lhs == rhs; } bool
null
null
null
null
null
null
github_plus_top10pct_by_avg
operator>(const OpcodeInfo& lhs, const OpcodeInfo& rhs) { return !(lhs <= rhs); } bool operator>=(const OpcodeInfo& lhs, const OpcodeInfo& rhs) { return !(lhs < rhs); } namespace { class BinaryReaderOpcnt : public BinaryReaderNop { public: explicit BinaryReaderOpcnt(OpcodeInfoCounts* counts); Result OnOpcode(Opcode opcode) override; Result OnOpcodeBare() override; Result OnOpcodeUint32(uint32_t value) override; Result OnOpcodeIndex(Index value) override; Result OnOpcodeUint32Uint32(uint32_t value, uint32_t value2) override; Result OnOpcodeUint64(uint64_t value) override; Result OnOpcodeF32(uint32_t value) override; Result OnOpcodeF64(uint64_t value) override; Result OnOpcodeBlockSig(Type sig_type) override; Result OnBrTableExpr(Index num_targets, Index* target_depths, Index default_target_depth) override; Result OnEndExpr() override; Result OnEndFunc() override; private: template <typename... Args> Result Emplace(Args&&... args); OpcodeInfoCounts* opcode_counts_; Opcode current_opcode_; }; template <typename... Args> Result BinaryReaderOpcnt::Emplace(Args&&... args) { auto pair = opcode_counts_->emplace( std::piecewise_construct, std::make_tuple(std::forward<Args>(args)...), std::make_tuple(0)); auto& count = pair.first->second; count++; return Result::Ok; } BinaryReaderOpcnt::BinaryReaderOpcnt(OpcodeInfoCounts* counts) : opcode_counts_(counts) {} Result BinaryReaderOpcnt::OnOpcode(Opcode opcode) { current_opcode_ = opcode; return Result::Ok; } Result BinaryReaderOpcnt::OnOpcodeBare() { return Emplace(current_opcode_, OpcodeInfo::Kind::Bare); } Result BinaryReaderOpcnt::OnOpcodeUint32(uint32_t value) { return Emplace(current_opcode_, OpcodeInfo::Kind::Uint32, &value); } Result BinaryReaderOpcnt::OnOpcodeIndex(Index value) { return Emplace(current_opcode_, OpcodeInfo::Kind::Index, &value); } Result BinaryReaderOpcnt::OnOpcodeUint32Uint32(uint32_t value0,
null
null
null
null
null
null
github_plus_top10pct_by_avg
uint32_t value1) { uint32_t array[2] = {value0, value1}; return Emplace(current_opcode_, OpcodeInfo::Kind::Uint32Uint32, array, 2); } Result BinaryReaderOpcnt::OnOpcodeUint64(uint64_t value) { return Emplace(current_opcode_, OpcodeInfo::Kind::Uint64, &value); } Result BinaryReaderOpcnt::OnOpcodeF32(uint32_t value) { return Emplace(current_opcode_, OpcodeInfo::Kind::Float32, &value); } Result BinaryReaderOpcnt::OnOpcodeF64(uint64_t value) { return Emplace(current_opcode_, OpcodeInfo::Kind::Float64, &value); } Result BinaryReaderOpcnt::OnOpcodeBlockSig(Type sig_type) { return Emplace(current_opcode_, OpcodeInfo::Kind::BlockSig, &sig_type); } Result BinaryReaderOpcnt::OnBrTableExpr(Index num_targets, Index* target_depths, Index default_target_depth) { return Emplace(current_opcode_, OpcodeInfo::Kind::BrTable, target_depths, num_targets, default_target_depth); } Result BinaryReaderOpcnt::OnEndExpr() { return Emplace(Opcode::End, OpcodeInfo::Kind::Bare); } Result BinaryReaderOpcnt::OnEndFunc() { return Emplace(Opcode::End, OpcodeInfo::Kind::Bare); } } // end anonymous namespace Result ReadBinaryOpcnt(const void* data, size_t size, const ReadBinaryOptions& options, OpcodeInfoCounts* counts) { BinaryReaderOpcnt reader(counts); return ReadBinary(data, size, &reader, options); } } // namespace wabt /** * Copyright (C) 2014 MongoDB Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more detail
null
null
null
null
null
null
github_plus_top10pct_by_avg
s. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #include "mongo/platform/basic.h" #include "mongo/db/repl/repl_set_heartbeat_response.h" #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" namespace mongo { namespace repl { namespace { using std::unique_ptr; bool stringContains(const std::string& haystack, const std::string& needle) { return haystack.find(needle) != std::string::npos; } TEST(ReplSetHeartbeatResponse, DefaultConstructThenSlowlyBuildToFullObj) { int fieldsSet = 2; ReplSetHeartbeatResponse hbResponse; ReplSetHeartbeatResponse hbResponseObjRoundTripChecker; ASSERT_EQUALS(false, hbResponse.hasState()); ASSERT_EQUALS(false, hbResponse.hasElectionTime()); ASSERT_EQUALS(false, hbResponse.hasIsElectable()); ASSERT_EQUALS(false, hbResponse.hasTime()); ASSERT_EQUALS(false, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(false, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(false, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_
null
null
null
null
null
null
github_plus_top10pct_by_avg
EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("", hbResponse.getReplicaSetName()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(-1, hbResponse.getConfigVersion()); BSONObj hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); Status initializeResult = Status::OK(); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toString()); // set version hbResponse.setConfigVersion(1); ++fieldsSet; ASSERT_EQUALS(false, hbResponse.hasState()); ASSERT_EQUALS(false, hbResponse.hasElectionTime()); ASSERT_EQUALS(false, hbResponse.hasIsElectable()); ASSERT_EQUALS(false, hbResponse.hasTime()); ASSERT_EQUALS(false, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(false, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(false, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("", hbResponse.getReplicaSetName()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toString()); // set setname hbResponse.setSetName("rs0"); ++fieldsSet; ASSERT_EQUALS(false, hbResponse.hasState()); ASSERT_EQUALS(false, hbResponse.hasElectionTime()); ASSERT_EQUALS(false, hbResponse.hasIsElectable());
null
null
null
null
null
null
github_plus_top10pct_by_avg
ASSERT_EQUALS(false, hbResponse.hasTime()); ASSERT_EQUALS(false, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(false, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(false, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toString()); // set electionTime hbResponse.setElectionTime(Timestamp(10, 0)); ++fieldsSet; ASSERT_EQUALS(false, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(false, hbResponse.hasIsElectable()); ASSERT_EQUALS(false, hbResponse.hasTime()); ASSERT_EQUALS(false, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(false, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(false, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); hbResponseObj = hbResponse.toBSON(false); ASSER
null
null
null
null
null
null
github_plus_top10pct_by_avg
T_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toString()); // set durableOpTime hbResponse.setDurableOpTime(OpTime(Timestamp(10), 0)); ++fieldsSet; ASSERT_EQUALS(false, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(false, hbResponse.hasIsElectable()); ASSERT_EQUALS(false, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(false, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(false, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(St
null
null
null
null
null
null
github_plus_top10pct_by_avg
atus::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set appliedOpTime hbResponse.setAppliedOpTime(OpTime(Timestamp(50), 0)); ++fieldsSet; ASSERT_EQUALS(false, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(false, hbResponse.hasIsElectable()); ASSERT_EQUALS(false, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(false, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 50), hbResponseObj["opTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set time hbResponse.setTime(Seconds(10)); ++fieldsSet; ASSERT_EQUALS(false,
null
null
null
null
null
null
github_plus_top10pct_by_avg
hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(false, hbResponse.hasIsElectable()); ASSERT_EQUALS(true, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(false, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); ASSERT_EQUALS(Seconds(10), hbResponse.getTime()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 50), hbResponseObj["opTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); ASSERT_EQUALS(10, hbResponseObj["time"].numberLong()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set electable hbResponse.setElectable(true); ++fieldsSet; ASSERT_EQUALS(false, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(true, hbResponse.hasIsElectable()); ASSERT_
null
null
null
null
null
null
github_plus_top10pct_by_avg
EQUALS(true, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(false, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); ASSERT_EQUALS(Seconds(10), hbResponse.getTime()); ASSERT_EQUALS(true, hbResponse.isElectable()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 50), hbResponseObj["opTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); ASSERT_EQUALS(10, hbResponseObj["time"].numberLong()); ASSERT_EQUALS(true, hbResponseObj["e"].trueValue()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set config ReplSetConfig config; hbResponse.setConfig(config); ++fieldsSet; ASSERT_EQUALS(false, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(true, hbResponse.hasIsElectable()); ASSERT_EQUALS(true, hb
null
null
null
null
null
null
github_plus_top10pct_by_avg
Response.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(true, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); ASSERT_EQUALS(Seconds(10), hbResponse.getTime()); ASSERT_EQUALS(true, hbResponse.isElectable()); ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 50), hbResponseObj["opTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); ASSERT_EQUALS(10, hbResponseObj["time"].numberLong()); ASSERT_EQUALS(true, hbResponseObj["e"].trueValue()); ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set state hbResponse.setState(MemberState(MemberState::RS_SECONDARY)); ++fieldsSet; ASSERT_EQUAL
null
null
null
null
null
null
github_plus_top10pct_by_avg
S(true, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(true, hbResponse.hasIsElectable()); ASSERT_EQUALS(true, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(true, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(false, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS(MemberState(MemberState::RS_SECONDARY).toString(), hbResponse.getState().toString()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); ASSERT_EQUALS(Seconds(10), hbResponse.getTime()); ASSERT_EQUALS(true, hbResponse.isElectable()); ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 50), hbResponseObj["opTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); ASSERT_EQUALS(10, hbResponseObj["time"].numberLong()); ASSERT_EQUALS(true, hbResponseObj["e"].trueValue()); ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString()); ASSERT_EQUALS(2, hbResponseObj["state"].numberLong());
null
null
null
null
null
null
github_plus_top10pct_by_avg
initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set stateDisagreement hbResponse.noteStateDisagreement(); ++fieldsSet; ASSERT_EQUALS(true, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(true, hbResponse.hasIsElectable()); ASSERT_EQUALS(true, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(true, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(false, hbResponse.isReplSet()); ASSERT_EQUALS(true, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS(MemberState(MemberState::RS_SECONDARY).toString(), hbResponse.getState().toString()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); ASSERT_EQUALS(Seconds(10), hbResponse.getTime()); ASSERT_EQUALS(true, hbResponse.isElectable()); ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 50), hbResponseObj["opTime"].timestamp()); ASSERT_EQUALS(Tim
null
null
null
null
null
null
github_plus_top10pct_by_avg
estamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); ASSERT_EQUALS(10, hbResponseObj["time"].numberLong()); ASSERT_EQUALS(true, hbResponseObj["e"].trueValue()); ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString()); ASSERT_EQUALS(2, hbResponseObj["state"].numberLong()); ASSERT_EQUALS(false, hbResponseObj["mismatch"].trueValue()); ASSERT_EQUALS(true, hbResponseObj["stateDisagreement"].trueValue()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set replSet hbResponse.noteReplSet(); ++fieldsSet; ASSERT_EQUALS(true, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(true, hbResponse.hasIsElectable()); ASSERT_EQUALS(true, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(true, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(true, hbResponse.isReplSet()); ASSERT_EQUALS(true, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS(MemberState(MemberState::RS_SECONDARY).toString(), hbResponse.getState().toString()); ASSERT_EQUALS("", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort(), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); ASSERT_EQUALS(Seconds(10), hbResponse.getTime()); ASSERT_EQUALS(true, hbResponse.isElectable()); ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toS
null
null
null
null
null
null
github_plus_top10pct_by_avg
tring()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 50), hbResponseObj["opTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); ASSERT_EQUALS(10, hbResponseObj["time"].numberLong()); ASSERT_EQUALS(true, hbResponseObj["e"].trueValue()); ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString()); ASSERT_EQUALS(2, hbResponseObj["state"].numberLong()); ASSERT_EQUALS(false, hbResponseObj["mismatch"].trueValue()); ASSERT_EQUALS(true, hbResponseObj["stateDisagreement"].trueValue()); ASSERT_EQUALS(true, hbResponseObj["rs"].trueValue()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set syncingTo hbResponse.setSyncingTo(HostAndPort("syncTarget")); ++fieldsSet; ASSERT_EQUALS(true, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(true, hbResponse.hasIsElectable()); ASSERT_EQUALS(true, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(true, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(true, hbResponse.isReplSet()); ASSERT_EQUALS(true, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS(MemberState(MemberState::RS_SECONDARY).toString(), hbResponse.getState().toString()); ASSERT_EQUALS("", hbResponse.g
null
null
null
null
null
null
github_plus_top10pct_by_avg
etHbMsg()); ASSERT_EQUALS(HostAndPort("syncTarget"), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); ASSERT_EQUALS(Seconds(10), hbResponse.getTime()); ASSERT_EQUALS(true, hbResponse.isElectable()); ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 50), hbResponseObj["opTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); ASSERT_EQUALS(10, hbResponseObj["time"].numberLong()); ASSERT_EQUALS(true, hbResponseObj["e"].trueValue()); ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString()); ASSERT_EQUALS(2, hbResponseObj["state"].numberLong()); ASSERT_EQUALS(false, hbResponseObj["mismatch"].trueValue()); ASSERT_EQUALS(true, hbResponseObj["stateDisagreement"].trueValue()); ASSERT_EQUALS(true, hbResponseObj["rs"].trueValue()); ASSERT_EQUALS("syncTarget:27017", hbResponseObj["syncingTo"].String()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set hbmsg hbResponse.setHbMsg("lub dub"); ASSERT_EQUALS(true, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(true, hbResponse.hasIsElectable());
null
null
null
null
null
null
github_plus_top10pct_by_avg
ASSERT_EQUALS(true, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(true, hbResponse.hasConfig()); ASSERT_EQUALS(false, hbResponse.isMismatched()); ASSERT_EQUALS(true, hbResponse.isReplSet()); ASSERT_EQUALS(true, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS(MemberState(MemberState::RS_SECONDARY).toString(), hbResponse.getState().toString()); ASSERT_EQUALS("lub dub", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort("syncTarget"), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); ASSERT_EQUALS(Seconds(10), hbResponse.getTime()); ASSERT_EQUALS(true, hbResponse.isElectable()); ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(fieldsSet, hbResponseObj.nFields()); ASSERT_EQUALS("rs0", hbResponseObj["set"].String()); ASSERT_EQUALS("lub dub", hbResponseObj["hbmsg"].String()); ASSERT_EQUALS(1, hbResponseObj["v"].Number()); ASSERT_EQUALS(Timestamp(10, 0), hbResponseObj["electionTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 50), hbResponseObj["opTime"].timestamp()); ASSERT_EQUALS(Timestamp(0, 10), hbResponseObj["durableOpTime"]["ts"].timestamp()); ASSERT_EQUALS(10, hbResponseObj["time"].numberLong()); ASSERT_EQUALS(true, hbResponseObj["e"].trueValue()); ASSERT_EQUALS(config.toBSON().toString(), hbResponseObj["config"].Obj().toString()); ASSERT_EQUALS(2, hbResponseObj["state"].numberLong()); ASSERT_EQUALS(false, hbResponseObj["mismatch"].trueValue()); ASSERT_EQUALS(true, hbResponseObj["stateDisagreemen
null
null
null
null
null
null
github_plus_top10pct_by_avg
t"].trueValue()); ASSERT_EQUALS(true, hbResponseObj["rs"].trueValue()); ASSERT_EQUALS("syncTarget:27017", hbResponseObj["syncingTo"].String()); initializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(hbResponseObj.toString(), hbResponseObjRoundTripChecker.toBSON(false).toString()); // set mismatched hbResponse.noteMismatched(); ASSERT_EQUALS(true, hbResponse.hasState()); ASSERT_EQUALS(true, hbResponse.hasElectionTime()); ASSERT_EQUALS(true, hbResponse.hasIsElectable()); ASSERT_EQUALS(true, hbResponse.hasTime()); ASSERT_EQUALS(true, hbResponse.hasDurableOpTime()); ASSERT_EQUALS(true, hbResponse.hasAppliedOpTime()); ASSERT_EQUALS(true, hbResponse.hasConfig()); ASSERT_EQUALS(true, hbResponse.isMismatched()); ASSERT_EQUALS(true, hbResponse.isReplSet()); ASSERT_EQUALS(true, hbResponse.isStateDisagreement()); ASSERT_EQUALS("rs0", hbResponse.getReplicaSetName()); ASSERT_EQUALS(MemberState(MemberState::RS_SECONDARY).toString(), hbResponse.getState().toString()); ASSERT_EQUALS("lub dub", hbResponse.getHbMsg()); ASSERT_EQUALS(HostAndPort("syncTarget"), hbResponse.getSyncingTo()); ASSERT_EQUALS(1, hbResponse.getConfigVersion()); ASSERT_EQUALS(Timestamp(10, 0), hbResponse.getElectionTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 10), 0), hbResponse.getDurableOpTime()); ASSERT_EQUALS(OpTime(Timestamp(0, 50), 0), hbResponse.getAppliedOpTime()); ASSERT_EQUALS(Seconds(10), hbResponse.getTime()); ASSERT_EQUALS(true, hbResponse.isElectable()); ASSERT_EQUALS(config.toBSON().toString(), hbResponse.getConfig().toBSON().toString()); hbResponseObj = hbResponse.toBSON(false); ASSERT_EQUALS(2, hbResponseObj.nFields()); ASSERT_EQUALS(true, hbResponseObj["mismatch"].trueValue()); // NOTE: Does not check round-trip. Once noteMismached is set the bson will return an error // from initialize parsing. in
null
null
null
null
null
null
github_plus_top10pct_by_avg
itializeResult = hbResponseObjRoundTripChecker.initialize(hbResponseObj, 0); ASSERT_NOT_EQUALS(Status::OK(), initializeResult); ASSERT_EQUALS(ErrorCodes::InconsistentReplicaSetNames, initializeResult.code()); } TEST(ReplSetHeartbeatResponse, InitializeWrongElectionTimeType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "electionTime" << "hello"); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS( "Expected \"electionTime\" field in response to replSetHeartbeat command to " "have type Date or Timestamp, but found type string", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeWrongTimeType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "time" << "hello"); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS( "Expected \"time\" field in response to replSetHeartbeat command to " "have a numeric type, but found type string", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeWrongDurableOpTimeType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "durableOpTime" << "hello"); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS("\"durableOpTime\" had the wrong type. Expected object, found string", result.reason()); BSONObj initializerObj2 = BSON("ok" << 1.0 << "durableOpTime" << OpTime().getTimestamp()); Status result2 = hbResponse.initialize(initializerObj2, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result2); ASSERT_EQUALS("\"durableOpTime\" had the wrong type. Expected object, found timestamp", res
null
null
null
null
null
null
github_plus_top10pct_by_avg
ult2.reason()); } TEST(ReplSetHeartbeatResponse, InitializeWrongAppliedOpTimeType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "opTime" << "hello"); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS( "Expected \"opTime\" field in response to replSetHeartbeat command to " "have type Date or Timestamp, but found type string", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeMemberStateWrongType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "state" << "hello"); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS( "Expected \"state\" field in response to replSetHeartbeat command to " "have type NumberInt or NumberLong, but found type string", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeMemberStateTooLow) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "state" << -1); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::BadValue, result); ASSERT_EQUALS( "Value for \"state\" in response to replSetHeartbeat is out of range; " "legal values are non-negative and no more than 10", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeMemberStateTooHigh) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "state" << 11); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::BadValue, result); ASSERT_EQUALS( "Value for \"state\" in response to replSetHeartbeat is out of range; " "legal values are non-negative and no more than 10", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeVer
null
null
null
null
null
null
github_plus_top10pct_by_avg
sionWrongType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "v" << "hello"); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS( "Expected \"v\" field in response to replSetHeartbeat to " "have type NumberInt, but found string", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeReplSetNameWrongType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "v" << 2 << // needs a version to get this far in initialize() "set" << 4); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS( "Expected \"set\" field in response to replSetHeartbeat to " "have type String, but found int", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeHeartbeatMeessageWrongType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "v" << 2 << // needs a version to get this far in initialize() "hbmsg" << 4); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS( "Expected \"hbmsg\" field in response to replSetHeartbeat to " "have type String, but found int", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeSyncingToWrongType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "v" << 2 << // needs a version to get this far in initialize() "syncingTo" << 4); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS( "Expected \"syncingTo\" field in response to replSetHeartbeat to " "have type String, but found i
null
null
null
null
null
null
github_plus_top10pct_by_avg
nt", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeConfigWrongType) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "v" << 2 << // needs a version to get this far in initialize() "config" << 4); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::TypeMismatch, result); ASSERT_EQUALS( "Expected \"config\" in response to replSetHeartbeat to " "have type Object, but found int", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeBadConfig) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 1.0 << "v" << 2 << // needs a version to get this far in initialize() "config" << BSON("illegalFieldName" << 2)); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::BadValue, result); ASSERT_EQUALS("Unexpected field illegalFieldName in replica set configuration", result.reason()); } TEST(ReplSetHeartbeatResponse, InitializeBothElectionTimeTypesSameResult) { ReplSetHeartbeatResponse hbResponseDate; ReplSetHeartbeatResponse hbResponseTimestamp; BSONObjBuilder initializerDate; BSONObjBuilder initializerTimestamp; Date_t electionTime = Date_t::fromMillisSinceEpoch(974132); initializerDate.append("ok", 1.0); initializerDate.append("v", 1); initializerDate.appendDate("electionTime", electionTime); Status result = hbResponseDate.initialize(initializerDate.obj(), 0); ASSERT_EQUALS(Status::OK(), result); initializerTimestamp.append("ok", 1.0); initializerTimestamp.append("v", 1); initializerTimestamp.appendTimestamp("electionTime", electionTime.toULL()); result = hbResponseTimestamp.initialize(initializerTimestamp.obj(), 0); ASSERT_EQUALS(Status::OK(), result); ASSERT_EQUALS(hbResponseTimestamp.getElectionTime(), hbResponseTimestamp.getElectionTime()); }
null
null
null
null
null
null
github_plus_top10pct_by_avg
TEST(ReplSetHeartbeatResponse, InitializeBothOpTimeTypesSameResult) { ReplSetHeartbeatResponse hbResponseDate; ReplSetHeartbeatResponse hbResponseTimestamp; BSONObjBuilder initializerDate; BSONObjBuilder initializerTimestamp; Date_t opTime = Date_t::fromMillisSinceEpoch(974132); initializerDate.append("ok", 1.0); initializerDate.append("v", 1); initializerDate.appendDate("opTime", opTime); Status result = hbResponseDate.initialize(initializerDate.obj(), 0); ASSERT_EQUALS(Status::OK(), result); initializerTimestamp.append("ok", 1.0); initializerTimestamp.append("v", 1); initializerTimestamp.appendTimestamp("opTime", opTime.toULL()); result = hbResponseTimestamp.initialize(initializerTimestamp.obj(), 0); ASSERT_EQUALS(Status::OK(), result); ASSERT_EQUALS(hbResponseTimestamp.getAppliedOpTime(), hbResponseTimestamp.getAppliedOpTime()); } TEST(ReplSetHeartbeatResponse, NoConfigStillInitializing) { ReplSetHeartbeatResponse hbResp; std::string msg = "still initializing"; Status result = hbResp.initialize(BSON("ok" << 1.0 << "rs" << true << "hbmsg" << msg), 0); ASSERT_EQUALS(Status::OK(), result); ASSERT_EQUALS(true, hbResp.isReplSet()); ASSERT_EQUALS(msg, hbResp.getHbMsg()); } TEST(ReplSetHeartbeatResponse, InvalidResponseOpTimeMissesConfigVersion) { ReplSetHeartbeatResponse hbResp; std::string msg = "still initializing"; Status result = hbResp.initialize(BSON("ok" << 1.0 << "opTime" << Timestamp()), 0); ASSERT_EQUALS(ErrorCodes::NoSuchKey, result.code()); ASSERT_TRUE(stringContains(result.reason(), "\"v\"")) << result.reason() << " doesn't contain 'v' field required error msg"; } TEST(ReplSetHeartbeatResponse, MismatchedRepliSetNames) { ReplSetHeartbeatResponse hbResponse; BSONObj initializerObj = BSON("ok" << 0.0 << "mismatch" << true); Status result = hbResponse.initialize(initializerObj, 0); ASSERT_EQUALS(ErrorCodes::InconsistentReplicaSetNames, result.code()); } TEST(ReplSetHear
null
null
null
null
null
null
github_plus_top10pct_by_avg
tbeatResponse, AuthFailure) { ReplSetHeartbeatResponse hbResp; std::string errMsg = "Unauthorized"; Status result = hbResp.initialize( BSON("ok" << 0.0 << "errmsg" << errMsg << "code" << ErrorCodes::Unauthorized), 0); ASSERT_EQUALS(ErrorCodes::Unauthorized, result.code()); ASSERT_EQUALS(errMsg, result.reason()); } TEST(ReplSetHeartbeatResponse, ServerError) { ReplSetHeartbeatResponse hbResp; std::string errMsg = "Random Error"; Status result = hbResp.initialize(BSON("ok" << 0.0 << "errmsg" << errMsg), 0); ASSERT_EQUALS(ErrorCodes::UnknownError, result.code()); ASSERT_EQUALS(errMsg, result.reason()); } } // namespace } // namespace repl } // namespace mongo module java.nonstandard.XmlTranscode; import java.lang.util; import java.lang.exceptions; import java.lang.Math; /++ + Decode XML entities into UTF8 string. + Eg. "&amp;" -> "&", "&#38;" -> "&", "&#x26;" -> "&" + Throws TextException on failure + The given string is modified. +/ String xmlUnescape( String str ){ void error(){ throw new RuntimeException( "xmlUnescape" ); } // &lt; ... // &#1234; // &#x12AF; String src = str; String trg = str; while( src.length ){ if( src[0] !is '&' ){ //trg[0] = src[0]; trg = trg[1..$]; src = src[1..$]; } else{ src = src[1..$]; // go past '&' if( src.length < 2 ) error(); // search semi int len = Math.min( cast(int)src.length, 10 ); // limit semi search to possible longest entityname int semi = java.lang.util.indexOf( src[0 .. len ], ';' ); if( semi is -1 ) error(); // no semi found String entityName = src[ 0 .. semi ]; // name without semi dchar entityValue = 0; switch( entityName ){ case "lt": entityValue = '<'; break; case "gt": entityValue = '>'; break; case "amp": entityValue = '&'; break;
null
null
null
null
null
null
github_plus_top10pct_by_avg
case "quot": entityValue = '\"'; break; case "apos": entityValue = '\''; break; default: if( entityName[0] is 'x' ){ if( semi < 2 ) error(); if( semi > 9 ) error(); foreach( hex; entityName[1..$] ){ entityValue <<= 4; if( hex >= '0' && hex <= '9' ){ entityValue |= ( hex - '0' ); } else if( hex >= 'a' && hex <= 'f' ){ entityValue |= ( hex - 'a' ); } else if( hex >= 'A' && hex <= 'F' ){ entityValue |= ( hex - 'A' ); } else{ error(); } } } else{ if( semi < 1 ) error(); if( semi > 9 ) error(); foreach( dec; entityName[1..$] ){ if( dec >= '0' && dec <= '9' ){ entityValue *= 10; entityValue += ( dec - '0' ); } else{ error(); } } } } String res = String_valueOf( entityValue ); trg = trg[ res.length .. $ ]; src = src[ semi +1 .. $ ]; // go past semi } } return str[ 0 .. trg.ptr-str.ptr ]; } /++ + Encode XML entities into UTF8 string. + First checks if processing is needed. + If not, the original string is returned. + If processing is needed, a new string is allocated. +/ String xmlEscape( String xml ){ bool needsReplacement( dchar c ){ switch( c ){ c
null
null
null
null
null
null
github_plus_top10pct_by_avg
ase '<': case '>': case '&': case '\"': case '\'': case '\r': case '\n': case '\u0009': return true; default: return c > 0x7F; } } // Check if processing is needed foreach( char c; xml ){ if( needsReplacement( c )){ goto Lprocess; } } return xml; Lprocess: // yes, do a new string, start with +20 chars char[] res = new char[ xml.length + 20 ]; res.length = 0; foreach( dchar c; xml ){ if( !needsReplacement( c )){ res ~= c; } else{ res ~= '&'; switch( c ){ case '<': res ~= "lt"; break; case '>': res ~= "gt"; break; case '&': res ~= "amp"; break; case '\"': res ~= "quot"; break; case '\'': res ~= "apos"; break; case '\r': case '\n': case '\u0009': default: char toHexDigit( int i ){ if( i < 10 ) return cast(char)('0'+i); return cast(char)('A'+i-10); } res ~= "#x"; if( c <= 0xFF ){ res ~= toHexDigit(( c >> 4 ) & 0x0F ); res ~= toHexDigit(( c >> 0 ) & 0x0F ); } else if( c <= 0xFFFF ){ res ~= toHexDigit(( c >> 12 ) & 0x0F ); res ~= toHexDigit(( c >> 8 ) & 0x0F ); res ~= toHexDigit(( c >> 4 ) & 0x0F ); res ~= toHexDigit(( c >> 0 ) & 0x0F ); } else if( c <= 0xFFFFFF ){ res ~= toHexDigit(( c >> 20 ) & 0x0F ); res ~= toHexDigit(( c >> 16 ) & 0x0F ); res ~= toHexDigit(( c >> 12 ) & 0x0F ); res ~= toHexDigit(( c >> 8 )
null
null
null
null
null
null
github_plus_top10pct_by_avg